Skip to content

Create An API Token

POST
/tokens
curl --request POST \
--url https://markdawn.space/api/v1/tokens \
--header 'Content-Type: application/json' \
--cookie better-auth.session_token=<better-auth.session_token> \
--data '{ "name": "Local CLI", "scopes": [ "pages:read" ], "expiresAt": null }'

Creates an API token through a browser session. The token secret appears only in this response. If scopes is omitted, the token starts with pages:read.

Media typeapplication/json
object
name
required
string
>= 1 characters <= 100 characters
scopes
Array<string>
>= 1 items
Allowed values: pages:read pages:write
expiresAt
Any of:
string
Example
{
"name": "Local CLI",
"scopes": [
"pages:read"
],
"expiresAt": null
}

Token metadata and the secret, which is shown only once.

Media typeapplication/json
object
id
required
string format: uuid
/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/
name
required
string
scopes
required
Array<string>
Allowed values: pages:read pages:write
expiresAt
required
Any of:
string
lastUsedAt
required
Any of:
string
createdAt
required
string
token
required
string
Example
{
"scopes": [
"pages:read"
]
}