---
type: api
title: Create a service token
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/operation/operation-post-fleet-service-tokens
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/operation/operation-post-fleet-service-tokens
products:
  - Kibana
---

# Create a service token

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/fleet/service_tokens`
- `POST` `/s/{space_id}/api/fleet/service_tokens`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/authentication#apikeyauth)

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

Create a Fleet Server service token. The token is used to enroll Fleet Server instances with Kibana.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.

## Request Body

`application/json`

- `remote` (boolean · default: false) — optional

## Responses

#### `200`

Successful response

`application/json`

- `name` (string)
- `value` (string)
#### `400`

Bad Request

`application/json`

- `attributes` (object)
- `error` (string)
- `errorType` (string)
- `message` (string)
- `statusCode` (number)
## Code Examples

#### Console

```console
POST /api/fleet/service_tokens
{
  "remote": true
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/service_tokens" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
  "remote": true
}'
```

## Response Examples

#### Post generate service token

The generated Fleet Server service token

```json
{
  "name": "elastic/fleet-server/token-1234567890",
  "value": "AAEAAWVsYXN0aWMvZmxlZXQtc2VydmVyL3Rva2VuLTEyMzQ1Njc4OTA6QUJDREVGR0hJSktMTU5P"
}
```

#### Generic error response

Example of a generic error response

```json
{
  "error": "Bad Request",
  "message": "An error message describing what went wrong",
  "statusCode": 400
}
```

