# Revoke the old API key after a rotation, signed with the new key.
# Needs openssl, curl and OLYMPEX_API_KEY_ID, OLYMPEX_SECRET_KEY, OLYMPEX_PASSPHRASE.
OLD_API_KEY_ID='00000000-0000-4000-8000-000000000000' # the previousApiKeyId of the rotation
METHOD=POST
ENDPOINT="/accounts/me/keys/$OLD_API_KEY_ID/revoke"
QUERY=''
BODY='{"reason":"replaced after validation"}'
TS="${OLYMPEX_TIMESTAMP:-$(date +%s)}"
NONCE="${OLYMPEX_NONCE:-$(openssl rand -hex 12)}"
BODY_HASH="$(printf '%s' "$BODY" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-_' | tr -d '=')"
VALUE_INFO="$(printf '%s\n%s\n%s' "$TS" "$NONCE" "$BODY_HASH")"
MESSAGE="$(printf 'OLPX-HMAC-SHA256-V2\n%s\n%s\n%s\n%s\n%s\n%s' "$TS" "$NONCE" "$METHOD" "/api/v1$ENDPOINT" "$QUERY" "$BODY_HASH")"
curl -sS -X "$METHOD" "https://api-rest.olympex.io/api/v1$ENDPOINT${QUERY:+?$QUERY}" \
-H "content-type: application/json" \
-H "x-api-key-id: $OLYMPEX_API_KEY_ID" \
-H "x-value-info: $(printf '%s' "$VALUE_INFO" | openssl base64 -A)" \
-H "x-passphrase: $OLYMPEX_PASSPHRASE" \
-H "x-signature: $(printf '%s' "$MESSAGE" | openssl dgst -sha256 -hmac "$OLYMPEX_SECRET_KEY" -binary | od -An -v -tx1 | tr -d ' \n')" \
--data-raw "$BODY"
import { olympexRequest } from "./sign-request.ts"; // /authentication/sign-requests
type ApiKey = { apiKeyId: string; status: "active" | "rotating" | "expired" | "revoked" };
// Signed with the new key (OLYMPEX_* variables). Revoke every older key that can still sign.
const { keys } = await olympexRequest<{ keys: ApiKey[] }>("GET", "/accounts/me/keys");
for (const key of keys.filter((k) => k.status === "rotating")) {
await olympexRequest("POST", `/accounts/me/keys/${key.apiKeyId}/revoke`, { reason: "replaced after validation" });
console.log(`Revoked ${key.apiKeyId}`);
}
from sign_request import olympex_request # /authentication/sign-requests
# Signed with the new key (OLYMPEX_* variables). Revoke every older key that can still sign.
keys = olympex_request("GET", "/accounts/me/keys")["keys"]
for key in (k for k in keys if k["status"] == "rotating"):
olympex_request("POST", f"/accounts/me/keys/{key['apiKeyId']}/revoke", {"reason": "replaced after validation"})
print("Revoked", key["apiKeyId"])
{
"success": true,
"data": {
"apiKeyId": "00000000-0000-4000-8000-000000000000",
"status": "revoked"
},
"meta": {
"requestId": "GDxwVi9roAMEPRQ=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000001"
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Key not found",
"details": []
},
"meta": {
"requestId": "GDxwRi2ToAMEZFA=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000001"
}
}
{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many key administration requests",
"details": []
},
"meta": {
"requestId": "GQ1EYiEFIAMEZ8A=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000001"
}
}
{
"message": "Forbidden"
}
Revoke an API key
Disable one API key of your account at once, for example the old key after a rotation.
# Revoke the old API key after a rotation, signed with the new key.
# Needs openssl, curl and OLYMPEX_API_KEY_ID, OLYMPEX_SECRET_KEY, OLYMPEX_PASSPHRASE.
OLD_API_KEY_ID='00000000-0000-4000-8000-000000000000' # the previousApiKeyId of the rotation
METHOD=POST
ENDPOINT="/accounts/me/keys/$OLD_API_KEY_ID/revoke"
QUERY=''
BODY='{"reason":"replaced after validation"}'
TS="${OLYMPEX_TIMESTAMP:-$(date +%s)}"
NONCE="${OLYMPEX_NONCE:-$(openssl rand -hex 12)}"
BODY_HASH="$(printf '%s' "$BODY" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-_' | tr -d '=')"
VALUE_INFO="$(printf '%s\n%s\n%s' "$TS" "$NONCE" "$BODY_HASH")"
MESSAGE="$(printf 'OLPX-HMAC-SHA256-V2\n%s\n%s\n%s\n%s\n%s\n%s' "$TS" "$NONCE" "$METHOD" "/api/v1$ENDPOINT" "$QUERY" "$BODY_HASH")"
curl -sS -X "$METHOD" "https://api-rest.olympex.io/api/v1$ENDPOINT${QUERY:+?$QUERY}" \
-H "content-type: application/json" \
-H "x-api-key-id: $OLYMPEX_API_KEY_ID" \
-H "x-value-info: $(printf '%s' "$VALUE_INFO" | openssl base64 -A)" \
-H "x-passphrase: $OLYMPEX_PASSPHRASE" \
-H "x-signature: $(printf '%s' "$MESSAGE" | openssl dgst -sha256 -hmac "$OLYMPEX_SECRET_KEY" -binary | od -An -v -tx1 | tr -d ' \n')" \
--data-raw "$BODY"
import { olympexRequest } from "./sign-request.ts"; // /authentication/sign-requests
type ApiKey = { apiKeyId: string; status: "active" | "rotating" | "expired" | "revoked" };
// Signed with the new key (OLYMPEX_* variables). Revoke every older key that can still sign.
const { keys } = await olympexRequest<{ keys: ApiKey[] }>("GET", "/accounts/me/keys");
for (const key of keys.filter((k) => k.status === "rotating")) {
await olympexRequest("POST", `/accounts/me/keys/${key.apiKeyId}/revoke`, { reason: "replaced after validation" });
console.log(`Revoked ${key.apiKeyId}`);
}
from sign_request import olympex_request # /authentication/sign-requests
# Signed with the new key (OLYMPEX_* variables). Revoke every older key that can still sign.
keys = olympex_request("GET", "/accounts/me/keys")["keys"]
for key in (k for k in keys if k["status"] == "rotating"):
olympex_request("POST", f"/accounts/me/keys/{key['apiKeyId']}/revoke", {"reason": "replaced after validation"})
print("Revoked", key["apiKeyId"])
{
"success": true,
"data": {
"apiKeyId": "00000000-0000-4000-8000-000000000000",
"status": "revoked"
},
"meta": {
"requestId": "GDxwVi9roAMEPRQ=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000001"
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Key not found",
"details": []
},
"meta": {
"requestId": "GDxwRi2ToAMEZFA=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000001"
}
}
{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many key administration requests",
"details": []
},
"meta": {
"requestId": "GQ1EYiEFIAMEZ8A=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000001"
}
}
{
"message": "Forbidden"
}
POST /accounts/me/keys/{apiKeyId}/revoke disables one API key of your account. It takes effect at once: the next request signed with that key fails with 403. Use it to retire the old key after a rotation, as soon as your services use the new key. A revoked key can’t be restored.
The API console doesn’t call the key endpoints: run them from your server, where your credentials live.
Rules
- Same account only. Sign with any
activeorrotatingkey of the account, including the key you revoke. A key ID that belongs to another account, or to none, returns404 NOT_FOUNDwith the message"Key not found", so the API doesn’t reveal whether it exists elsewhere. - Keep one active key. You can’t revoke the account’s last
activekey: rotate it first, check the new key, then revoke the old one. The API refuses the call, and the key staysactive. List your keys before you revoke. - Calling it again is safe. Revoking a key that is already
revoked, or arotatingkey that has becomeexpired, returns200withstatusrevoked. - No undo. To get a working key back, rotate the
activekey or create a new account. - 10 per hour. An account can send 10 revocation requests per hour, repeats included, on every plan. Over that, the API answers
429RATE_LIMIT_EXCEEDEDand the key’s status doesn’t change: wait up to an hour. A503SERVICE_UNAVAILABLEmeans Olympex refused the call for now and changed nothing: retry it after a few seconds.
reason is optional and goes to Olympex’s audit record, up to 200 characters; a longer one returns 400 VALIDATION_ERROR with the message "Invalid revoke body". Never put a credential in it.
# Revoke the old API key after a rotation, signed with the new key.
# Needs openssl, curl and OLYMPEX_API_KEY_ID, OLYMPEX_SECRET_KEY, OLYMPEX_PASSPHRASE.
OLD_API_KEY_ID='00000000-0000-4000-8000-000000000000' # the previousApiKeyId of the rotation
METHOD=POST
ENDPOINT="/accounts/me/keys/$OLD_API_KEY_ID/revoke"
QUERY=''
BODY='{"reason":"replaced after validation"}'
TS="${OLYMPEX_TIMESTAMP:-$(date +%s)}"
NONCE="${OLYMPEX_NONCE:-$(openssl rand -hex 12)}"
BODY_HASH="$(printf '%s' "$BODY" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-_' | tr -d '=')"
VALUE_INFO="$(printf '%s\n%s\n%s' "$TS" "$NONCE" "$BODY_HASH")"
MESSAGE="$(printf 'OLPX-HMAC-SHA256-V2\n%s\n%s\n%s\n%s\n%s\n%s' "$TS" "$NONCE" "$METHOD" "/api/v1$ENDPOINT" "$QUERY" "$BODY_HASH")"
curl -sS -X "$METHOD" "https://api-rest.olympex.io/api/v1$ENDPOINT${QUERY:+?$QUERY}" \
-H "content-type: application/json" \
-H "x-api-key-id: $OLYMPEX_API_KEY_ID" \
-H "x-value-info: $(printf '%s' "$VALUE_INFO" | openssl base64 -A)" \
-H "x-passphrase: $OLYMPEX_PASSPHRASE" \
-H "x-signature: $(printf '%s' "$MESSAGE" | openssl dgst -sha256 -hmac "$OLYMPEX_SECRET_KEY" -binary | od -An -v -tx1 | tr -d ' \n')" \
--data-raw "$BODY"
import { olympexRequest } from "./sign-request.ts"; // /authentication/sign-requests
type ApiKey = { apiKeyId: string; status: "active" | "rotating" | "expired" | "revoked" };
// Signed with the new key (OLYMPEX_* variables). Revoke every older key that can still sign.
const { keys } = await olympexRequest<{ keys: ApiKey[] }>("GET", "/accounts/me/keys");
for (const key of keys.filter((k) => k.status === "rotating")) {
await olympexRequest("POST", `/accounts/me/keys/${key.apiKeyId}/revoke`, { reason: "replaced after validation" });
console.log(`Revoked ${key.apiKeyId}`);
}
from sign_request import olympex_request # /authentication/sign-requests
# Signed with the new key (OLYMPEX_* variables). Revoke every older key that can still sign.
keys = olympex_request("GET", "/accounts/me/keys")["keys"]
for key in (k for k in keys if k["status"] == "rotating"):
olympex_request("POST", f"/accounts/me/keys/{key['apiKeyId']}/revoke", {"reason": "replaced after validation"})
print("Revoked", key["apiKeyId"])
{
"success": true,
"data": {
"apiKeyId": "00000000-0000-4000-8000-000000000000",
"status": "revoked"
},
"meta": {
"requestId": "GDxwVi9roAMEPRQ=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000001"
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Key not found",
"details": []
},
"meta": {
"requestId": "GDxwRi2ToAMEZFA=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000001"
}
}
{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many key administration requests",
"details": []
},
"meta": {
"requestId": "GQ1EYiEFIAMEZ8A=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000001"
}
}
{
"message": "Forbidden"
}
Authorizations
Your API key ID (UUID). See Sign requests.
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.
Body
Was this page helpful?
