---
title: "POST /scoped-tokens"
method: POST
path: "/scoped-tokens"
---

# POST /scoped-tokens

`POST /scoped-tokens`

## Request

- Base URL: `https://api.useanima.sh/v1`
- URL: `https://api.useanima.sh/v1/scoped-tokens`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

## Request body

- object: Issue a new scoped token
  - `audience` string, required: Token audience (typically the service identifier, e.g. 'api.useanima.sh')
  - `scopes` string[], required: Scope strings the token grants, e.g. ['email:send']
  - `ttlSeconds` integer: Token TTL in seconds (max 1h)
  - `parentJti` string: Parent token jti for delegation chains
  - `metadata` object: Free-form metadata (task id, conversation id, etc.)

## Response `200`

OK

- object: Result of issuing a scoped token
  - `token` string, required: Raw JWT — only returned at issuance time
  - `record` object, required: Persisted record (no raw JWT)
    - `id` string, required: Database id (cuid)
    - `jti` string, required: JWT id (matches the token's jti claim)
    - `agentId` string, required: Issuing agent id
    - `orgId` string, required: Organization id
    - `scopes` string[], required: Granted scopes
    - `audience` string, required: Audience (aud claim)
    - `parentJti` string, nullable, required: Parent token jti, null for root
    - `expiresAt` string, date-time, required: Token expiry (ISO 8601)
    - `revokedAt` string, date-time, nullable, required: Revocation timestamp, null if active
    - `createdAt` string, date-time, required: Creation timestamp

---

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