Rename an environment variable
rename_secret
Renames one environment variable on a site and keeps its value, without reading the value.
The new name follows the same rules as set_secret and must not already belong to another variable or be a reserved name. Locked variables cannot be renamed, and an encrypted variable cannot take a NEXT_PUBLIC_ name here, because that name puts its value in the browser code. Rename that one in the Secrets tab instead, where its value is shown.
The site's code keeps reading the old name until it is changed too, so every place that reads it needs updating. The running preview gets the new name straight away, and the published site gets it on the next publish. See Secrets.
Request
Call it with a POST to https://api.modulify.ai/v1/rename_secret, sending the inputs below as a JSON object. The token needs the config:write scope.
It makes changes, so send an Idempotency-Key header whenever you might retry it. A retry with the same key gets the first answer back instead of running again.
curl -X POST https://api.modulify.ai/v1/rename_secret \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"projectId":"PROJECT_ID","secretId":"SECRET_ID","key":"KEY"}'Over MCP, the same method is the rename_secret tool.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
projectId |
string | Yes | The site id. |
secretId |
string | Yes | The variable id from list_secrets. |
key |
string | Yes | The new name. Use letters, digits and underscores only, starting with a letter or an underscore. |
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.