Rotate a publishable key
Mints a replacement carrying the same name, origins, rate limit and quota as the key you named. Needs settings: write, and is a write.
The old key keeps working. That is the whole point of rotating rather than revoking: a publishable key lives in deployed HTML, so the order has to be mint, deploy, then revoke. Two live keys in between is the normal case rather than a violation, and last_used_at on each is how you tell when the old one has stopped being called.
Revoke a publishable key is the third step, and nothing here does it for you: Commune cannot know when your pages have gone out.
Rotating a revoked key is allowed and is the ordinary way to replace one you have lost: it copies the settings and mints a new secret, and the revoked key stays revoked.
As with minting, the secret is in this response and nowhere else.
Publishes no event.
Request
- Base URL: https://api.usecommune.com
- URL: https://api.usecommune.com/publishable-keys/{publishable_key}/rotate
- Auth: one of:
- HTTP bearer
- OAuth 2 (authorization code, authorization URL https://usecommune.com/api/oauth/authorize, token URL https://usecommune.com/api/oauth/token, scopes: settings:write)
Headers
A value of your choosing naming the change this request is making.
Send the same value again to retry the same request. Commune replays the answer the first attempt gave instead of making the change twice, and marks the replay with an Idempotent-Replay: true response header. Send a different value for a different change: a key reused for a request that differs in any way answers 409, because replaying an answer to a question you did not ask is a wrong answer you could not detect.
A UUID per change is the usual choice. Remembered for 24 hours, per credential, so two credentials choosing the same value never see each other's answers.
Required, not optional.
Response
The new key, with its secret. The key you named is untouched and still live.
Example response
{
"newsletter": {
"object": "newsletter",
"id": "9a4c1c6e-0f2b-4f47-9d3f-6d1b1a2c3d4e"
},
"key_prefix": "cmn_pk_7Qa2Lk9x",
"allowed_origins": [
"http://localhost:5173"
]
}Changes
No recorded changes to this operation across all 1 revision of this API.