---
title: "Create a personal access token"
method: POST
path: "/api-tokens"
tags: ["developer"]
---

# Create a personal access token

`POST /api-tokens`

## Request

- Base URL: `https://api.onplana.com/api`
- URL: `https://api.onplana.com/api/api-tokens`
- Auth: HTTP bearer

Creates a new PAT and returns the **plaintext token once**. Store it securely - it cannot be retrieved again. **JWT only** - PATs cannot create other PATs.

## Request body

- object
  - `name` string, required
  - `organizationId` string, uuid, required
  - `scopes` string[], required
  - `expiresAt` string, date-time: Optional expiry (ISO 8601)

## Response `201`

Token created - plaintext returned once

- CreateApiTokenResponse: A Personal Access Token (PAT) for programmatic API access.
  - `id` string, uuid, required
  - `name` string, required: Human-readable label for this token
  - `tokenPrefix` string, required: First 12 chars of the token (e.g. "pat_AbCdEfGh") - safe to display
  - `scopes` string[], required
  - `organizationId` string, uuid, required
  - `orgPlan` string: Plan snapshot at creation time
  - `expiresAt` string, date-time, nullable
  - `lastUsedAt` string, date-time, nullable
  - `createdAt` string, date-time, required
  - `organization` object
    - `name` string
    - `slug` string
  - `token` string, required: Plaintext token - shown ONCE; save it immediately.
  - `warning` string, required

## Other responses

- `400`: Validation error
- `401`: Unauthorized - missing or invalid JWT
- `403`: Forbidden - insufficient role

---

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