Skip to main content
POST
POST /accounts/me/keys/rotate creates a new API key for your account and retires the key that signs the request. Olympex generates the new API key ID and secret key and returns the secret key in this response. Your passphrase doesn’t change. In graceful mode, the default, the old key keeps working for a grace period, so you can deploy the new key without downtime. In compromised mode, Olympex revokes the old key at once. The API console doesn’t call the key endpoints: run them from your server, where your credentials live.

Choose the mode

gracePeriodSeconds goes from 60 to 604800 (7 days), and defaults to 86400 (24 hours). Choose a period longer than it takes you to deploy the new key everywhere, then revoke the old key as soon as your services use the new one. Only an active key can start a rotation. A rotating key that tries gets 404 NOT_FOUND with the message "Key not found". The new key can rotate again during the grace period, which leaves more than one rotating key: list your keys and revoke the ones you no longer use.

Retry with the same Idempotency-Key

The Idempotency-Key header identifies one rotation, not one attempt. Generate it once, for example as a UUID, and store it with the exact body before you send the first attempt. If an attempt times out or returns a 5xx, sign it again (with a new timestamp and nonce) and send it with the same Idempotency-Key, the same body and the same signing key. Olympex then returns the same new API key ID and secret key, and creates no other key.
  • The window is 15 minutes. A retry returns the secret key until secretRecoverableUntil. After that, no endpoint returns that secret key again, so store it as soon as you receive it.
  • Change nothing. The same Idempotency-Key with another body or another signing key returns 409 CONFLICT with the message "Idempotency key was reused with a different payload". Key order and whitespace don’t count: Olympex compares the canonical body.
  • A new rotation needs a new key. Never generate a new Idempotency-Key to retry an attempt whose outcome you don’t know: that starts a second rotation if the first one succeeded. On a 409, list your keys first.
  • A graceful retry also needs the old key. It must still be rotating, so the retry deadline is the earlier of secretRecoverableUntil and previousKeyExpiresAt.
  • Retries count toward the rate limit. An account can send 5 rotation requests per hour, retries with the same Idempotency-Key included, on every plan. Over that, the API answers 429 RATE_LIMIT_EXCEEDED and the request doesn’t run: wait up to an hour, then send it again with the same Idempotency-Key and body. Don’t retry a 429 sooner. A 503 SERVICE_UNAVAILABLE means Olympex refused the rotation for now and changed nothing: retry it after a few seconds.
A compromised rotation revokes the old key in the same call, so if you lose its response, you can’t retry it: the gateway rejects the old key with 403, and the account has no key you hold. Email partners@olympex.io with the API key IDs (never a secret key or the passphrase), and create a new account if you need to keep working.

Store the new key first

The response carries Cache-Control: no-store. Keep it out of caches, logs and error reports.
  1. Write apiKeyId and secretKey to your secrets manager before you report success. Keep the passphrase: it signs for the new key too.
  2. Confirm that the new key works, for example by calling GET /accounts/me/keys with it.
  3. Deploy the new key to every service that signs requests.
  4. Revoke the old key once nothing uses it, instead of waiting for previousKeyExpiresAt.

Authorizations

x-api-key-id
string
header
required

Your API key ID (UUID). See Sign requests.

x-value-info
string
header
required

Base64 of timestamp + "\n" + nonce + "\n" + bodyHash, where timestamp is Unix seconds, nonce is 24 new hexadecimal characters and bodyHash is the unpadded base64url SHA-256 of the canonical body.

x-passphrase
string
header
required

Your account passphrase. Treat it like the secret key.

x-signature
string
header
required

Lowercase hex HMAC-SHA256 (signature v2), keyed with your secret key string (UTF-8, not decoded), of seven lines joined with \n, with no trailing newline: OLPX-HMAC-SHA256-V2, timestamp, nonce, the uppercase method, path, canonicalQuery and bodyHash. path is the request path including /api/v1, without the query string, for example /api/v1/limit-order/<id>. canonicalQuery is the query parameters decoded (+ is a space), sorted by key and then by value, re-encoded per RFC 3986 and joined with &, or the empty string when there is no query. Headers signed for one request are rejected on any other. See Sign requests.

Headers

Idempotency-Key
string
required

Identifies one rotation, not one attempt. Generate a new UUID for each rotation, store it with the body before you send the request, and send the same value on every retry of that rotation. Up to 200 characters, not empty. It isn't part of the signature.

Maximum string length: 200

Body

application/json
mode
enum<string>
default:graceful

graceful keeps the old key valid for gracePeriodSeconds. compromised revokes it at once: use it only when the old secret key or passphrase may be exposed.

Available options:
graceful,
compromised
gracePeriodSeconds
integer
default:86400

How long the old key keeps signing after a graceful rotation, in seconds: from 60 to 604800 (7 days). The default is 86400 (24 hours).

Required range: 60 <= x <= 604800
reason
string

Why you rotate, for Olympex's audit record. Up to 200 characters. Never put a credential in it.

Maximum string length: 200

Response

The new API key. Store secretKey before you do anything else. The response carries Cache-Control: no-store: don't cache or log it.

success
enum<boolean>
required
Available options:
true
data
object
required
meta
object
required