Skip to main content

Rotate a Secret

Rotates a secret by marking the existing secret as ROTATED and generating a new active secret in its place. The old secret immediately becomes invalid.
POST /v1/recipients/:recipientId/secrets/:secretId/rotate

Path Parameters

ParameterTypeDescription
recipientIdstringThe recipient ID
secretIdstringThe secret ID to rotate

Example Request

curl -X POST https://api.docyard.io/v1/recipients/rcp_01HQ3N.../secrets/sec_01HQ5A.../rotate \
  -H "Authorization: Bearer dk_live_a1b2c3d4..."

Response

{
  "id": "sec_01HQ5D...",
  "secret": "dys_x9y8z7w6v5u4t3s2r1q0p9o8n7m6l5k4"
}

Error Handling

StatusCondition
401Missing or invalid API key
404Recipient or secret not found
409Secret has already been rotated or revoked
The new secret value is shown only once in this response. The old secret is immediately marked as ROTATED and can no longer be used for verification. Update your systems with the new secret before discarding this response.