API tokens
Preview

Revoke a token

Every secret of the token stops working at once. The token stays in the list as revoked. It cannot be undone.

POST
/api-tokens/{tokenId}/revoke
cookiebetter-auth.session_token<token>

Better Auth session cookie. Production uses the __Secure- prefixed name.

tokenId*string
Formatuuid
Idempotency-Key?string

Makes 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.

Match^[A-Za-z0-9_.:-]+$
Length1 <= length <= 255

Response Body

The revoked token.

application/json
  1. response
id*string
Formatuuid
name*string
description*string
owner*
status*ApiTokenStatus
Value in"active""expired""revoked"
prefix?string

The start of the current secret, such as wrd_4f9a, to tell tokens apart. Absent until the secret is made.

generation*integer

Which secret is current. Rotating starts the next one.

Range1 <= value
previousSecretUntil?string

When the secrets before the current one stop working, while they still do.

Formatdate-time
access*array<>
rateLimitPerMinute?integer
expiresAt?string
Formatdate-time
lastUsedAt?string
Formatdate-time
createdAt*string
Formatdate-time
revokedAt?string
Formatdate-time
revokedBy?
Example Request
curl -X POST 'https://wardn.example.com/api/v1/api-tokens/497f6eca-6276-4993-bfeb-53cbbbba6f08/revoke'
Example Response
{  "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"  }}