import requests
response = requests.post(
"https://api.portkey.ai/v1/api-keys/API_KEY_ID/rotate",
headers={
"x-portkey-api-key": "PORTKEY_API_KEY",
"Content-Type": "application/json",
},
json={
"key_transition_period_ms": 3600000
}
)
print(response.json()){
"id": "550e8400-e29b-41d4-a716-446655440000",
"key": "pk_live_new_rotated_key_value",
"key_transition_expires_at": "2026-01-15T10:30:00.000Z"
}Rotate API Key
Rotates an existing API key and returns a newly generated key value.
The previous key remains valid during the transition period and expires at key_transition_expires_at.
POST
/
api-keys
/
{id}
/
rotate
import requests
response = requests.post(
"https://api.portkey.ai/v1/api-keys/API_KEY_ID/rotate",
headers={
"x-portkey-api-key": "PORTKEY_API_KEY",
"Content-Type": "application/json",
},
json={
"key_transition_period_ms": 3600000
}
)
print(response.json()){
"id": "550e8400-e29b-41d4-a716-446655440000",
"key": "pk_live_new_rotated_key_value",
"key_transition_expires_at": "2026-01-15T10:30:00.000Z"
}Documentation Index
Fetch the complete documentation index at: https://portkey-docs-feat-byteplus-provider.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Authorizations
Path Parameters
Body
application/json
Optional transition period in milliseconds during which the previous key remains valid.
Required range:
x >= 1800000Example:
3600000
Response
200 - application/json
OK
Last modified on May 24, 2026
Was this page helpful?
⌘I

