---
title: "Create an API token"
method: POST
path: "/api-tokens"
tags: ["Auth"]
---

# Create an API token

`POST /api-tokens`

## Request

- Base URL: `https://app.openpo.st/api/v1`
- URL: `https://app.openpo.st/api/v1/api-tokens`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `openpost_session`

## Request body

- CreateAPITokenInputBody
  - `$schema` string, uri: A URL to the JSON Schema for this object.
  - `expires_at` string, date-time, nullable: Expiry time. Omitted or null defaults to 90 days; the maximum lifetime is one year.
  - `name` string, required: Required user-visible token name
  - `scope` 'cli:full' | 'mcp:read' | 'mcp:full' | 'api:read' | 'api:write': Token scope. Defaults to cli:full.
  - `workspace_id` string: Optional workspace ID this token is limited to

## Response `201`

Created

- CreateAPITokenOutputBody
  - `$schema` string, uri: A URL to the JSON Schema for this object.
  - `item` APITokenResponse, required
    - `created_at` string, required: Creation time
    - `expires_at` string: Token expiry time
    - `id` string, required: API token ID
    - `identity_provider_id` string: Identity provider assurance bound to this token
    - `last_used_at` string: Last successful authentication time
    - `name` string, required: User-visible token name
    - `organization_id` string: Organization this token is bound to by SSO policy
    - `revoked_at` string: Revocation time
    - `scope` string, required: Token scope
    - `status` 'active' | 'expired' | 'revoked', required: Current token status
    - `token_prefix` string, required: First 8 hex characters of the token secret hash
    - `workspace_id` string: Optional workspace ID this token is limited to
  - `token` string, required: Raw API token. Returned once and never stored in plaintext.

## Other responses

- `400`: Bad Request
- `403`: Forbidden
- `422`: Unprocessable Entity
- `500`: Internal Server Error

---

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