---
title: "Create a bearer credential"
method: POST
path: "/api/v1/tokens"
tags: ["Tokens"]
---

# Create a bearer credential

`POST /api/v1/tokens`

## Request

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

## Headers

- `X-Request-Id` string

## Request body

- CreateTokenRequest
  - `name` string, required
  - `scopes` union
    - string
    - string[]
  - `expiresInDays` union: Days until the token expires, from 1 to 365. Omit it for the 90-day default; send null or "never" for a token that never expires.
    - integer
    - 'never'

## Response `201`

Success

- CreateTokenEnvelope
  - `ok` unknown, required
  - `requestId` string, required
  - `data` CreateTokenData, required
    - `token` string, required
    - `credential` CredentialMetadata, required
      - `id` string, required
      - `name` string, required
      - `tokenPrefix` string, required
      - `scopes` string[], required
      - `createdAt` string, date-time, required
      - `updatedAt` string, date-time, required
      - `lastUsedAt` string, date-time, nullable, required
      - `revokedAt` string, date-time, nullable, required
      - `expiresAt` string, date-time, nullable, required

## Other responses

- `400`: Errors: invalid_json, validation_error, invalid_scope
- `401`: Errors: authentication_required, invalid_token
- `403`: Errors: insufficient_scope
- `405`: Errors: method_not_allowed
- `429`: Errors: rate_limited
- `500`: Errors: internal_error
- `503`: Errors: temporarily_unavailable

---

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