> ## Documentation Index
> Fetch the complete documentation index at: https://okl-ink.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create API Token

> Issue a new scoped API token for the currently authenticated user session.

# Create API Token

Generates a new API token. The plaintext token is returned **exactly once** in the response and stored server-side as a SHA-256 hash.

<Note>
  Creating an API token requires an active authenticated session cookie (via web login).
</Note>

### Request Body

<ParamField body="name" type="string">
  An optional human-readable name or label for the token (max 64 characters).
</ParamField>

<ParamField body="ttlDays" type="number" default="365">
  Token lifetime in days. Defaults to 365 days.
</ParamField>

<ParamField body="scopes" type="array" default="[&#x22;pages:read&#x22;, &#x22;pages:write&#x22;, &#x22;links:write&#x22;]">
  Array of allowed scopes: `pages:read`, `pages:write`, `links:write`, `tokens:manage`.
</ParamField>

### Response

<ResponseField name="token" type="string">
  The plaintext token string to be used with `Authorization: Bearer <token>`.
</ResponseField>

<ResponseField name="id" type="string">
  Unique token ID in the database.
</ResponseField>

<ResponseField name="scopes" type="array">
  Assigned permission scopes.
</ResponseField>

<ResponseField name="plan" type="string">
  Assigned tier plan (`free`, `pro`, `enterprise`).
</ResponseField>

<ResponseField name="expiresAt" type="string">
  ISO 8601 expiration timestamp.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://okl.ink/api/v1/tokens \
    -H "Content-Type: application/json" \
    -d '{
      "name": "GitHub Actions CI",
      "ttlDays": 90,
      "scopes": ["pages:read", "pages:write", "links:write"]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "token": "4f9d8a1c7e2b6d5f0a3c9e8d7b6a5c4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c",
    "id": "cmsh98127391823",
    "scopes": ["pages:read", "pages:write", "links:write"],
    "plan": "free",
    "expiresAt": "2027-08-31T00:00:00.000Z"
  }
  ```
</ResponseExample>
