---
type: api
title: Delete service account tokens
description: Delete service account tokens for a service in a specified namespace.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-security-delete-service-token
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-security-delete-service-token
products:
  - Elasticsearch
---

# Delete service account tokens

Availability: 5.5+

## Paths

- `DELETE` `/_security/service/{namespace}/{service}/credential/token/{name}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/authentication#bearerauth)

#### Path Parameters

- `namespace` (string)
  The namespace, which is a top-level grouping of service accounts.
- `service` (string)
  The service name.
- `name` (string Name)
  The name of the service account token.

## Description

Delete service account tokens for a service in a specified namespace.
This route serves both kinds of service account, but the privileges differ: `manage_service_account` authorizes tokens of built-in accounts in the `elastic` namespace only, and tokens of a user-managed account require `manage_security`.

IMPORTANT: On Serverless, non-operator users can delete tokens for only `elastic/fleet-server` and `elastic/fleet-server-remote`.
Deleting tokens for any other service account requires operator privileges.

## Required authorization

* Cluster privileges: `manage_service_account`

[More about service accounts](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/service-accounts)

## Query String Parameters

- `refresh` (enum Refresh)
  If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.
  Values: `true`, `false`, `wait_for`

## Response

`application/json`

- `found` (boolean)
  If the service account token is successfully deleted, the request returns `{"found": true}`.
Otherwise, the response will have status code 404 and `found` is set to `false`.
## Code Examples

#### Console

```console
DELETE /_security/service/elastic/fleet-server/credential/token/token42
```

#### JavaScript

```javascript
const response = await client.security.deleteServiceToken({
  namespace: "elastic",
  service: "fleet-server",
  name: "token42",
});
```

#### Python

```python
resp = client.security.delete_service_token(
    namespace="elastic",
    service="fleet-server",
    name="token42",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_security/service/elastic/fleet-server/credential/token/token42" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.security().deleteServiceToken(d -> d
    .name("token42")
    .namespace("elastic")
    .service("fleet-server")
);
```

#### C#

```c#
var response = await client.Security.DeleteServiceTokenAsync(@namespace: "elastic", service: "fleet-server", name: "token42");
```

#### PHP

```php
$resp = $client->security()->deleteServiceToken([
    "namespace" => "elastic",
    "service" => "fleet-server",
    "name" => "token42",
]);
```

#### Ruby

```ruby
response = client.security.delete_service_token(
  namespace: "elastic",
  service: "fleet-server",
  name: "token42"
)
```

## Response Examples

#### Delete service token response example1

A successful response from `DELETE /_security/service/elastic/fleet-server/credential/token/token42`.

```json
{
  "found" : true
}
```

