Rotate a secret
Endpoint: POST /v1/vaults/{vault_id}/secret-rotate/{path}
Authentication: Bearer JWT
You can rotate in two ways:
- Server-generated value —
POST /v1/vaults/{vault_id}/secret-rotate/{path}with optional{ "length": 32, "charset": "hex", "type": "api_key" }. Requiresrotateorwritepermission. - Client-supplied value — PUT to the same path with a new value (see Create / Update). Creates a new version while preserving history.
Server-side generation
- curl
- TypeScript
- Python
- CLI
curl -X POST "https://api.1claw.xyz/v1/vaults/$VAULT_ID/secret-rotate/api-keys/openai" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"length": 32, "charset": "alphanumeric", "type": "api_key"}'
const { data } = await client.secrets.rotateGenerate(vaultId, "api-keys/openai", {
length: 32,
charset: "alphanumeric",
type: "api_key",
});
console.log(data.version);
from oneclaw import create_client
client = create_client(api_key="1ck_...")
resp = client.secrets.rotate_generate(
vault_id,
"api-keys/openai",
length=32,
charset="alphanumeric",
type="api_key",
)
print(resp.data["version"])
1claw secret rotate api-keys/openai --generate -v $VAULT_ID -l 32 -c alphanumeric
Manual rotation (new version via PUT)
- curl
- TypeScript
- Python
curl -X PUT "https://api.1claw.xyz/v1/vaults/$VAULT_ID/secrets/api-keys/openai" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"type":"api_key","value":"sk-proj-NEW..."}'
await client.secrets.set(vaultId, "api-keys/openai", "sk-proj-NEW...", {
type: "api_key",
});
client.secrets.set(vault_id, "api-keys/openai", "sk-proj-NEW...", type="api_key")
After rotation, optionally disable older versions with POST /v1/vaults/{vault_id}/secret-version-disable/{path}/{version}.