---
title: Delete a service token
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/typescript)

[Zero Trust](https://developers.cloudflare.com/api/typescript/resources/zero_trust)

[Access](https://developers.cloudflare.com/api/typescript/resources/zero_trust/subresources/access)

[Service Tokens](https://developers.cloudflare.com/api/typescript/resources/zero_trust/subresources/access/subresources/service_tokens)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Delete a service token

client.zeroTrust.access.serviceTokens.delete(stringserviceTokenID, ServiceTokenDeleteParams {account\_id, zone\_id } params?, RequestOptionsoptions?): [ServiceToken](<https://developers.cloudflare.com/api/typescript/resources/zero_trust#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)>) {id, client\_id, duration, 7 more }

DELETE/{accounts\_or\_zones}/{account\_or\_zone\_id}/access/service\_tokens/{service\_token\_id}

Deletes a service token.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Access: Service Tokens Write`

##### ParametersExpand Collapse

serviceTokenID: string

UUID.

maxLength36

[Link to this property](<#(resource)%20zero_trust.access.service_tokens%20%3E%20(method)%20delete%20%3E%20(params)%20default%20%3E%20(param)%20service_token_id%20%3E%20(schema)>)

<details>

<summary>

params: ServiceTokenDeleteParams {account\_id, zone\_id }

</summary>

account\_id?: string

The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(method)%20delete%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

zone\_id?: string

The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(method)%20delete%20%3E%20(params)%20default%20%3E%20(param)%20zone_id">Link to this property</a>

</details>

[Link to this property](<#(resource)%20zero_trust.access.service_tokens%20%3E%20(method)%20delete%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

ServiceToken {id, client\_id, duration, 7 more }

</summary>

id?: string

The ID of the service token.

maxLength36

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

client\_id?: string

The Client ID for the service token. Access will check for this value in the <code>CF-Access-Client-ID</code> request header.

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20client_id">Link to this property</a>

duration?: string

The duration for how long the service token will be valid. Must be in the format <code>300ms</code> or <code>2h45m</code>, or the special value <code>forever</code> for non-expiring tokens. Valid time units are: ns, us (or µs), ms, s, m, h. The default is 1 year in hours (8760h).

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20duration">Link to this property</a>

enabled?: boolean

Whether the service token is enabled. A disabled service token cannot be used to authenticate; both its current and previous <code>client_secret</code> stop being accepted, but the token itself is preserved and can be re-enabled. A service token reported as leaked is disabled automatically and cannot be re-enabled until its secret is rotated; attempting to do so returns a 409. Defaults to enabled when omitted on create.

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20enabled">Link to this property</a>

expires\_at?: string

formatdate-time

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20expires_at">Link to this property</a>

leak\_report\_url?: string

Where the leaked <code>client_secret</code> was found, if provided by the reporter. Omitted if the token has not been reported as leaked.

formaturi

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20leak_report_url">Link to this property</a>

leak\_reported\_at?: string

When a secret scanning partner reported this service token’s <code>client_secret</code> as leaked. A leaked service token is disabled and must be rotated before it can be re-enabled. Cleared once the secret is rotated. Omitted if the token has not been reported as leaked.

formatdate-time

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20leak_reported_at">Link to this property</a>

leak\_reporter?: string

The secret scanning partner that reported the leak. Omitted if the token has not been reported as leaked.

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20leak_reporter">Link to this property</a>

name?: string

The name of the service token.

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

tags?: Record&lt;string, string&gt;| null

Tags associated with the service token, as key-value pairs. On update, replaces all existing tags.

<a href="#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)%20%3E%20(property)%20tags">Link to this property</a>

</details>

[Link to this property](<#(resource)%20zero_trust.access.service_tokens%20%3E%20(model)%20service_token%20%3E%20(schema)>)

### Delete a service token

TypeScript

HTTPTypeScriptPythonGoTerraform

```
import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const serviceToken = await client.zeroTrust.access.serviceTokens.delete(
  'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
  { account_id: 'account_id' },
);

console.log(serviceToken.id);
```

200 example

```
{
  "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,
  "result": {
    "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
    "client_id": "88bf3b6d86161464f6509f7219099e57.access.example.com",
    "created_at": "2014-01-01T05:20:00.12345Z",
    "duration": "60m",
    "enabled": true,
    "expires_at": "2014-01-01T05:20:00.12345Z",
    "last_seen_at": "2014-01-01T05:20:00.12345Z",
    "leak_report_url": "https://github.com/example/repo/blob/main/config.yaml",
    "leak_reported_at": "2014-01-01T05:20:00.12345Z",
    "leak_reporter": "github",
    "name": "CI/CD token",
    "tags": {
      "environment": "production"
    },
    "updated_at": "2014-01-01T05:20:00.12345Z"
  }
}
```

##### Returns Examples

200 example

```
{
  "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,
  "result": {
    "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
    "client_id": "88bf3b6d86161464f6509f7219099e57.access.example.com",
    "created_at": "2014-01-01T05:20:00.12345Z",
    "duration": "60m",
    "enabled": true,
    "expires_at": "2014-01-01T05:20:00.12345Z",
    "last_seen_at": "2014-01-01T05:20:00.12345Z",
    "leak_report_url": "https://github.com/example/repo/blob/main/config.yaml",
    "leak_reported_at": "2014-01-01T05:20:00.12345Z",
    "leak_reporter": "github",
    "name": "CI/CD token",
    "tags": {
      "environment": "production"
    },
    "updated_at": "2014-01-01T05:20:00.12345Z"
  }
}
```