Skip to Content
SendlySendly
API ReferenceApi keys

Rotate an API key's secret

POST
/api/projects/{id}/api-keys/{keyId}/rotate

Replace the key's secret in place, keeping its id, name and scopes. The PREVIOUS secret stops authenticating immediately — there is no overlap window — so anything still using it starts failing on its next request. As with creation, the response depends on the caller: a signed-in dashboard session receives the new secret in plaintextToken, once; any other caller receives lastFour and a one-time revealUrl and never the secret. A revoked key cannot be rotated (400 KEY_REVOKED).

Requires the api-keys:write scope — Create, rotate, and revoke API keys — these keep working even after you disconnect this app.

cookiebetter-auth.session_token<token>

BetterAuth session cookie. Used by the dashboard / browser clients. When present, the active project is taken from the x-project-id header.

id*string

Project id.

keyId*string

API key id.

Response Body

API key rotated. The new secret is in plaintextToken for a dashboard session, behind revealUrl for everyone else.

application/json
  1. response
success*true
Value intrue
data*
Example Request
curl -X POST 'https://api.sendly.now/api/projects/string/api-keys/string/rotate'
Example Response
{  "success": true,  "data": {    "lastFour": "string",    "plaintextToken": "string",    "revealUrl": "http://example.com",    "revealExpiresAt": "2019-08-24T14:15:22Z"  }}