> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.immix.xyz/api-reference/rest-api/credentials/rotate/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.immix.xyz/_mcp/server. # Rotate a credential's key POST /credentials/{id}/rotate Content-Type: application/json Proposes new key material for the credential (`credentials:propose`): the body carries the material once, the gateway stores it and derives the new fingerprint, and a second user's `/approve` cuts the connectors over to it. The intake's refusals are the create's — [the guide](https://docs.immix.xyz/guides/rest-api-guide#writes). Reference: https://docs.immix.xyz/api-reference/rest-api/credentials/rotate ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Path parameters - `id` (integer, required) — The record's id — a positive 32-bit integer the platform minted. ### Headers - `Idempotency-Key` (string, required) — Required on every write: a URL-safe string of 1 to 64 characters from `[A-Za-z0-9._~-]` (a UUID fits), scoped to you. It names one operation on one record, ever: a retry replays the stored outcome (`Idempotent-Replay: true`) or attaches to the live one, and reuse on another record refuses 409 `IDEMPOTENCY_KEY_REUSED`. Missing or malformed, 400. - `If-Match` (string, optional) — The `ETag` the read minted, quoted or bare; absent or `*` is unconditional; a weak validator refuses 400 `INVALID_IF_MATCH`. A stale value answers 412 `VERSION_CONFLICT` with `currentVersion` and a fresh `ETag`: re-read, reapply, retry. Send it — every write restates the whole record, so an unconditional write overwrites every field from your copy, and an amend against a pending proposal replaces that proposal. ### Body (application/json) This endpoint expects an object. - `material` (CredentialMaterial, required) — The venue key's material, sent once over TLS and never served back: the gateway stores it write-only, mints the row's `secretRef`, fingerprints it (`fp-` and 16 hex characters of SHA-256) and fills `venueKeyId` from the public key leg; the row answers with those references only. Every leg is a non-blank string and the venue decides which legs exist — `x-immix-intake-venues` lists the venues served, each with its legs, its key-id leg and the connectors that serve it. - `credentialId` (integer, optional) - `expectedVersion` (string, optional, nullable) — int64 as a decimal JSON string - `keyCreatedAtNs` (string, optional, nullable) — int64 as a decimal JSON string - `rotateByNs` (string, optional, nullable) — int64 as a decimal JSON string ## Response ### 200 The credential as the platform now holds it after the write — the same row the read serves, with the answering change's position, the row's `ETag` and, on a replayed key, `Idempotent-Replay`. - `credentialId` (integer, required) — Sticky entity key. - `globalSequence` (string, required) — The position as a decimal string — the last change this member had applied, orders and balance readings included. - `keyFingerprint` (string, required) — The credential's fingerprint as the intake computed it — fp- and the first 16 hex characters of SHA-256 over the canonical payload — the pin a connector adopts the material at: enough to prove a cutover, never enough to sign. Empty on a row seeded before the intake. - `name` (string, required) — Natural key — per-org unique among live credentials. - `orgId` (integer, required) — Owner-stamped. - `pendingTransition` (enum, required) — ACTIVATE, AMEND (capabilities/secretRef), REACTIVATE, REVOKE or ROTATE; NONE otherwise. NONE is the unset sentinel: outputs only — as input, omit the field instead; explicit NONE refuses 400. The value set is append-only: a consumer READING this field treats an unknown name as NONE, never as an error; as input an unknown name refuses 400 — the parse is strict - Allowed values: `NONE`, `ACTIVATE`, `AMEND`, `REACTIVATE`, `UNFREEZE`, `RETIRE`, `REVOKE`, `ROTATE`, `RESUME_TRADING` - `providerKind` (enum, required) — UNKNOWN is the unset sentinel: outputs only — as input, omit the field instead; explicit UNKNOWN refuses 400. The value set is append-only: a consumer READING this field treats an unknown name as UNKNOWN, never as an error; as input an unknown name refuses 400 — the parse is strict - Allowed values: `UNKNOWN`, `EXCHANGE`, `CUSTODIAN`, `WALLET_PROVIDER`, `CHAIN_RPC`, `BANK` - `secretRef` (string, required) — LOGICAL credential name (okx-account-prod) — never a store path or provider URI; resolution happens only at the owning connector's edge. - `status` (enum, required) — UNKNOWN is the unset sentinel: outputs only — as input, omit the field instead; explicit UNKNOWN refuses 400. The value set is append-only: a consumer READING this field treats an unknown name as UNKNOWN, never as an error; as input an unknown name refuses 400 — the parse is strict - Allowed values: `UNKNOWN`, `DRAFT`, `PENDING_APPROVAL`, `ACTIVE`, `SUSPENDED`, `REVOKED` - `venueKeyId` (string, required) — The venue's identifier for the key — metadata, not material. - `version` (string, required) — Monotonic per entity. int64 as a decimal JSON string - `allowlistDetail` (string, optional) — The venue's own allowlist, verbatim (IP addresses are not secrets); empty when none or no probe answered. - `appGroup` (string, optional) — The connector app group serving this credential (desk 5-as-amended, okx-oe D-E17): the assignment rides the row — one group per credential by construction, empty = unassigned (no connector serves it; fail-safe). Replaces the compile-time CredentialAssignments table. - `canExecuteTransfers` (boolean, optional) — Whether the key may execute transfers. a boolean; absent reads false - `canReadBalances` (boolean, optional) — Whether the key may read balances. a boolean; absent reads false - `canServeAddresses` (boolean, optional) — Whether the key may serve deposit addresses. a boolean; absent reads false - `canTrade` (boolean, optional) — Capability boolean: an order routes through its account's trading pipe — the account's designated tradingCredentialId, else its own credential — which must be ACTIVE and carry canTrade. Any number of trading credentials may share one (org × venue) — one venue key per sub-account. a boolean; absent reads false - `exchangeId` (integer, optional, nullable) — The refdata exchange for an EXCHANGE-kind credential — carried, not resolved here; a credential that can trade must name one (MISSING_VENUE); 0 = no venue. - `keyCreatedAtNs` (string, optional, nullable) — Key metadata: when the venue key was minted; 0 = not stated. int64 as a decimal JSON string - `observedAllowlist` (enum, optional) — The probe's allowlist verdict against the cluster's egress set; UNKNOWN until a probe answers. UNKNOWN is the unset sentinel: outputs only — as input, omit the field instead; explicit UNKNOWN refuses 400. The value set is append-only: a consumer READING this field treats an unknown name as UNKNOWN, never as an error; as input an unknown name refuses 400 — the parse is strict - Allowed values: `UNKNOWN`, `NONE`, `COVERS`, `MISSES` - `observedKeyCreatedAtNs` (string, optional, nullable) — The key creation time the venue stated to the probe; 0 = the venue states none, or never probed. int64 as a decimal JSON string - `observedKeyFingerprint` (string, optional) — The fingerprint of the material the probe adopted — compare with keyFingerprint, the intake's pin; empty until a probe answers. - `observedKeyId` (string, optional) — The venue-facing key identifier the probing connector resolved (the public half, never the secret); empty until a probe answers. - `observedPermissions` (list of enum, optional) — The observed axis: the key scopes the venue stated to the probing connector, parsed by name; empty until a probe answers. a set (SBE bit-set) served as the array of its set choice names in declared order; empty = none set, never null. The choice set is append-only: a consumer READING this field skips an unknown name, never errors; as input an unknown or repeated name refuses 400 — the parse is strict - Allowed values: `read`, `trade`, `withdraw` - `pendingByUserId` (integer, optional, nullable) — The user whose proposal is pending, so an approver is checked to be someone else; 0 when nothing is pending. - `permissionDetail` (string, optional) — The venue's own permission string, verbatim (not a secret); empty until a probe answers. - `probeDetail` (string, optional) — Redacted diagnostic text for a non-NONE probe outcome; empty-not-null. - `probeOutcome` (enum, optional) — UNKNOWN = never probed; NONE = the venue's key-restrictions read answered; else the probe's own failure in the credential or gate band. UNKNOWN is the unset sentinel: outputs only — as input, omit the field instead; explicit UNKNOWN refuses 400. The value set is append-only: a consumer READING this field treats an unknown name as UNKNOWN, never as an error; as input an unknown name refuses 400 — the parse is strict - Allowed values: `UNKNOWN`, `NONE`, `AUTH_FAILED`, `IP_NOT_WHITELISTED`, `PERMISSION_DENIED`, `RATE_LIMITED`, `VENUE_UNREACHABLE`, `STARTUP`, `RECONNECT`, `HEARTBEAT_TIMEOUT`, `VENUE_MAINTENANCE`, `BACKPRESSURE`, `RESYNC`, `SHUTDOWN`, `FAILOVER`, `LAGGING`, `RECOVERED`, `INVALID_KEY`, `CLOCK_SKEW`, `CONFIG_ERROR`, `STREAM_STALE`, `VENUE_UNAVAILABLE` - `probedAtNs` (string, optional, nullable) — Consensus time of the probe report this row records — owner-stamped; 0 = never probed. int64 as a decimal JSON string - `rotateByNs` (string, optional, nullable) — Governance deadline for rotation; a breach is an ops alert; 0 = none. int64 as a decimal JSON string - `venueAccountRef` (string, optional) — The venue's account identifier behind the key (OKX uid); empty when the venue states none or no probe answered. - `unscaled` (boolean, optional, deprecated) — Never present since 0.3.3: every money value on this API states its own scale on the wire — a policy amount or cap since 0.3.3, an order's and an execution's since 0.3.2, a balance's since 0.3.1 — so a row is never served raw, whether or not this member holds the asset or instrument it references. Kept, deprecated, so a client generated from 0.3.2 still compiles; it goes at the next major. ## Errors ### 400 Rotate Credentials Request Bad Request Error Refused at the door — nothing reached the platform and the key was not journaled: a missing or malformed `Idempotency-Key` or `If-Match`, malformed JSON, a body `userId`, a body restating the path or `If-Match` differently, a money string off its `pattern` (an exponent, a plus sign, a bare point, surrounding whitespace) or past its `maxLength`, or one no value here can state (over 18 fractional digits, or past a 64-bit integer at its own scale), or any other value outside the schema. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 401 Rotate Credentials Request Unauthorized Error No bearer token, or one that does not verify. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 403 Rotate Credentials Request Forbidden Error Authenticated, but not admitted. `FORBIDDEN_PRINCIPAL`: a token with no `org_id`, a non-ASCII `org_id` or `sub`, a disabled user, or a local binding with no user. `AWAITING_ADMISSION`: your user is not yet admitted — every route but `GET /me` answers this until an administrator admits you. `ORG_NOT_ACTIVE`: your organisation is suspended, pending activation, retired or unregistered. The record owners' 403s (`CAPABILITY_DENIED`, `SELF_APPROVAL`, `NOT_PROPOSER`, …) are refusals on the platform's stream: they carry the position header, and a retried key replays them with `Idempotent-Replay`. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 404 Rotate Credentials Request Not Found Error No such row in your organisation — another organisation's row is indistinguishable from an absent one. The position header says as of when. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 409 Rotate Credentials Request Conflict Error The record owner's refusal, by class: 409 for a state or uniqueness refusal, 422 for a field or reference refusal — a fact on the platform's stream, so it carries the position header and a retried key replays it. The same statuses also carry two door refusals that are never journaled: 409 `IDEMPOTENCY_KEY_REUSED` and, on `POST /orders`, 422 `INSTRUMENT_NOT_LIVE` for a symbol this member holds no instrument under and 422 `ACCOUNT_NOT_ACTIVE` for a display name no live account of your org holds (the owner answers both codes, as facts, to an id it will not trade) — a retry takes fresh. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 412 Rotate Credentials Request Precondition Failed Error `If-Match` is stale (`VERSION_CONFLICT`): the envelope carries `currentVersion` and the `ETag` header the current row — re-read, reapply, retry. A retried key replays it with `Idempotent-Replay`. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 413 Rotate Credentials Request Content Too Large Error The platform refused the command's size (`TOO_LARGE`); nothing was submitted, a retry takes fresh. Not expected for any route here. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 422 Rotate Credentials Request Unprocessable Entity Error The record owner's refusal, by class: 409 for a state or uniqueness refusal, 422 for a field or reference refusal — a fact on the platform's stream, so it carries the position header and a retried key replays it. The same statuses also carry two door refusals that are never journaled: 409 `IDEMPOTENCY_KEY_REUSED` and, on `POST /orders`, 422 `INSTRUMENT_NOT_LIVE` for a symbol this member holds no instrument under and 422 `ACCOUNT_NOT_ACTIVE` for a display name no live account of your org holds (the owner answers both codes, as facts, to an id it will not trade) — a retry takes fresh. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 429 Rotate Credentials Request Too Many Requests Error Shed at once: `INBOX_FULL` or `IN_FLIGHT_FULL` (this member's bounds; nothing queued, the key not journaled), the intake's `RATE_LIMITED`, or the orders owner's `RATE_CEILING` (the organisation's per-minute ceiling — a refusal on the stream, replayed like any). `Retry-After` says when. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 500 Rotate Credentials Request Internal Server Error The gateway failed to serve (`INTERRUPTED`, `INTERNAL_ERROR`, `PROJECTION_MISS`); the operation record, if one exists, is still readable. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ### 503 Rotate Credentials Request Service Unavailable Error This member cannot carry the write now: `NOT_PRIMED` (still catching up), `NOT_SERVING` (a read-only or not-ready member), `OWNER_ABSENT` (the record owner has no active member), `INTAKE_UNAVAILABLE` (no credential store here), or the platform's own outcome for a command lost in transit. Nothing was journaled; retry against a serving member. - `error` (ErrorError, required) - `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry. ## Types ### CredentialMaterial The venue key's material, sent once over TLS and never served back: the gateway stores it write-only, mints the row's `secretRef`, fingerprints it (`fp-` and 16 hex characters of SHA-256) and fills `venueKeyId` from the public key leg; the row answers with those references only. Every leg is a non-blank string and the venue decides which legs exist — `x-immix-intake-venues` lists the venues served, each with its legs, its key-id leg and the connectors that serve it. - `key` (string, required) — The API key id — the venue's public leg; becomes the row's `venueKeyId`. - `secret` (string, required) — The signing secret. - `passphrase` (string, required) — The passphrase chosen when the key was created. ### ErrorError - `code` (string, required) — The code to branch on — stable and append-only: treat one you do not know by its HTTP status. The gateway's own: - 400: `MALFORMED_REQUEST`, `MISSING_IDEMPOTENCY_KEY`, `INVALID_IDEMPOTENCY_KEY`, `INVALID_IF_MATCH` - 401: `UNAUTHENTICATED` - 403: `FORBIDDEN_PRINCIPAL`, `AWAITING_ADMISSION`, `ORG_NOT_ACTIVE`, `CAPABILITY_DENIED` (the credential intake) - 404: `NOT_FOUND`, `UNKNOWN_OPERATION` - 409: `IDEMPOTENCY_KEY_REUSED`, `INTAKE_KEY_REUSED` - 413: `TOO_LARGE`, `PAYLOAD_TOO_LARGE` - 422: `INSTRUMENT_NOT_LIVE` and `ACCOUNT_NOT_ACTIVE` (`POST /orders`: a symbol or an account name nothing here holds — the orders owner answers the same codes to an unheld id), `VENUE_UNSUPPORTED`; `SCALE_UNKNOWN` (retired: only a member below `0.3.4` answers it) - 429: `INBOX_FULL`, `IN_FLIGHT_FULL`, `RATE_LIMITED` - 500: `INTERRUPTED`, `INTERNAL_ERROR`, `PROJECTION_MISS` - 503: `NOT_PRIMED`, `NOT_SERVING`, `OWNER_ABSENT`, `INTAKE_UNAVAILABLE`, `BALANCES_UNAVAILABLE`, `LOST`, `REJECTED_NOT_REGISTERED`, `REJECTED_NOT_ACTIVE` The record owners' refusals ride verbatim — `OrgRegisterRejected.reason` and `OrderRejected.reason` list them, and the guide's Errors section maps each to its status. - `message` (string, optional) — Free text for humans; may change without notice — never parse it. ## Examples **Request** ```json { "material": { "key": "key", "secret": "secret", "passphrase": "passphrase" } } ``` **Response** ```json { "credentialId": 1, "globalSequence": "globalSequence", "keyFingerprint": "keyFingerprint", "name": "name", "orgId": 1, "pendingTransition": "NONE", "providerKind": "UNKNOWN", "secretRef": "secretRef", "status": "UNKNOWN", "venueKeyId": "venueKeyId", "version": "version", "allowlistDetail": "allowlistDetail", "appGroup": "appGroup", "canExecuteTransfers": true, "canReadBalances": true, "canServeAddresses": true, "canTrade": true, "exchangeId": 1, "keyCreatedAtNs": "keyCreatedAtNs", "observedAllowlist": "UNKNOWN", "observedKeyCreatedAtNs": "observedKeyCreatedAtNs", "observedKeyFingerprint": "observedKeyFingerprint", "observedKeyId": "observedKeyId", "observedPermissions": [ "read" ], "pendingByUserId": 1, "permissionDetail": "permissionDetail", "probeDetail": "probeDetail", "probeOutcome": "UNKNOWN", "probedAtNs": "probedAtNs", "rotateByNs": "rotateByNs", "venueAccountRef": "venueAccountRef" } ``` **SDK Code** ```python import requests url = "https://api.example.com/credentials/1/rotate" payload = { "material": { "key": "key", "secret": "secret", "passphrase": "passphrase" } } headers = { "Idempotency-Key": "Idempotency-Key", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.example.com/credentials/1/rotate'; const options = { method: 'POST', headers: { 'Idempotency-Key': 'Idempotency-Key', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"material":{"key":"key","secret":"secret","passphrase":"passphrase"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.example.com/credentials/1/rotate" payload := strings.NewReader("{\n \"material\": {\n \"key\": \"key\",\n \"secret\": \"secret\",\n \"passphrase\": \"passphrase\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "Idempotency-Key") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.example.com/credentials/1/rotate") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = 'Idempotency-Key' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"material\": {\n \"key\": \"key\",\n \"secret\": \"secret\",\n \"passphrase\": \"passphrase\"\n }\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/credentials/1/rotate") .header("Idempotency-Key", "Idempotency-Key") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"material\": {\n \"key\": \"key\",\n \"secret\": \"secret\",\n \"passphrase\": \"passphrase\"\n }\n}") .asString(); ``` ```php request('POST', 'https://api.example.com/credentials/1/rotate', [ 'body' => '{ "material": { "key": "key", "secret": "secret", "passphrase": "passphrase" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => 'Idempotency-Key', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.example.com/credentials/1/rotate"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "Idempotency-Key"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"material\": {\n \"key\": \"key\",\n \"secret\": \"secret\",\n \"passphrase\": \"passphrase\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Idempotency-Key": "Idempotency-Key", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["material": [ "key": "key", "secret": "secret", "passphrase": "passphrase" ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/credentials/1/rotate")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```