---
title: "Create an access key"
method: POST
path: "/api/tokens"
tags: ["Account"]
---

# Create an access key

`POST /api/tokens`

## Request

- Base URL: `https://api.xpoz.ai`
- URL: `https://api.xpoz.ai/api/tokens`
- Auth: HTTP bearer

Create an API access key for the caller, or return the existing one (`isExisting: true`).

## Request body

- object
  - `description` string

## Response `200`

Access key.

- AccessKeyCreated
  - `success` true, required
  - `data` object, required
    - `id` string, required
    - `accessKey` string, required
    - `accessKeyPrefix` string, required
    - `keyName` string, required
    - `expiresAt` string, date-time, nullable
    - `createdAt` string, date-time, required
  - `message` string, required
  - `isExisting` boolean, required

## Other responses

- `400`: Missing user data on the session.
- `401`: Missing or invalid credentials.
- `500`: Server error.

---

[API](https://skmtc.dev/xpoz/apis/xpoz-api.md) · [All operations](https://skmtc.dev/xpoz/apis/xpoz-api/llms.txt) · [OpenAPI document](https://skmtc.dev/xpoz/apis/xpoz-api/revisions/c18261f587a4?raw)
