Create an API token
The caller owns the token, and the owner never changes. Each access row gives permission keys on places; a row can only give what the caller holds on each of its places. A token cannot be edited later: only rotated or revoked. The secret is not in this response. The web app makes it as a Better Auth
better-auth.session_token<token>Better Auth session cookie. Production uses the __Secure- prefixed name.
Idempotency-Key?stringMakes retries safe. A repeated key with the same request returns the first result and sets
Idempotent-Replayed: true. The same key with a different request answers 409
idempotency.key_reused, and while the first request is still running 409
idempotency.in_progress. Results are kept for 24 hours. Server errors and refusals for lack
of sign-in or permission are not kept, so a retry runs again.
^[A-Za-z0-9_.:-]+$1 <= length <= 255application/json- body
name*string1 <= length <= 64description?stringlength <= 280expiry*ApiTokenExpiryHow long the token lives from its creation.
"30d""90d""1y""never"rateLimitPerMinute?integerRequests per minute the token may make. Absent means no limit of its own.
1 <= value <= 100000access*array<>1 <= items <= 50The token.
application/json- response
id*stringuuidname*stringdescription*stringowner*status*ApiTokenStatus"active""expired""revoked"prefix?stringThe start of the current secret, such as wrd_4f9a, to tell tokens apart. Absent until the secret is made.
generation*integerWhich secret is current. Rotating starts the next one.
1 <= valuepreviousSecretUntil?stringWhen the secrets before the current one stop working, while they still do.
date-timeaccess*array<>rateLimitPerMinute?integerexpiresAt?stringdate-timelastUsedAt?stringdate-timecreatedAt*stringdate-timerevokedAt?stringdate-timerevokedBy?curl -X POST 'https://wardn.example.com/api/v1/api-tokens' \ -H 'Content-Type: application/json' \ -d '{ "name": "string", "expiry": "30d", "access": [ { "permissions": [ "string" ], "places": [ { "kind": "org" } ] } ]}'{ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "name": "string", "description": "string", "owner": { "userId": "string", "name": "string", "since": "2019-08-24T14:15:22Z" }, "status": "active", "prefix": "string", "generation": 1, "previousSecretUntil": "2019-08-24T14:15:22Z", "access": [ { "permissions": [ "string" ], "places": [ { "kind": "org", "id": "string", "name": "string", "missing": true } ] } ], "rateLimitPerMinute": 0, "expiresAt": "2019-08-24T14:15:22Z", "lastUsedAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z", "revokedAt": "2019-08-24T14:15:22Z", "revokedBy": { "userId": "string", "name": "string", "since": "2019-08-24T14:15:22Z" }}List the organization's API tokens GET
Every token of the organization, newest first, revoked and expired ones included. Only owners and admins see the list.
Which permissions the caller could give a token on some places POST
The keys the caller holds on every one of the places, so the access picker can grey out the rest.