# Regenerate API token

```http
POST https://api.axiom.co/v2/tokens/{id}/regenerate
```

Creates a new API token with the existing token's capabilities, or with those in `newToken`, and returns its secret value. The existing token keeps working until `existingTokenExpiresAt`; set it to the current time to revoke it immediately.

## Authentication

Authenticate using an API token or personal access token (PAT). Include the token as a Bearer token: `Authorization: Bearer <token>`. For more information, see [Tokens](/reference/tokens).

## Parameters

- `id` (path; string; required)

## Request body

Content type: `application/json`

- `existingTokenExpiresAt` (string (date-time); required): Expiration date of the existing token (ISO 8601 format)
- `newToken` (`CreateAPIToken`)
- `newTokenExpiresAt` (string (date-time); nullable): Expiration date of the new token (ISO 8601 format)

## Responses

### 200: New API token, including its secret `token` value.

Content type: `application/json`

Type: `CreateAPITokenResponse`

### 400: Missing `existingTokenExpiresAt`, expiry set in both `newTokenExpiresAt` and `newToken.expiresAt`, or invalid capabilities in `newToken`.

### 404: API token not found or expired.

## Schemas

### CreateAPIToken

Object.

- `datasetCapabilities` (`datasetCapabilities`)
- `description` (string): Description of the token
- `expiresAt` (string (date-time); nullable): Expiration date of the token (ISO 8601 format)
- `name` (string; required): Name of the token
- `orgCapabilities` (`orgCapabilities`)
- `viewCapabilities` (`viewCapabilities`)

### CreateAPITokenResponse

All of the following:

- `APIToken`
- Object with:
  - `token` (string)

### datasetCapabilities

Type: map of string to object

### orgCapabilities

Object.

- `annotations` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Annotations capability
- `apiTokens` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): API tokens capability
- `auditLog` (array of string; one of `"read"`): Audit Log capability
- `billing` (array of string; one of `"read"`, `"update"`): Billing capability
- `dashboards` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Dashboards capability
- `datasets` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Datasets capability
- `endpoints` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Endpoints capability
- `integrations` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Integrations capability
- `labels` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Labels capability
- `monitors` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Monitors capability
- `notifiers` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Notifiers capability
- `rbac` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Access control capability
- `sharedAccessKeys` (array of string; one of `"read"`, `"update"`): Shared access keys capability
- `users` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Users capability
- `views` (array of string; one of `"create"`, `"read"`, `"update"`, `"delete"`): Views capability

### viewCapabilities

Type: map of string to object

### APIToken

Object.

- `apiLastUsed` (string (date-time); nullable; read-only): When the token was last used on an API other than ingest
- `auditIdentity` (string; read-only): Audit identity of the token
- `datasetCapabilities` (`datasetCapabilities`; required)
- `description` (string): Description of the token
- `expiresAt` (string (date-time); nullable; read-only): Expiration date of the token (ISO 8601 format)
- `id` (string; required): ID of the token
- `ingestLastUsed` (string (date-time); nullable; read-only): When the token was last used to ingest
- `name` (string; required): Name of the token
- `orgCapabilities` (`orgCapabilities`; required)
- `samlAuthenticated` (boolean)
- `viewCapabilities` (`viewCapabilities`)