Endpoint
Roll an API key
/v1/keys/{id}/rollCreates a replacement key with the same name, type, scopes and IP list, and returns it with its secret. The old key keeps working for expires_in seconds with status: "rolling", then is revoked. In live mode a key cannot do this: it answers passkey_approval_required with reason live_key_dashboard_only, and a live key is made and rolled in the dashboard with a passkey. A key that is limited to IP addresses or has an expires_at makes and rolls only keys inside its own list and ending no later (parameter_invalid, reason wider_than_caller); with neither given, the new key takes its maker's. A replay of the same request (Idempotent-Replayed: true) answers the key without secret, which is never kept.
- Scope a restricted key needs
keys:write- Publishable key
- Not allowed: secret or restricted key only
- Idempotency-Key
- Recommended. It makes a retry safe.
Parameters
| Parameter | Type and place | Meaning |
|---|---|---|
idrequired | stringpath | The id of the key. |
Orrerie-Version | stringheader | API version date. Default: the version the key was created with. Example 2026-10-11. |
Idempotency-Key | stringheader | Makes a retry safe. Kept 24 hours. 1 to 255 characters. |
Request body
A JSON object. The body may be left out. A field the call does not list is refused with parameter_unknown.
| Field | Type | Meaning |
|---|---|---|
expires_in | integer | 0 to 604,800 (7 days). Default 86,400. |
Example request
curl
curl https://api.orrerie.com/v1/keys/key_6e3gg2c6ea176xxdek2nar6v/roll \
-H "Authorization: Bearer $ORRERIE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"expires_in": 86400
}'JavaScript
const response = await fetch("https://api.orrerie.com/v1/keys/key_6e3gg2c6ea176xxdek2nar6v/roll", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ORRERIE_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"expires_in": 86400
}),
});
const result = await response.json();
if (!response.ok) throw new Error(`${result.error.code}: ${result.error.message}`);
console.log(result);Python
import os
import requests
response = requests.post(
"https://api.orrerie.com/v1/keys/key_6e3gg2c6ea176xxdek2nar6v/roll",
headers={"Authorization": f"Bearer {os.environ['ORRERIE_SECRET_KEY']}"},
json={
"expires_in": 86400,
},
timeout=30,
)
result = response.json()
if not response.ok:
raise RuntimeError(f"{result['error']['code']}: {result['error']['message']}")
print(result)PHP
<?php
$request = curl_init('https://api.orrerie.com/v1/keys/key_6e3gg2c6ea176xxdek2nar6v/roll');
curl_setopt_array($request, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ORRERIE_SECRET_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'expires_in' => 86400,
]),
]);
$body = curl_exec($request);
if ($body === false) {
throw new RuntimeException(curl_error($request));
}
$result = json_decode($body, true);
if (curl_getinfo($request, CURLINFO_HTTP_CODE) >= 400) {
throw new RuntimeException($result['error']['code'] . ': ' . $result['error']['message']);
}
print_r($result);Responses
201 Created
The answer is the api_key object. Headers: Orrerie-Request-Id.
Example response, 201
{
"id": "key_7q9wzhxat737dwk7yzgdf5m8",
"object": "api_key",
"livemode": true,
"created": "2026-10-12T12:00:00.000Z",
"name": "Shop backend",
"type": "restricted",
"prefix": "sk_live_",
"last4": "m4Zr",
"scopes": [
"checkout_sessions:write",
"orders:read",
"refunds:write",
"events:read"
],
"allowed_ips": [],
"status": "active",
"api_version": "2026-10-11",
"created_by": {
"type": "member",
"id": "mem_ceh1wpzdrpk13cnpcjy9w0fa"
},
"last_used_at": null,
"expires_at": null,
"rolled_from": "key_6e3gg2c6ea176xxdek2nar6v",
"secret": "sk_live_EXAMPLE2EXAMPLE2EXAMPLE2EXAMPLE2EXAMPLE2m4Zr"
}Any other status: an error
A status of 400 or above answers with the error object. Branch on its code, never on its message.
Errors
Beside the errors every call can answer with (a bad key, a missing scope, the rate limit), this call answers with:
| Code | HTTP | Meaning |
|---|---|---|
passkey_approval_required | 403 | The action can only be done by a signed-in member in the dashboard (settlement asset, key-holding roles, approvals). No API key can do it. |