Skip to main content
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"
}

Authorizations

x-portkey-api-key
string
header
required

Path Parameters

id
string<uuid>
required

Body

application/json
key_transition_period_ms
integer

Optional transition period in milliseconds during which the previous key remains valid.

Required range: x >= 1800000
Example:

3600000

Response

200 - application/json

OK

id
string<uuid>
Example:

"550e8400-e29b-41d4-a716-446655440000"

key
string

Newly rotated API key value.

Example:

"pk_live_new_rotated_key_value"

key_transition_expires_at
string<date-time>

Timestamp when the previous key version stops being accepted.

Example:

"2026-01-15T10:30:00.000Z"

Last modified on April 7, 2026