# Subdomain ## Get Worker subdomain `client.workers.scripts.subdomain.get(stringscriptName, SubdomainGetParamsparams, RequestOptionsoptions?): SubdomainGetResponse` **get** `/accounts/{account_id}/workers/scripts/{script_name}/subdomain` Get if the Worker is available on the workers.dev subdomain. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: SubdomainGetParams` - `account_id: string` Identifier. ### Returns - `SubdomainGetResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const subdomain = await client.workers.scripts.subdomain.get('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(subdomain.enabled); ``` #### 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": { "enabled": false, "previews_enabled": false }, "success": true } ``` ## Post Worker subdomain `client.workers.scripts.subdomain.create(stringscriptName, SubdomainCreateParamsparams, RequestOptionsoptions?): SubdomainCreateResponse` **post** `/accounts/{account_id}/workers/scripts/{script_name}/subdomain` Enable or disable the Worker on the workers.dev subdomain. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: SubdomainCreateParams` - `account_id: string` Path param: Identifier. - `enabled: boolean` Body param: Whether the Worker should be available on the workers.dev subdomain. - `previews_enabled?: boolean` Body param: Whether the Worker's Preview URLs should be available on the workers.dev subdomain. ### Returns - `SubdomainCreateResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const subdomain = await client.workers.scripts.subdomain.create('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', enabled: true, }); console.log(subdomain.enabled); ``` #### 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": { "enabled": false, "previews_enabled": false }, "success": true } ``` ## Delete Worker subdomain `client.workers.scripts.subdomain.delete(stringscriptName, SubdomainDeleteParamsparams, RequestOptionsoptions?): SubdomainDeleteResponse` **delete** `/accounts/{account_id}/workers/scripts/{script_name}/subdomain` Disable all workers.dev subdomains for a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: SubdomainDeleteParams` - `account_id: string` Identifier. ### Returns - `SubdomainDeleteResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const subdomain = await client.workers.scripts.subdomain.delete('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(subdomain.enabled); ``` #### 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": { "enabled": false, "previews_enabled": false }, "success": true } ``` ## Domain Types ### Subdomain Get Response - `SubdomainGetResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Subdomain Create Response - `SubdomainCreateResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Subdomain Delete Response - `SubdomainDeleteResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain.