Rotate the AI key of a site
rotate_site_ai_key
Replaces the AI key of a site with a new one, so the old key stops working within a minute, everywhere.
A running preview gets the new key right away, but a published site keeps the old one until it is published again, so its AI answers 401 until then, and the tool tells the client to remind you to publish right after. needsPublish in the answer is true while the site is published, and the message then says to publish. Anything outside Modulify that used the old key breaks until the new one is pasted in.
The new key is not returned: the answer carries url, keyChangedAt and needsPublish, and get_site_ai_key reads the key. The tool tells the client to rotate only when a key has leaked or you ask, never as routine maintenance. It needs the Delete projects permission, like the rotate button beside the AI key. See Rotate the key.
Request
Call it with a POST to https://api.modulify.ai/v1/rotate_site_ai_key, sending the inputs below as a JSON object. The token needs the config:write scope.
This method is marked destructive: it deletes or overwrites data. Check the inputs before you call it, and send an Idempotency-Key header whenever you might retry it.
curl -X POST https://api.modulify.ai/v1/rotate_site_ai_key \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"projectId":"PROJECT_ID"}'Over MCP, the same method is the rotate_site_ai_key tool.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
projectId |
string | Yes | The site id. |
Response
Every call answers with the JSON envelope of success, message, data, code and version. data holds the result described above, and on a method that returns a total, count carries it. The response headers carry the call's X-Request-Id and what is left of your per-minute budget in X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. Errors explains every status code a call can answer with.