Skip to content
Luna
Esc
↑↓navigate↵open⌘Jpreview

Rotate an API key

Makes a replacement for an API key, with the same permissions and reach. The old key keeps working for the overlap, so that you can move your programs over. The new key is shown once, in this response.

POST/_luna/tokens/{id}/rotate
Authorization
AuthorizationBearer token · headerrequired

An account key (la_…), an API key (lt_…) or a session token (ls_…). The scopes listed are the permissions the operation needs.

Scopes:tokens:write
Path parameters
idstringrequired

The key's id: 16 hex characters.

Request body
application/json
One of:
Rotation
overlapSecondsinteger<int64> | null

How long the old key keeps working, in seconds. One hour when left out. 0 ends it at once.

min 0 · default: null
null
null
Responses
200

The replacement key.

idstringrequired

The key's id, for revoking or rotating it.

tokenstringrequired

The key. Send it as Authorization: Bearer <TOKEN>.

expiresMsinteger<int64> | null

When the key stops working, in milliseconds since the Unix epoch. Null when it does not expire.

min 0
default

The request failed. The status says how and error.message says why.

errorErrorDetailrequired
Show properties
codestring | null

A code for programs to branch on, when the error has one.

messagestringrequired

What went wrong, in a sentence a person can read.

Try it
Server
Authorization
Parameters
Bodyapplication/json
Request
curl -X POST 'https://luna.example.com/_luna/tokens/string/rotate' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "overlapSeconds": null
}'
Response
{
  "id": "string",
  "token": "string",
  "expiresMs": 0
}

Was this page helpful?