# Tail ## List Tails `client.workers.scripts.tail.get(stringscriptName, TailGetParamsparams, RequestOptionsoptions?): TailGetResponse` **get** `/accounts/{account_id}/workers/scripts/{script_name}/tails` Get list of tails currently deployed on a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: TailGetParams` - `account_id: string` Identifier. ### Returns - `TailGetResponse` - `id: string` Identifier. - `expires_at: string` - `url: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const tail = await client.workers.scripts.tail.get('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(tail.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "expires_at": "expires_at", "url": "url" }, "success": true } ``` ## Start Tail `client.workers.scripts.tail.create(stringscriptName, TailCreateParamsparams, RequestOptionsoptions?): TailCreateResponse` **post** `/accounts/{account_id}/workers/scripts/{script_name}/tails` Starts a tail that receives logs and exception from a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: TailCreateParams` - `account_id: string` Path param: Identifier. - `body: unknown` Body param ### Returns - `TailCreateResponse` - `id: string` Identifier. - `expires_at: string` - `url: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const tail = await client.workers.scripts.tail.create('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', body: {}, }); console.log(tail.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "expires_at": "expires_at", "url": "url" }, "success": true } ``` ## Delete Tail `client.workers.scripts.tail.delete(stringscriptName, stringid, TailDeleteParamsparams, RequestOptionsoptions?): TailDeleteResponse` **delete** `/accounts/{account_id}/workers/scripts/{script_name}/tails/{id}` Deletes a tail from a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `id: string` Identifier. - `params: TailDeleteParams` - `account_id: string` Identifier. ### Returns - `TailDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const tail = await client.workers.scripts.tail.delete( 'this-is_my_script-01', '023e105f4ecef8ad9ca31a8372d0c353', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(tail.errors); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true } ``` ## Domain Types ### Consumer Script - `ConsumerScript` A reference to a script that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. ### Tail Get Response - `TailGetResponse` - `id: string` Identifier. - `expires_at: string` - `url: string` ### Tail Create Response - `TailCreateResponse` - `id: string` Identifier. - `expires_at: string` - `url: string` ### Tail Delete Response - `TailDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true`