---
type: api
title: Create enrollment token
description: Creates an enrollment token.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/cloud-enterprise/operation/operation-create-enrollment-token
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/cloud-enterprise/operation/operation-create-enrollment-token
products:
  - Elastic Cloud Enterprise
---

# Create enrollment token

## Paths

- `POST` `/platform/configuration/security/enrollment-tokens`

- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/cloud-enterprise/authentication#basicauth)
- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/cloud-enterprise/authentication#apikey)

## Description

Creates an enrollment token.

## Request Body

`application/json`

Request parameters for the enrollment token

- `roles` ([] string) — optional
  The additional services for which this enrollment token applies (empty if not specified, ie system services only)
- `persistent` (boolean) — required
  Whether this token can subsequently to its grant be revoked from the UI
- `validity_in_seconds` (integer) — optional
  The time in seconds for which this token is valid (defaults to 1 hour). Currently this can only be set for ephemeral (persistent: false) tokens.

## Responses

#### `200`

A token has been generated that can be used to start new servers with the requested roles

`application/octet-stream`

- `token` (string)
  The requested token
- `token_id` (string)
  An identifier for the requested token (if persistent) that can be used in listing and deletion
#### `400`

The token request format was invalid, details in the error (code: 'enrollment_tokens.invalid_token_request')

`application/octet-stream`

- `errors` ([] BasicFailedReplyElement)
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` ([] string)
    If the error can be tied to a specific field or fields in the user request, this lists those fields
#### `403`

No signing key is available to generate a token (code: 'enrollment_tokens.signing_key_not_found')

`application/octet-stream`

- `errors` ([] BasicFailedReplyElement)
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` ([] string)
    If the error can be tied to a specific field or fields in the user request, this lists those fields
## Code Examples

#### Console

```console
POST /platform/configuration/security/enrollment-tokens
```

#### curl

```curl
curl -X POST "/platform/configuration/security/enrollment-tokens"
```

