REST API guide
The REST API’s rules in full: authentication and admission, reads and writes, maker-checker, money, errors, orders, balances, algos
The consumer’s reference for the Immix API — the REST API an organisation uses for its users,
venue accounts with the keys beneath them, the balances those accounts hold at their venues, addresses,
portfolios and policies, the orders it places and the positions its fills build, and the algo
instances it runs. The organisation lifecycle — registering, activating, disabling and
deleting organisations — is the platform’s own, on the
internal platform API, served on a second port with no
public host.
The contract itself is the OpenAPI document the gateway serves at /openapi.json (rendered
by Swagger UI at /docs); this guide is the long form of the rules that document’s first
screen states in eight lines, and the changelog records every
change to either. Read GET /me first: it tells you who the platform holds you to be and what
you may do.
Contents: Authentication and admission · Capabilities · From a browser · Principals · Reads · Writes · Venue key specs · Maker-checker · Money · Ids, sentinels, enums and sets · Errors · Orders · Balances · Positions · Risk · Algos · Versioning
Authentication and admission
Every request carries a bearer (Authorization: Bearer …) of one of two kinds. A JWT
from the deployment’s identity provider, verified against its key set with the audience and
issuer pinned: its org_id claim names your organisation and its sub names you — a person,
a member of the organisation. Or an API key (since 0.68.0): immix_<keyId>_<secret>,
the bearer POST /api-keys served once when the key was issued — the platform holds the
secret’s digest alone and compares it at admission, so a key authenticates exactly while its
row is ACTIVE (API keys). Either admits a principal — the member or the key,
the actor every write is stamped with and every row names (Principals); a
key never approves (Maker-checker).
The bearer only authenticates. Authorisation is the platform’s: nothing on a token is a role, a permission or an organisation — the live organisation and user records decide, at request time. What the door can answer:
Admission is checked on every request before anything else about it: a malformed request from a caller the platform has not admitted is refused 403, not 400.
Capabilities
What you may do is your user’s capabilities: an array of scope strings, <family>:<verb>,
served on every user row and on GET /me — one family per resource. A preset is a bundle
the capabilities are copied from at the door, never a record the row points at
(Presets). The
verbs: users:manage, accounts:propose, accounts:approve (every change to an account and
to the keys beneath it since 0.65.0 — the venue-keys:propose and venue-keys:approve of
0.61.0 are gone), account-addresses:propose, account-addresses:approve,
portfolios:manage, asset-policies:propose, asset-policies:approve,
chain-policies:propose, chain-policies:approve, trading-policies:propose,
trading-policies:approve, orders:trade, algos:manage, api-keys:manage (since
0.68.0: issuing and managing the organisation’s API keys, API keys; no key
may hold it), and org:manage (since
0.29.0; spelled orgs:manage before 0.48.0), your organisation’s own settings (its
approval rules and, since 0.50.0, its name — PUT /org): every organisation’s to grant.
The platform’s own bit —
internal-platform:manage, the organisation lifecycle’s (one bit since 0.59.0; a pair,
internal-platform:propose and internal-platform:approve, before it) — is granted inside the
platform’s own organisation alone and belongs to the
internal platform API: a platform member’s row
carries it as a name this document does not list, which a client treats like any name it
does not know. And, since 0.24.0, the reads: users:read, venue-keys:read,
accounts:read, account-addresses:read, portfolios:read, asset-policies:read,
chain-policies:read, trading-policies:read, orders:read, algos:read — one per family a
member can be kept out of. And, since 0.54.0, the risk family: risk:read, risk:propose
and risk:approve — its read, and the maker and checker of its proposals (a risk limit’s
loosening, a position adjustment, a manually booked execution — routes still to come).
- Every verb stands alone (
approvedoes not implypropose), and a write your capabilities do not cover is refused by the record’s owner, on the platform’s stream, as 403CAPABILITY_DENIED— with one exception the gateway judges itself: the credential intake (Writes) checksaccounts:propose— onPOST /accounts, whose keys ride the account’s record, and on a key added or rotated beneath an account, a change to the account’s own record since0.65.0— before it stores any key material. - Every read needs its family’s read grant. Each read operation names it —
x-immix-readson the operation, and the sentence in its description:GET /usersneedsusers:read,GET /accounts/{id}/keysvenue-keys:read(the keys beneath an account: the account the path names is required, never read), and so on through the eight register families;GET /api-keysapi-keys:manage— the family’s one bit, which reads it, since there is noapi-keys:read(0.68.0);GET /ordersandGET /executionsorders:read, andGET /positionstoo (a position is built from those fills) — orrisk:read, the one read two families admit, which its operation states asx-immix-reads-also;GET /risk/records,GET /risk/exposures,GET /risk/posturesand the risk limits’ readsrisk:readalone;GET /account-balancesaccounts:read(a balance is the account’s); every read under/algosalgos:read. The gateway refuses a read the caller’s row does not cover 403CAPABILITY_DENIEDat the door — right after admission, before the request’s shape and the row lookup, with no position header — so a caller who may not read a family meets 403 on an absent id and on a bad query alike. Three reads take no grant:GET /me,GET /me/orgs(your own identity) andGET /operations/{key}(your own operation);GET /orgtakes none either — you read your own organisation’s row by membership, and so are the approval rules read.GET /venue-key-specsandGET /capability-presetstake none either: they describe the deployment and the platform’s vocabulary, nobody’s row (Venue key specs, Presets). The trading WebSocket gates its channels on the same grants. The gate stands on the reads alone: a write’s answer is the row it wrote, whatever its caller reads —POST /trading-policies/{id}/haltis any member’s (the fail-safe direction; an API key’s is 403CAPABILITY_DENIED, whatever it holds) and answers with the policy row, whichGET /operations/{key}replays — while the same member’sGET /trading-policies/{id}needstrading-policies:read. - A capability reads its own family — the one implication. Holding any
<family>:<verb>reads that family:accounts:proposereads accounts,orders:tradeorders and executions,algos:managethe algos surface,users:managethe users. Nothing crosses a family: a trader reads accounts only withaccounts:read. The:readgrants are for a member who may only look; an empty set reads nothing. TheCapabilityschema states the rule as contract, and since0.60.0a set the door takes carries the reads its verbs imply: it adds a verb’s<family>:read(every family butorgandapi-keyshas one) to a set stated without it, so["accounts:propose"]reads back as["accounts:propose", "accounts:read"]. To take a family away, leave out its read as well as its verbs. - Two spellings:
capabilities, or apreset. Granting takes the scope strings, or apresetthe door expands to a set —INITIATOR(the six:proposebits —risk:proposeamong them since0.54.0— and those families’ reads),APPROVER(Initiator and the six:approvebits,risk:approveamong them),ADMIN(Approver,users:manage,api-keys:manage— since0.68.0—portfolios:manage,org:manageand every read),TRADER(orders:trade,orders:read,accounts:read— the ticket names an account — andrisk:read, so a trader sees the record a refusal was judged on),TREASURY(the accounts, address, asset-policy and chain-policy pairs,portfolios:manage, those families’ reads andrisk:read— and so, since0.65.0, every change to an account’s venue keys, which the accounts pair governs, without reading a key’s record). The platform’s two lifecycle bits are no preset’s: they are granted as scope strings, inside the platform’s own organisation only.GET /capability-presetsserves each preset’s capabilities and a sentence on what it grants; a row records bits, never a preset name, and there is no third spelling — a preset is not a record (Presets). - An administrator is an
ACTIVEmember holdingusers:manage; once an organisation has one, it always keeps one. The bit makes an administrator, whatever else the row holds — not theADMINpreset, which is no record. Three writes refuse 409LAST_ADMINwhen their target is the organisation’s last administrator:POST /users/{id}/disable,POST /users/{id}/delete, and aPUT /users/{id}whose capabilities — stated, or apreset’s — leaveusers:manageout. Only anACTIVErow counts: a member invited with the bit counts once their row turnsACTIVE(Invitations), a disabled holder once enabled, and no API key holds the bit (API keys). Each write is judged against every write the platform accepted before it, so administrators removed at the same moment never leave the organisation with none: the write that would is refused. To remove the last one, make another first — grantusers:manageto an active member, or enable a disabled holder.
From a browser
A page on another origin calls the API directly when the deployment lists that origin. Each
deployment lists the exact origins it serves, spelled as a browser sends them in Origin
(https://app.example.com, https://desk.example.com:8443), and grants each of them:
- Its preflights. An
OPTIONSrequest from a listed origin — the preflight a browser sends before a call that needs one — answers204, at any path and before admission (a browser sends no token on one), withAccess-Control-Allow-Methods: GET, POST, PUT,Access-Control-Allow-Headers: Authorization, Content-Type, Idempotency-Key, If-Match, If-None-Match, X-Request-IdandAccess-Control-Max-Age: 600: the browser reuses each answer for ten minutes.If-None-Matchmay ride a read, as a client that revalidates sends it; the API answers every read in full whatever it carries. - Every answer, a refusal’s included.
Access-Control-Allow-Originnames your origin, andAccess-Control-Expose-Headerslets the page read every response header the document declares —X-Immix-Global-Sequence,X-Immix-As-Of-Seq-Ts,ETag,Idempotent-Replay,Location,Retry-AfterandX-Request-Id— so a page handles a 401, a 412’sETagor a 429’sRetry-Afteras any other client does.POST /ws-ticketsis granted like every route: a page mints its WebSocket ticket from its own origin before each connect.
There are no credentials: the bearer rides Authorization, never a cookie, so no answer carries
Access-Control-Allow-Credentials — send requests in the browser’s default credentials mode,
never with credentials: "include". Every response of a deployment that lists an origin carries
Vary: Origin. An origin not on the list is granted nothing: its requests are answered as if
they carried no Origin — a preflight as any OPTIONS is, 405 METHOD_NOT_ALLOWED — and the
browser keeps the answer from the page. The
internal platform API grants no origin.
Principals
Your organisation and your principal — the member or the API key — are taken from the bearer and the platform’s records, never from the request:
- No request carries an
orgIdto choose an organisation. Every read is scoped to your organisation by construction and no parameter widens it; another organisation’s record is404 NOT_FOUND, indistinguishable from one that does not exist. - No write carries an
actor: it is stamped from the admitted principal —{"kind": "USER", "id": <userId>}for a member,{"kind": "API_KEY", "id": <apiKeyId>}for a key — and a body that states one (or auserId, its spelling before0.68.0) is refused 400MALFORMED_REQUEST; so is a bodycommandKey, on every write since0.81.0— the key rides theIdempotency-Keyheader, and the platform stamps it onto the command. Rows carryorgIdand, wherever they name who acted, anActorobject —kindandid; the kind’s value set is append-only, so read an unknown kind as unknown, never as an error: an order’sactor, a proposal’sproposedByandconcludedBy, an algo instance’screatedBy. The platform’s own acts carry{"kind": "MACHINE", "id": 0}— a connector’s observation, an algo instance’s order. An order row also carriesalgoInstanceId— the platform’s own algo instance that placed it, beside theMACHINEactor;nullon every order a member or a key placed — and an order write that states one is refused the same way: no request through this edge is machine flow.
Last active
Every user row, every API-key row and GET /me carry lastActiveAtNs (since 0.71.0):
when the principal was last seen acting — its last admitted request on this API, or its open
trading socket — as epoch nanoseconds, null while no mark is recorded (the principal has not
acted since marks were first kept at 0.71.0, or ever — a reader cannot tell which). The
platform records activity at a five-minute grain: a request inside five minutes of the
mark need not move it, so read the value as “active within five minutes of this time”, never
as the exact last request; a trading socket marks its principal when it connects and every
five minutes while the principal holds one open, and an API key’s mark is its last use. A request
served by a read replica (a READ_ONLY member — a deployment’s second release for its
reads, [the operations runbook]‘s A read replica) is not
recorded: the replica publishes nothing, so a principal is marked by its writes, by the reads an
active member serves and by its trading socket — where reads are served by replicas, a key that
only reads can carry an old mark or none, which is not an unused key. It is a mark beside the
row, not a field of it: it moves no version and no ETag, so an edit held open never meets a
412 for a colleague’s sign-in, and it is not a sortable or filterable column.
Names
A member has one name (since 0.67.0): the user row’s name — free text up to 128 bytes,
set by whoever invites the member and changed by the member themself or by an
administrator. It is a label, not a key: two members may share one, and no write is refused
for a name another member holds. What the identity provider calls the person is read
nowhere — the token’s name claims included — so show name.
PUT /merenames you: the body is{"name": "…"},If-MatchtheversionGET /meserves (since0.76.0; itsETagcarries the same — 428PRECONDITION_REQUIREDwithout either), anIdempotency-Keyas on every write. EveryACTIVEmember may, with no capability, and it is live at once — no approval. It answers your row asGET /meserves it, with the row’s newversionandETag. Your capabilities and sign-in are an administrator’s: a body statingcapabilities,presetoridpUserRef— orkind, as on every user body since0.68.0— is 400MALFORMED_REQUEST. A name is a member’s: an API key’sPUT /meis 403FORBIDDEN_PRINCIPAL, and anapi-keys:manageholder restates a key’s name onPUT /api-keys/{id}(API keys).PUT /users/{id}renames a member as it restates their capabilities (users:manage).- No route changes an address. A member’s
emailis the address they were invited at; a new address is a new invitation.
Invitations
A member joins by invitation (0.18.0; 0.17.0 put the invitation on the user row). An
administrator (users:manage) invites a person by email with the capabilities they will hold
— POST /users/invitations, body email, name, preset or capabilities; the invitation
is claimable for 72 hours, the deployment’s lifetime (an organisation’s first administrator’s
is seven days), never a caller’s choice since 0.53.0 — and the platform registers them at
once as a user in status INVITED, holding those capabilities, and emails the invitation. The person’s
first sign-in claims it: a token whose organisation the platform knows, whose subject binds
no user yet, and whose verified email address is an open invitation’s claims the invitation
inside the door, on whatever route it arrives at — GET /me is the natural first call — and
is answered as the ACTIVE member it just became. An unverified address is refused
EMAIL_UNVERIFIED, an invitation past its deadline INVITATION_EXPIRED, a claim still in
flight REGISTRATION_PENDING (503, retry after Retry-After), and a sign-in with neither
row nor invitation NOT_REGISTERED (Authentication and admission).
An existing member needs no email (since 0.75.0). When the invited address already
belongs to a verified member of your organisation at the identity provider — someone who
signs in to it already — the platform sends nothing and binds them at once: the row turns
ACTIVE within moments of the invitation, holding the capabilities and the name you granted,
its invitationState ACCEPTED, its idpUserRef the member’s identity at the provider and its
idpInvitationRef empty — no invitation was created (a claim no invitation reached, after a
failed send say, leaves it empty too) — and invitationDetail names the member the address
belonged to. Nothing tells the person they now hold the seat; tell them yourself. A member
whose address is not verified at the provider is never bound (FAILED, MEMBER_UNVERIFIED,
below): verify the address there and re-invite.
An address one of your members already holds is refused 409 EMAIL_TAKEN — an invited, an
active or a disabled member’s (the disabled one since 0.75.0): a disabled member keeps
their seat and their identity, so another invitation at their address could never be claimed
by them — enable them instead (POST /users/{id}/enable). A deleted member’s address is free.
A user is never created directly: the invitation is the one way a person joins (since
0.68.0, when POST /users left with the service seat — a machine principal is an
API key, never a user row, and the user row carries no kind). The door admits
a bound subject or the claim of an open invitation, nothing else.
An open invitation is listed under GET /users?status=INVITED, re-sent with
POST /users/{id}/invitation (under If-Match, the version the re-invite replaces, as on every
entity write; no body — an invitation is fixed once sent (0.53.0): the row is restated as it
stands under a fresh deadline, the outstanding invitation withdrawn and sent anew, and a stated
field is 400 MALFORMED_REQUEST; another address, name or capability set is the cancel and a
new invitation), and cancelled with POST /users/{id}/delete —
the cancel is a delete, and /disable refuses an invitation 409 ILLEGAL_TRANSITION;
PUT /users/{id} refuses it too. A cancel is final: the row reads DELETED — it keeps its
email, binds no idpUserRef, and its invitationState keeps the value it had — and is
neither re-enabled nor re-invited (409 ILLEGAL_TRANSITION). Its address is free again, so
inviting the person again is a new POST /users/invitations: a new user, with a new
userId.
Expiry is a time, not a state: inviteExpiresAtNs is judged at the claim — a first sign-in
past it is 403 INVITATION_EXPIRED — nothing sweeps, and invitationState never reads
expired. A send the platform could not make says why since 0.53.0: invitationFailure
(EXPIRED_UNSENT — the deadline passed before the send; MEMBER_UNVERIFIED — the address
belongs to a member of the identity provider’s organization whose address is unverified there,
to be verified in the tenant first; IDP_REFUSED — the provider refused the create;
SUBJECT_BOUND, since 0.75.0 — the address belongs to a member of the provider’s
organization whose identity already holds another seat in yours, a disabled one, say, so this
row cannot be bound while that seat holds them, nor does a re-invite mend it: enable that seat
if it is disabled and cancel this invitation) with the provider’s words in
invitationDetail — for SUBJECT_BOUND, the seat; a re-invite clears both.
GET /me/orgs lists the organisations the caller holds an active seat in — one person is one
identity-provider subject across the organisations that invited them — as a page, ascending
by orgId, for an organisation switcher. A switch is a new token, not a call here: ask your
identity provider for a token for the row’s idpOrgRef (since 0.69.0; Auth0’s organization
parameter takes it), never its orgId or its name, and that token’s org_id claim is the
same value. Offer only ACTIVE rows with a non-empty idpOrgRef: a token for a DISABLED
organisation is 403 ORG_NOT_ACTIVE, and an empty ref names nothing to ask for. The list is
read through the organisation your token names, so a token for a DISABLED organisation
reads no list either: sign in again through your identity provider’s organisation picker.
GET /meis the one read that describes the caller:actor(who you are —USERwithuserId, orAPI_KEYwithapiKeyId; the othernull),version,orgId,orgName,name,status,capabilities— identity and grants alone since0.48.0, one name since0.67.0(Names), itsversion(since0.76.0; theETagcarries the same) the onePUT /metakes — your own user row’s, or the key’s own: the organisation’s approval rules are their own rows,GET /approval-rules(Maker-checker), and a platform member’s standing on the lifecycle isGET /internal-platform/meon the internal platform API. Configure a client from it, and from nothing in the token.
Presets
There are no roles. A preset is one of five named bundles the preset alias expands at
the door on PUT /users/{id}, POST /users/invitations, POST /users/{id}/invitation,
POST /api-keys and PUT /api-keys/{id} — INITIATOR (the six maker-checker propose bits
and those families’ reads), APPROVER (Initiator plus their approve bits), ADMIN (Approver
plus users:manage, api-keys:manage, portfolios:manage, org:manage and every read),
TRADER (orders:trade,
orders:read, accounts:read and risk:read) and TREASURY (the accounts, address and two
policy families, portfolios:manage, risk:read and those families’ reads; the accounts pair
makes and concludes every venue-key change since 0.65.0) — and never a
record: nothing is
created, linked or restated, the row records bits, and no row, body or read names the preset
a member was given — or a key: a preset naming a bit no key holds (APPROVER, ADMIN and
TREASURY name approve bits, INITIATOR risk:propose) refuses an API key’s issue or
restatement 422 INVALID_FIELD, so a key’s grant is spelled as capabilities, or as
TRADER (0.40.0; the /roles routes of 0.26.0 to 0.39.0 are gone). The
platform’s bit, internal-platform:manage, is no preset’s: granted as a scope string, inside
the platform’s own organisation alone, as algos:manage is. A
member’s “role” in a user interface is a label the client derives by matching the row’s
capabilities against the presets — an exact match names the preset, anything else is
Custom, an empty set No access. Every preset holds the reads its verbs imply, and since
0.61.0 so does every set the door takes (Capabilities), so a body that
leaves those reads out still reads back as the preset’s set. A row a gateway before 0.60.0
wrote, before the release or while it rolls out, may lack them: match after adding each verb’s
<family>:read, and every row compares the same way. The names are one schema,
CapabilityPresetName, on the presets read and on both bodies.
GET /capability-presets (0.41.0) serves the table a picker needs: each preset’s name —
the value preset takes — its capabilities in the order a row lists its own, and a
sentence on what it grants. Every admitted member reads the same one document, never a page,
with the position headers as on every read (Reads). Fill a
member’s capabilities from the preset picked, let the person edit the bits, and send the
bits; or send the preset’s name and let the door expand it. A later change to a preset
changes no member, since the row never named one. Before 0.41.0 the expansions were
published as the x-immix-preset-capabilities extension on the preset property, which
generators drop; the route replaces it.
API keys
An API key (since 0.68.0) is your organisation’s machine principal: a row at
/api-keys with a grant, a name and a lifecycle, and a bearer that authenticates as it —
immix_<keyId>_<secret>. A key acts under its own id: every write it makes is stamped
{"kind": "API_KEY", "id": <apiKeyId>}, and every row it touched names it so.
- Issue.
POST /api-keys(api-keys:manage), bodynameandcapabilitiesorpresetas a user body spells them — any capability butusers:manage,api-keys:manage,risk:proposeand theapproveones, which no key may hold (422INVALID_FIELD; a key cannot mint keys, seat people, approve or write a risk row) — and only capabilities you hold yourself, unless you holdusers:manage, which grants any (403CAPABILITY_DENIED): the secret is answered to you, so a key never reaches past what its issuer could grant. The answer is the key’s row withsecret: the bearer, served on this answer alone — the platform keeps its digest and nothing serves the secret again, so store it as the answer arrives (the answer carriesCache-Control: no-store). An issue the deadline answers202keeps its secret in the memory of the member that minted it, never on the stream or the operation record (GET /operations/{key}): retry the same request under the sameIdempotency-Key, as any write (Writes), and the first accepted answer holding the secret the key’s row records servessecret— normally the answer of the member that took your request. Every other answer serves the row withsecretnull— a member that never held that secret (a deployment runs more than one, and a request may reach any), a replay after the secret was served, an answer after another write rotated the key — and the remedy is a rotation (below), which mints a fresh secret served once. A member holds an unserved secret only while it can read the operation, and a restart forgets it. A name in use by a live key is 409NAME_TAKEN. - Restate.
PUT /api-keys/{id}underIf-Matchrestates the grant and the name — live at once: the key’s next request is judged by the new grant, which the issue’s bounds hold. - Rotate.
POST /api-keys/{id}/rotatemints a fresh secret, served once as the issue serves it — a202’d rotation’s by its retry under the sameIdempotency-Key, and where that answerssecretnull, by another rotation; the old bearer authenticates nowhere from the answering change on. The id, the grant and the name stay; the row’srotatedBynames the member the new secret was answered to (nulluntil a key’s first rotation), who stands behind what the key proposes from here on — so you hold every capability of the key’s grant, orusers:manage, to rotate it (403CAPABILITY_DENIED). - Lifecycle.
/disable(the key authenticates nowhere, 403FORBIDDEN_PRINCIPAL, until/enable) and/delete(for good; its name is free again, the row readable withinclude=deleted) — the user family’s shape,ACTIVE⇄DISABLED→DELETED, each at once underIf-Match, 409ILLEGAL_TRANSITIONwhere the move is not the row’s. - Maker-checker. A key’s proposal counts as the members behind the key —
createdBy, who issued it, and the member its secret was answered to when it proposed (its last rotator then, else its issuer), whom the proposed row names askeyHolder— so neither may approve it (403SELF_APPROVAL), and the inbox never names them among its approvers: dual control asks a member who could not have made the change through the key alone (Maker-checker). The proposal keeps itskeyHolderwhoever rotates the key afterwards: a later rotation moves the key, not a proposal already made. - Reading.
GET /api-keysandGET /api-keys/{id}serve the rows — never a secret or its digest, and since0.71.0with the key’s last use aslastActiveAtNs(Last active) — toapi-keys:manageholders. Only a member manages keys: a key’s own request on any/api-keyswrite is 403CAPABILITY_DENIED, since no key holds the bit. - As a key. A key reads and writes what its grant allows, as a member would: orders,
balances, positions, the register’s rows and proposals (it proposes and withdraws; it never
approves), the algos surface, a trading WebSocket ticket (a key’s opens
tradingalone:market-datais 403FORBIDDEN_PRINCIPAL) — andGET /medescribes it (actorAPI_KEY,apiKeyId, itsname,statusandcapabilities;userIdnull),GET /me/orgsits one organisation. The risk surface’s writes are members’ alone (Risk), and so is the trading halt: the kill switch any member throws with no capability is 403CAPABILITY_DENIEDfor a key, whatever it holds — a key’s authority is its grant. A key is admitted as a member is —NOT_PRIMED, then the bearer, then the row: 401UNAUTHENTICATEDfor a bearer naming no key, a deleted key or a wrong secret (the three answer alike), 403ORG_NOT_ACTIVEfor a disabled organisation, 403FORBIDDEN_PRINCIPALfor aDISABLEDkey.
Reads
GET /{resource} lists your organisation’s rows and GET /{resource}/{id} serves one, for
users, api-keys (since 0.68.0), accounts, account-addresses, portfolios,
asset-policies, chain-policies, trading-policies, orders and executions; the keys
beneath an account are read under it since 0.61.0 — GET /accounts/{id}/keys and
GET /accounts/{id}/keys/{keyId} (a key of another account is 404, as an absent one is);
GET /account-balances lists your accounts’ latest observed balances (a collection only —
see Balances), GET /positions your accounts’ derivative positions (a collection
only — see Positions), the algos collections are under Algos, and
GET /approvals lists your organisation’s proposals across the families with what changed
and who may approve (a collection only — see Approvals). Every key row
also carries health, whether a connector is serving it, and every account row the keys
beneath it with their readings — see Connection health.
Every collection answers a page:
Every member is on every page, null where it does not apply: the rows first, then the
walk, then the position the page was read at.
- Order. Each collection has one order of its own, stated on its operation.
orders,executionsand an algo instance’s orders are feeds, newest first: by descending id, and ids rise with creation. Every other collection ascends by its key: the row’s id;accountIdthenassetIdfor balances; the sequence number for an instance’s documents; the pool, then each entry’s place in its pool’s report, for the algo catalogue. sortasks for another order: comma-separated properties from the list the collection’ssortparameter names, a leading-for descending —sort=orgId,sort=status,-inviteExpiresAtNs— the parameter repeated or not. The order is always complete: the collection’s own key breaks every tie, in its own direction (a feed’s newest first), so no two rows share a position; a value a row does not state (null) sorts last whichever way the column goes; an id or clock served as a decimal string compares by value, text by code point and an enum by its name. A property the collection does not sort by, an empty term or one named twice is 400MALFORMED_REQUEST, the message naming what the collection sorts by. The sortable properties are a row’s ids, statuses and other enums, flags, counts, clocks and names; money, free text, opaque references and sets are not sortable, and the parameter’sdefaultis the collection’s own order.limitis the page size, 1 to 100. A larger value is clamped, never refused. Withoutlimitthe whole collection is served as one page.cursoris thenextCursoror theprevCursorof a page you were served, sent with the same filters, the samesearchand the samesort. It is opaque: send back exactly what you were given.nextCursorisnullon the last page andprevCursoron a page that starts at the head. A cursor does not carrylimitorinclude=total; send them with every request that wants them.include=deletedit does bind, as a filter (below).include=totaladdstotal: the exact number of rows matching the filters — the set served, so withoutinclude=deletedthe deleted rows are not counted — the whole walk’s and not the page’s. Without ittotalisnull.include=deleted(since0.39.0) serves a collection’s deleted rows among the live ones. By default every register collection (GET /me/orgsincluded) andGET /algos/instancesleaves out the rows their terminal state has reached —status: "DELETED", and on users a cancelled invitation written before0.38.0— unless you ask:include=deleted, which composes with any filter sent, or astatusfilter, which stands the default down whatever its values (status=DELETEDis theDELETEDrows alone;status=ACTIVE,DELETEDboth). Astatusfilter reads the row’s serialized status, so a users cancel written before0.38.0is understatus=DISABLED, never understatus=DELETED—include=deletedis the one read that lists every row the default leaves out. A by-id read serves a deleted row as ever. The toggle changes the set served, so it binds into the cursor as a filter does — a cursor minted with it isINVALID_CURSORwithout it, and the other way round — wheretotalnever did. The feeds and readings (orders,executions,account-balances,approvals, an instance’s configs and orders, the catalogue) have no terminal state and takeinclude=totalalone;include=deletedon them is 400MALFORMED_REQUEST(Lifecycle).INVALID_CURSOR(400) refuses a cursor that does not decode, or that came from another query: another collection, filter, search, view, sort or organisation. Drop it and fetch the first page. Asortspelled at the collection’s own order, or with its key written out (sort=orgId,userIdforsort=orgId), is the same query; so is a filter spelled another way — its values reordered, repeated or spaced — and a search in another case or with spaces at its ends. A filter a later version adds joins the binding only when you send it, so a cursor you hold keeps paging after the roll that adds one;searchjoins it the same way.
Walking a collection. Pages are read from live state, so a walk is not a snapshot. Each page states the position it was read at, and a row that changed between two pages is served as it stood when its page was read: merge pages by the row’s key, never append them.
A finished walk holds every row that was in the collection at its first page’s position and
stayed in it. A row that joined later is in the walk only if it joined ahead of the walker.
That is always so where rows join in key order, which is every unfiltered list of rows keyed
by an id, in its own order, on the default view: ids rise with creation, so a new row lands
after an ascending walker, and above the head of a newest-first walk, where fetching the
first page again reads it. It is not so where a row can join anywhere in the order: balances,
the algo catalogue, any list under a sort, and any list narrowed by a filter or by
view=approved, which a row enters by changing. So
take a walk as complete as of its first page’s position, and learn what came after from the
stream or from another walk. Under a sort by a column whose value can change, the walk
can miss or repeat a row that stayed in the collection: the cursor holds the values the
row had, not the row, so a row whose sorted value moves across the walker between two pages —
a user re-enabled under sort=status, an order filling under sort=status — is served twice
or not at all. The collection’s own key never changes, so a walk in the collection’s own
order has no such case: for a complete set, walk that order and sort what you hold.
Walking back, a page with fewer rows before it than limit asks for is the head page — the
first limit rows, exactly what a request without a cursor serves — so it can repeat rows
you already hold, which merging by key absorbs. A member below 0.13.0 ignores the three
parameters and serves the whole collection, in its own order, with globalSequence and
items alone: take a page without a nextCursor as the end.
- Read grant. Every read of a family needs the caller’s row to read that family — its
<family>:read, or any capability of the family (Capabilities); the operation names the grant, and 403CAPABILITY_DENIEDanswers without it, before anything below is judged. - Two views.
?view=latest(the default) is the review surface: while a proposal is pending on a row, the proposed content.?view=approvedis the enforcement surface: what the platform enforces now. On resources without proposals (users,account-addresses,portfolios) the two coincide;orders,executions,account-balancesandpositionshave one surface and refuseview=approved(400). - Position. Every response served from the platform’s state — the 200s and the 404s —
says where this member’s view of that state stood, twice.
X-Immix-Global-Sequenceis the position of the last change it had applied; a 200 body restates it asglobalSequence, except onGET /venue-key-specsandGET /capability-presets, documents that do not move with it, and onGET /operations/{key}, whose record states the command’s and the answer’s own positions instead.X-Immix-As-Of-Seq-Tsis the platform’s timestamp of that same change, in epoch nanoseconds; a page restates it asasOfSeqTsNs. Both advance on every change the gateway sees, records, orders and balance readouts alike: a reader at position S has seen every record, every order and execution and every balance reading at or before S. The position is the exact order, and it restarts if the platform’s stream is ever started afresh; the timestamp keeps rising across such a restart, and two changes can share one, which the position tells apart. A response holds every change at or before the position it states, and may already hold later ones, because its rows are read after its position is. So a stream frame at or before that position is already in the response; apply a later one by the row’s key and version, never as a new row. Until this member has applied its first change there is no timestamp to state: the header is absent andasOfSeqTsNsisnull. A write’s answer carries the position of the fact that answered it and no timestamp. Error bodies never carry a position field, and a refusal at the door (400, 401, 403, 503) carries neither header. - Reading what you have seen elsewhere (since
0.84.0). Your requests can reach different members, and one member can be a moment behind another. State a position you hold as?minGlobalSequence=<position>— anX-Immix-Global-Sequenceyou read, or a 202’scommandGlobalSequence— and the member answers only once it has folded the platform’s stream through it, so a read is never older than what you have already seen. A member behind it waits up to the gateway’s deadline — not at all when it already holds as many waiting requests as it takes, or you already hold 64 waiting on it, or your organisation’s keys and members 256 together (callers it does not admit yet, a key issued moments ago on another member among them, share 16) — then answers 503PROJECTION_BEHINDwithRetry-After; send the request again, to any member. Every route takes the parameter, beside the ones it declares; on aLocationyou poll, set it as a query parameter of the URL you resolved — set it, never append a second one. A value that is not one to nineteen decimal digits, at most9223372036854775807, is 400MALFORMED_REQUEST, and so is the parameter stated twice. The wait comes once your bearer authenticates and before the rest of the request is judged — who you are, what you may read, the request’s own shape — so a key, a grant or an enable made at that position on another member counts here, and a request malformed in another way waits too before its 400. The answer’s own position states the last change it reflects, which can sit below the one you sent when yours was a command’s — or read0, with no timestamp, on a member restarted from a snapshot that has applied no change since: the member has folded through your position all the same. A position belongs to one stream: when the platform cuts its stream anew — an event the operator announces, for the API carries no stream identity — positions start again from the beginning, and across the cut the parameter guarantees nothing, so drop every position you kept from before it — and everyETag: versions start again with the stream. A response whoseX-Immix-Global-Sequenceis below a position you hold while itsX-Immix-As-Of-Seq-Tsis above the one you read that position with, or a position members keep answeringPROJECTION_BEHINDto past a few retries, is a sign you missed such a cut, but no proof either way: once the new stream passes your number, nothing in a response tells the two streams apart. - Version. An entity response carries
ETag: "<version>", the row’s version — the tokenIf-Matchtakes on a write — and the row carries the same value in its body:version(an algo instance’sconfigSeq), onGET /meandGET /orgtoo since0.76.0. StateIf-Matchfrom the row you hold — quoted,"<version>", as theETagspells it (the gateway also takes it bare) — and a later read can never pair a newer token with your older copy. Executions are immutable and carry no version, so noETag; balances are readings that supersede one another and carry none either. A key’shealthis such a reading inside a versioned row — and an account’skeys[],capabilities,connection,trading,parentAccountIdandreadAtNsare derived from the keys beneath it: they change without the row’s version, so without itsETag. - Filters. Every collection narrows by its rows’ ids and the references between rows,
their statuses and other enums, and their flags — one query parameter per property,
named as the property is and declared on the collection’s operation, whose parameters are
the whole list:
GET /orders?instrumentId=5001&status=OPEN,PARTIALLY_FILLED,GET /accounts?exchangeId=300&status=ACTIVE,GET /users?status=INVITED(the pending-invitation list),GET /executions?orderId=9,GET /account-balances?accountId=50,51,GET /approvals?family=accounts. Any of: repeat the parameter, comma-separate its values, or both — a row is served when its value under that property is one of them — and separate parameters narrow together. Each value is stripped; the set is de-duplicated and sorted, so two spellings of one filter are one query and mint one cursor. At most 100 values a parameter, a repeat counted. Each parameter is typed by the row: an enum takes its published names (UNKNOWNis never one), an id a positive integer as the row serves it — a 32-bit integer, or a 64-bit one in decimal digits — a flagtrueorfalse. A value the row cannot carry — an empty value, one off that type, more than 100 values — refuses 400MALFORMED_REQUEST, the message naming the parameter and what it takes; a well-formed value naming no row (an id outside your organisation, one this member does not hold) yields an empty collection. A row that states no value (null) matches no value: there is no spelling for “absent”. A filter reads the row as the view serves it, after the organisation predicate — it widens nothing. What does not filter, in this version: clocks and counts (a clock wants a range), names and free text (a name wants a search — Search, below), money, opaque references and sets.GET /approvalskeepsstatus,mineandproposedByas parameters of its own — they select a surface or your standpoint, not a column — beside its filters. - Search.
GET /userstakessearch(since0.47.0): the users whosenameoremailcontains the text, ignoring case —?search=alice,?search=@acme.example. The text is matched anywhere in the value, not as a word or a prefix (search=icefindsalice). The spaces at either end are stripped, and a search left empty narrows nothing, as an absent one does. Every other character is part of the text: send a+as%2B, since a query reads+as a space. The parameter takes one value — repeated, it refuses 400MALFORMED_REQUEST. A search narrows as a filter does: after the organisation predicate, together with the filters, thesortand the count, and leaving the deleted rows out unlessinclude=deletedor astatusfilter asks. It binds the cursor as a filter does, and two spellings that match alike —search=ACME,search=acme— are one query. No other collection takessearchin this version. - No other parameter. A read takes the query parameters its operation declares and
refuses any other 400
MALFORMED_REQUEST, so a misspelt filter never serves the unfiltered collection as if it were the narrowed one. A collection takes its filters and the page’s four (limit,cursor,include,sort), andGET /usersitssearch; a single row takesviewalone. A member below0.47.0takes nosearchand refuses it the same way, empty or not — so send it only when there is text to search. A member below0.32.0takes nosortand refuses it the same way; a member below0.36.0takes only the four filters it had —statuson users,orderIdon executions,accountIdon balances,familyon the inbox — one value each, and refuses every other filter the same way, and a comma-separated second value on those four; the parameter repeated it reads as its first value alone (200, narrowed to that value), so send one value, or comma-separate and take the 400, until every member is at0.36.0.view=latestis accepted on every collection and row, the one-surface ones included.
Writes
Three route shapes per resource: POST /{resource} creates, PUT /{resource}/{id} amends or
restates the whole record, POST /{resource}/{id}/{verb} acts (approve, withdraw,
delete, halt, …). A body is the record’s fields minus what the gateway supplies: no
actor (stamped), and the path’s id and the version (If-Match) may be restated in the body
but never contradicted (400). A create’s id must be absent, null or 0. An action’s body is
optional: {} or an empty body is legal. Every write but one answers from the platform’s
stream, never from the gateway alone (the one is POST /ws-tickets, which mints the
ticket a browser opens a WebSocket with — trading or market-data, as its body names the
stream: the gateway answers it itself, with no position header and no ETag, and each
WebSocket’s contract — the
trading WebSocket’s
and the market-data WebSocket’s
— states the ticket’s rules with its ticket credential):
Four writes complete their body from the gateway’s own image of the row — POST /users/{id}/enable and POST /users/{id}/invitation (the whole body), PUT /me (all but your name) and PUT /accounts/{id}/keys/{keyId} (the fields a body leaves unstated) — so they are pinned to the version you read: If-Match must name it (* is refused 428). A version below the member’s image is a stale precondition: 412 VERSION_CONFLICT with its currentVersion and ETag before the platform judges the write — re-read and retry (a retry under the same Idempotency-Key of a write that was accepted still replays its 200). A version above it is lag, never a conflict (since 0.84.0): the member you reached has not folded the version another member served you, so it waits for it, up to the gateway’s deadline — not at all when it already holds as many such writes waiting as it takes, or you already hold 8, or your organisation’s members 16 together — and judges and composes the write from the row it reaches, or answers 503 PROJECTION_BEHIND with Retry-After, nothing taken: send it again, on any member. A version no member will reach — an ETag kept from before an announced stream cut, read off another row, or made up — waits the same way every time, for no member can tell it from lag: a write members keep answering PROJECTION_BEHIND past a few retries is the sign of one, so re-read the row and state the ETag it serves. Every other write takes * to write unconditionally on purpose.
Idempotency-Keyis required on every write but one —POST /ws-tickets, which mints a new single-use ticket on every call and takes no key (400MISSING_IDEMPOTENCY_KEY/INVALID_IDEMPOTENCY_KEY): a URL-safe string of 1 to 64 characters from[A-Za-z0-9._~-](a UUID fits), scoped to you — the same key from two users is two operations. A key names one operation on one record, ever: a retry replays the stored outcome withIdempotent-Replay: trueand publishes nothing, a retry of a still-live key attaches to it, and reuse of the key on another record or resource refuses 409IDEMPOTENCY_KEY_REUSED.If-Matchis required on every entity route (PUTand the/{id}/{verb}actions): it carries theETagthe read minted, quoted or bare — the version the write was computed against — or*, which writes unconditionally on purpose. Absent, the write is refused 428PRECONDITION_REQUIREDat the door, before the body is read and with nothing journaled: send it again, under the same key, with the header. A weak validator (W/…) refuses 400INVALID_IF_MATCH. A stale value answers 412VERSION_CONFLICTwith the current version in the envelope (currentVersion) and a freshETag: re-read, reapply, retry. State the version unless you mean the overwrite. Every write is a full-record restatement — the command carries the whole record and the answer replaces the row wholesale — so a*write overwrites every field from your copy, including the ones you never meant to touch and a colleague’s amend since your read, and a*approval concludes whatever the row holds now rather than what you read. The same shape one step less visible: an amend against a row whose proposal is still pending replaces that proposal.*is for the kill switches — a disable, a halt — and for a script that means it. A member below0.22.0took an absent header as*.- 200 is the record as the platform now holds it — the same shape the read serves, with
globalSequence, the position header and theETag; this member’s reads already reflect it. - 202 (
{"status": "PENDING", "key": "<your key>"},Locationthe operation’s URL) means the command was accepted, or is being carried, and its answer had not landed inside the gateway’s deadline — never a fabricated failure.Locationis absolute under the deployment’s public base where one is configured (https://api.immix.xyz/v1/operations/{key}, since0.84.0), the path/operations/{key}otherwise: resolve it against your request’s URL, and it names the same operation either way. The body carriescommandGlobalSequence(since0.83.0) when the answering member had folded the command by the deadline: the operation isCOMMITTEDand every member folds it, and theLocationcarries it as?minGlobalSequence=(since0.85.0), so the member you poll answers only once it has folded the command (Recovering after a 202, below); the field is absent when the answering member held no position for the command as the deadline passed — parked on the member that took it, in flight, or already sequenced — and absence never says the command is off the stream. PollGET /operations/{key}: the record showsphase(PENDING→COMMITTED→CONCLUDED) and, once concluded, theoutcome(the HTTP status, the code, the affectedentityIdororderId, and the message a synchronous caller would have read). The journal is the platform’s, not one member’s (since0.82.0): every member holds every write the gateway sequenced, so poll any member, with no session affinity, and a restarted member serves the window’s operations as the others do. A key past the window — 24 hours, or the newest 32768 operations of its kind (orders apart from everything else), whichever ends first — is 404UNKNOWN_OPERATIONon every member, and retrying it then re-submits: an owner that remembers keys (the register since0.84.2, the algos owner, the risk limits and adjustments, the manual executions) answers a key it still holds as it first did, each by its own rule (Errors has the register’s); a placement’s key is itsclientOrderId, which restates the same order; past that every action is state-gated — a cancel retried after its order is done reads 409ORDER_TERMINAL— and every create is unique by its natural key among live rows only, so a create whose row was deleted since is made again: read the row before retrying a create that old. - Recovering after a 202. Poll the
Locationas it is, with a bounded patience — a few seconds past the deadline is usually enough for a carried command to land, longer across a platform leader change. A secondminGlobalSequenceappended to it is 400MALFORMED_REQUEST: add the parameter yourself only where the URL lacks it, as on aLocationfrom a build before0.85.0. Its position belongs to one stream, so across an announced stream cut drop a keptLocationwith your other positions (Reading what you have seen elsewhere, above). Positioned, whichever member you reach answers only once it has folded the command, so a 404UNKNOWN_OPERATIONthen means the key is gone. Then send the write again under the sameIdempotency-Key, to any member, stating the same?minGlobalSequence=: the member waits until it has folded the command, then attaches to the live operation or replays its outcome — never a second publish while the journal still holds the key; once the window has dropped it, by age or by its kind’s capacity, the retry is taken afresh, as above. Without a position a 404 is only as of the answering member’s position: a member that has folded the command still attaches or replays, a key nobody carried any more is taken afresh and judged by the platform’s own dedup, and a member that has not folded it yet — which you cannot rule out behind one host — publishes the command again: an owner that remembers the key answers the second command as it answered the first (the register since0.84.2), any other judges it by its own dedup, and the record concludes on the first answer the stream carries for the key — the original’s unless the second’s lands first. 404UNKNOWN_OPERATIONis not a reason to keep polling past that patience: the write retry is the recovery. An API key issue recovers so too; whether a retry serves its secret, API keys says. - 4xx / 5xx is the record owner’s refusal, mapped to a status by its class, or the door’s — Errors.
Connecting an account, and the keys beneath it. The thing you connect is an
account — one row per venue account, the venue’s own account under your organisation —
and its keys are its own (since 0.61.0; before it a key was created first, under
/credentials, and the account discovered from it). POST /accounts connects one:
exchangeId (a venue GET /venue-key-specs serves as enabled — Venue key specs), displayName
(required, unique in your organisation: 409 NAME_TAKEN), the account’s key — the venue
key’s material and whether it trades (canTrade; every exchange key reads balances) with
an optional name, keyCreatedAtNs and rotateByNs — and, beside it, an optional
transferKey: a dedicated key that executes transfers out of the account and never
trades (a transfers key stated with canTrade is 422 DEDICATED_KEY; a key stated with
canExecuteTransfers is 400 — that key is the transferKey), plus ownership, purpose,
portfolioId and remark as PUT /accounts/{id} takes them. The command is one,
ConnectAccount: the account row and its key rows land in one answer — the row
PENDING_APPROVAL until your organisation’s accounts count is met, ACTIVE at once at a
count of 0, its keys riding the same proposal (Maker-checker) — and the
answer is the account row, keys[] on it (Connection health). The
venue’s word on the account is a reading beside the status, never a status: connection
reads CONNECTING until the account connector probes the key, then CONNECTED, or DOWN
with the reason and the fix (IP_NOT_WHITELISTED, AUTH_FAILED, ACCOUNT_EXISTS when
another live account of yours already holds that venue account — the duplicate reads no
balances and places no orders; delete it, or delete the other account and it takes over at
the next re-probe), and venueAccountRef is filled by the probe; nothing waits on it. A sub-account is
connected exactly the same way, with its own key: its probe states its venue account and
its parent’s (parentExternalRef), and parentAccountId names your organisation’s row for
the parent where you hold one. POST /accounts/{id}/keys adds a key beneath an account
later — a transfers key beside the account’s, or a replacement for a deleted one — a proposal
on the account, under the accounts count (since 0.65.0; Maker-checker):
the key’s account, venue and kind are the path’s, so the body carries
no exchangeId, providerKind or accountId (stated, 400), and at most one live key per
role sits beneath an account (a second is 422 INVALID_FIELD). The answer is the account row
with the new key in keys[] and its route in Location (/accounts/{id}/keys/{keyId}) — the
minted keyId for its later writes, which the row alone does not single out once a count of
0 has concluded the create at once; every key write’s answer carries the header, naming the
key it concerns.
One Binance account, one key, two markets. Since 0.62.0 a Binance account
(exchangeId 100, binance_spot) trades Binance USD-M futures (binance_usd-m, 102) too,
through the same trading key: there is no separate USD-M account or key. Grant the key
Enable Futures at Binance beside Enable Spot & Margin Trading. Orders on a USD-M
instrument name the Binance account; the venue table lists the further market under
x-immix-intake-venues (markets), and health.trading covers both (below).
Both creates and POST /accounts/{id}/keys/{keyId}/rotate take the venue key’s material once
(material, each leg a non-blank string: for OKX key, secret, passphrase; for Binance
spot key and privateKey, an Ed25519 key; for Bybit key and secret, an HMAC key — one
schema per venue, CredentialMaterial’s oneOf, the account’s venue naming which) over
TLS, under the request’s one Idempotency-Key (a connection’s two materials are staged
together and settle together). The gateway stores it write-only under a store reference of
its own (never served — it left the row at 0.24.0), fingerprints it (fp- and 16 hex
characters of SHA-256) and fills venueKeyId from the key leg; only references and metadata
go on to the platform, the row never serves the material, and a body stating any of
secretRef, venueKeyId or keyFingerprint — or, on a connection, any of the command’s
flat key… / transferKey… fields — is refused 400 — as is one still stating appGroup,
which left the record: the connectors that serve a key follow from its venue and its flags
(a key that reads balances is served by the venue’s account connector, one that trades by
its order-entry connector as well), and the gateway stores the material for every connector
that may serve the key: a key that reads or trades for the venue’s account connector and its
order-entry connectors alike, whether or not it trades today — so whether it trades is amended
in place, since 0.69.1 — and a transfers key for the account connector alone. A key stored
before 0.69.1 holds material for the connectors its flags named at the paste: amend it to
trade and its order-entry reading stays DOWN (CONFIG_ERROR) until the key is rotated — the
same legs will do — so rotate such a key before relying on it to trade.
One venue key is one row. Every exchange key reads balances — the gateway sets
canReadBalances on the create and the amend, whatever the body says — so the one question a
body answers is whether the key trades (canTrade); name is optional on a create (absent,
the row is named for the venue and the key id’s last four characters, OKX ...a3f9; the name
must still be unique in your organisation, so two keys sharing a suffix send the second back
409 NAME_TAKEN — name it); a key declared for transfers (canExecuteTransfers) is a
dedicated key and cannot also trade (422 DEDICATED_KEY, before anything is stored; the
platform refuses the same shape 422 INVALID_FIELD); and the same key pasted twice is
refused 409 KEY_ALREADY_REGISTERED naming the key that already holds it (its fingerprint
matches a live row of your organisation) — rotate that key to replace its material, or
delete it. A refusal about a leg names it — material.<leg>, the rule for every venue
and every leg (key.material.<leg> and transferKey.material.<leg> on a connection): a leg
missing or blank (material.secret is required — a non-blank string), a leg the venue has not
(material.pin is not a leg of okx (…)), or a leg off its published format (Binance spot’s
privateKey read as anything but an Ed25519 PKCS 8 key) is 400 MALFORMED_REQUEST with a
message that starts with the leg, so a form attaches it to the input; no value is ever echoed.
A trailing line break on a leg is dropped, never refused — a paste from a file, not material.
GET /venue-key-specs (Venue key specs) serves each venue’s legs as the schema to render the form
from and validate by. The intake’s
own refusals: 403 CAPABILITY_DENIED (no accounts:propose — the one bit, on a connection and
on a key added or rotated beneath an account alike — checked before anything is stored), 413 PAYLOAD_TOO_LARGE (16 KiB), 429
RATE_LIMITED (20 stagings a minute on each member, with Retry-After), 503 INTAKE_UNAVAILABLE, 422
VENUE_UNSUPPORTED and DEDICATED_KEY, 409 INTAKE_KEY_REUSED (the key already staged
other material) and KEY_ALREADY_REGISTERED. A
retry of a key the member answering it already holds stores nothing: it answers as any retry
does — the first attempt’s answer replayed with Idempotent-Replay: true, or attached while
that attempt is still being carried — so the store-time refusals (409 INTAKE_KEY_REUSED,
429 RATE_LIMITED, and 503 INTAKE_UNAVAILABLE when the store refuses the write) meet only a
key it holds no answer for. PUT /accounts/{id}/keys/{keyId} carries no material — new
material is a rotation — and restates the key’s account, venue and kind from the row (a key
never moves to another account or venue: stated in the body, 400). PUT /accounts/{id} is
the account’s amend — its name, portfolio, ownership and purpose — and carries no key field.
A rotation is judged on the incoming key (since 0.46.4). While the rotation awaits
approval, the venue’s account connector probes the new material at the pin the rotation staged —
beside the key’s live session, or on its own for a DISABLED key — and the record’s
observed fields (observedKeyFingerprint, observedPermissions, venueAccountRef,
probedAtNs, …) then describe the incoming key, pendingTransition still ROTATE — except
that a probe which fails (probeOutcome other than NONE) records its outcome and leaves
venueAccountRef as it was: a failed read states nothing about the account. The
scope checks — the approval’s (the account’s, POST /accounts/{id}/approve, since 0.65.0),
and since 0.53.0 the maker’s own submit, enable or rotate on an organisation whose
accounts count is 0 (the key’s own venue-keys count until 0.65.0), and since 0.69.1 an
amend that newly declares canTrade, judged at its conclusion as those are — (409
SCOPE_INSUFFICIENT, 409 SCOPE_MISMATCH) read that observation
and no other: a rotation nobody has probed concludes without a scope claim, and the record’s
observed fields stay the outgoing key’s — nothing re-reports a live key’s observation today, so
they describe the new key only once a later rotation’s probe answers. A rotation onto a
key of another venue account — the probe’s venueAccountRef differing from the record’s, both
stated — is refused at approval 422 INVALID_FIELD: withdraw it
(POST /accounts/{id}/withdraw — the account’s, a rotation being the account’s proposal
since 0.65.0) and rotate onto a key of this account, or
connect the other venue account as an account of its own, with that key. An organisation
whose keys conclude at submit has no approval to judge: its rotation cuts over unprobed, and
the connector’s next dial refuses a key of another venue account instead — the key’s
health.account reading is DOWN(CONFIG_ERROR) with both ids in its detail, and its
health.trading, where it trades, DOWN(CONFIG_ERROR) with an empty one, until the record
moves. The same holds for any key whose venue account is not the one its account names — a
transfers key created under another sub-account and added beneath a connected account, say: it
reads no balances and places no orders, its readings DOWN(CONFIG_ERROR) the same way, until it
is rotated onto a key of the account’s own venue account (since 0.64.2). Orders it placed
before keep reporting their fills and can still be cancelled. A transfers key can also be
deleted on its own; an account’s reading key cannot (409 CREDENTIAL_IN_USE), so it is rotated,
or the account is deleted with it.
Your organisation’s name is its own (since 0.50.0): PUT /org with {"name": "…"}
under the row’s version (If-Match, as every entity write takes it — GET /org serves it
in the body since 0.76.0, and in its ETag), by an org:manage holder, renames your
organisation at once — no approval, whatever your approval rules say. The answer is your
organisation as GET /org serves it, under the new name with a fresh version and ETag. The
name is a label, not a key: another organisation may carry the same one, restating your own
is accepted, and a rename tells you nothing about other organisations. An empty name or one
past 128 bytes is 422 INVALID_FIELD, and a member without org:manage is 403
CAPABILITY_DENIED. GET /org,
GET /me/orgs and GET /me’s orgName serve the new name from the answer on; the identity
provider’s organization takes it as its display name on the platform’s next pass, its own
sign-in name unchanged. The product profile and the lifecycle stay the platform’s: the body
takes name and nothing else.
Venue key specs
GET /venue-key-specs describes the venues the platform takes keys for, as this deployment sees them
— the one read a client needs before connecting an account (POST /accounts), so the
“connect an account” flow is rendered from the API and nothing hard-coded. Served to every admitted member, no capability
needed: the venue table is the platform’s and the addresses are the deployment’s, nobody’s
row. One document (VenueKeySpecs), never a page: it describes the deployment, not the
platform’s state — the position headers ride it as on every read (Reads), though
nothing in it moves with the position. The venues themselves — reference data, paged, and one
by id — are the data API’s GET /venues, under the same ids: a venue’s exchangeId here is its
venueId there.
venues— every venue the platform describes (VenueKeySpec), in the platform’s order, the ones this deployment serves and the rest alike. For each:exchangeId(the id a connection names and an account row carries; the data gateway’s venue id too — one id space across the two APIs),exchangeName(reference data’s spelling:okx,binance_spot),brand(the slug the venue’s markets share, for icons and colours — never parsed out of the name) anddisplayName;enabled— whether this deployment serves the venue, its connectors running beside the gateway: offer the enabled venues, and name the rest only (a key for a venue not enabled would idle);roles(VenueKeyRoles) —balanceswhen an account connector serves the venue (balances read, keys checked before approval),tradingwhen an order-entry connector does (a key’scanReadBalancesneeds the first,canTradethe second; transfers join when a connector executes them);probes— whether a pasted key is checked at the venue before approval, its permissions and allowlist read back onto the pending key (observedPermissions,observedAllowlist,probeOutcome) and the venue’s own id for the account onto the account row (venueAccountRef);materialSchema— the name of the venue’sCredentialMaterialvariant in the document, for a generated client’s typed legs;keyIdLeg— the leg that is the venue’s public key id, served back on the key row asvenueKeyId(nullwhen no leg is);material— the key’s legs as a JSON Schema, the same closed object schemamaterialSchemanames, every check the intake applies on it: each leg required,minLength1 with apatternrequiring one non-space character somewhere (non-blank; anchored, so a whole-string validator reads it as a search does),writeOnly, and its JSON Schemaformatwhere the intake checks one beyond that (pkcs8-ed25519); with form hints underx-immix-ui: on each leg alabel,secret(mask the input),multiline(a PEM block — a textarea, not an input) and thepatternMessageto show when the pattern fails, and on the object theorderto ask the legs in (a JSON object’s member order is no contract; the array is); andguidance(VenueKeyGuidance) — the permissions to grant at the venue for a balances-only key (balancesPermissions) and a trading key (tradingPermissions), in the venue’s own words, and the venue’s own page on creating and scoping keys (docsUrl).egressAddresses— the addresses this deployment’s connectors reach venues from, IP addresses or CIDR blocks: the ones to allowlist on the key at the venue. The key check judges a pasted key’s allowlist against the same list, so the verdict (observedAllowlist) and the addresses a customer copied cannot disagree. Empty while the deployment has no fixed egress address: nothing to allowlist yet, and the check readsUNKNOWN.
Render the key form from material and validate by it alone: every check the intake applies
to a leg is in the schema (required, minLength, pattern, format) and named in the
refusal, which starts with the leg (material.privateKey … — Writes); a value the
schema accepts and the intake refuses is the gateway’s bug, never the client’s, and no
client-side per-venue rule should exist. Two notes for a standard validator: the x-immix-ui
members are annotations, not keywords — allow them (ajv: strict: false, or addKeyword) —
and pkcs8-ed25519 is the platform’s own format, which a validator either registers (an
Ed25519 private key in PKCS 8 form, PEM or its base64 body) or leaves to the intake’s refusal,
which names the leg. A trailing line break on a leg — a PEM copied from a file ends with one —
is not material: the intake drops it before anything else, so it is never refused and never
stored. The edit path is a rotation (POST /accounts/{id}/keys/{keyId}/rotate), rendered
from the same schema; what a key row shows of its material is venueKeyId and
keyFingerprint, never a leg.
The list moves only with a release: a venue is added with its connectors, and enabled is a
fact of the deployment’s configuration, stated once per environment.
Maker-checker
Records can live under dual control. A connection or an amend on accounts, a key added
beneath an account (the account’s KEY_CHANGE, since 0.65.0), a create or amend on asset-policies, chain-policies
or trading-policies lands as a proposal wherever your organisation’s approval rules
(below) ask for approvals in that family — none does until the organisation raises a count —
and a lowering of one of those rules does too, as does an address’s declaration
(account-addresses, since 0.53.0): the row’s pendingTransition says what is proposed (ACTIVATE for a new record, AMEND,
ENABLE, DELETE, ROTATE, RESUME_TRADING; NONE when nothing is pending — one word a
transition since 0.67.0, when an account’s enable stopped reading UNFREEZE and a key’s
delete REVOKE) and proposedBy who
proposed it — an Actor, a member or an API key (kept on the row once it concluded); view=latest shows the proposed content,
view=approved the enforced one. An organisation’s lifecycle — its creation, disable, enable
and delete — is the platform’s act, at once, on the internal platform API (nothing of it pends
since 0.59.0): your organisation’s row here (GET /org) carries its identity and standing
alone, no proposal record. A second person holding the resource’s approve capability
concludes it with POST /{resource}/{id}/approve — the proposer cannot (403
SELF_APPROVAL), and an API key cannot at all — no key holds an approve capability, so a
key’s approve is 403 CAPABILITY_DENIED: an approval is a person’s; a key proposes and
withdraws as its grant allows, and its proposal counts as the members behind the key — the one
who issued it (createdBy) and the one its secret was answered to when it proposed, which
the proposed row names as keyHolder (its last rotator then, else its issuer): neither may
approve it (403 SELF_APPROVAL), so another holder of the capability concludes it — and
either the
proposer or a holder of that approve capability withdraws it with /withdraw (the checker’s
way to reject; anyone
else is 403 NOT_PROPOSER); a
withdrawn activation parks a key or a policy in DRAFT — and, since 0.61.0, a withdrawn
connection parks the account in DRAFT with the keys stated with it, which
PUT /accounts/{id} re-proposes together. The keys stated at a connection ride the
account’s proposal (since 0.61.0): one proposal, one inbox item showing the keys and
each key’s probe readout beside its declared flags, judged under the accounts count — the
approval that meets it lands the account ACTIVE and its keys ACTIVE in the same answer,
and at a count of 0 the maker’s own connection does. Every later change to a key is the
account’s proposal too (since 0.65.0): a key added (POST /accounts/{id}/keys), amended,
rotated, enabled or deleted settles on the account’s one pending slot as KEY_CHANGE, the key’s
own change pending beneath it in keys[] (since 0.70.0 with the name, the flags and the
rotation deadline it proposes, the enforced ones beside them in the inbox’s before.keys[] —
Approvals), judged under the same accounts count, concluded by
POST /accounts/{id}/approve (the key’s facts in the same answer) and returned by
POST /accounts/{id}/withdraw (the key restated as its approved record; one never approved
left DRAFT) — one change at a time per account: a change to another key, or to the account
itself, while one pends is 409 PROPOSAL_PENDING, the same key’s same change re-staged in
place excepted (a rotation onto fresh material) — and the account row’s version and ETag
move with it; a key’s disable is the one immediate act. A key stated at a connection still
pending or withdrawn is amended by re-staging the connection (since 0.65.0): the account
answers ACTIVATE afresh at its next version, its approvals cleared, the corrected key and
the connection’s other keys riding it — the fields an amend restates on any key (the name,
the deadlines, canServeAddresses and, since 0.69.1, canTrade); its transfers shape alone
stays pinned to the staged material as on every pinned key (400 MALFORMED_REQUEST: a key is
pasted as a transfers key or as the account’s key, and stays so), and a canTrade the probe
contradicts is corrected at the venue, the re-probe reading the granted scope, or unticked.
A key declared neither to trade nor for transfers that the probe finds able to withdraw has
its order-entry material retired (since 0.69.1; a key that can move money is never left
where a trading process can read it) — at the probe’s answer, or at the amend that unticks
canTrade on a key the probe had found able to withdraw: once Withdraw is removed at the
venue and the re-probe reads clean, amending it to trade also needs a rotation
(POST /accounts/{id}/keys/{keyId}/rotate, the same legs will do), before or after the amend
— its health.trading reads DOWN (CONFIG_ERROR) until then. A key that stays declared to
trade keeps its material where it was, so its documented fix stands: remove Withdraw at the
venue, and the re-probe reads the granted scope.
Approving with nothing pending
is 409 NOTHING_PENDING, and a user approving the same proposal twice is 409
ALREADY_APPROVED (where a family needs more than one approval, each comes from a different
user); an action on a row whose proposal is still pending may be refused 409
PROPOSAL_PENDING, while an amend against it revises the proposal. On a record not yet live a
re-submit replaces only its own activation proposal (a PENDING_APPROVAL row carries that
alone); while a delete pends on a DRAFT account, key or policy, the
re-submit is 409 PROPOSAL_PENDING too (since 0.46.3; before it the re-submit replaced the
pending delete), and so is a withdrawn connection’s re-proposal while a delete pends on one of
its keys (since 0.61.0; the refusal names the account). Some actions conclude at once, no
approval needed:
disabling an organisation, a key, an account or a user, halting trading.
An organisation’s approval rules are how many approvals a proposal needs, one rule per
family — accounts (the accounts and, since 0.65.0, every change to the keys beneath them:
the venue-keys rule of 0.61.0 is gone), account-addresses, asset-policies, chain-policies,
trading-policies and, since 0.54.0, risk (a risk limit’s loosening) — read by every member with GET /approval-rules (your organisation’s
rows; ?family= names one) and GET /approval-rules/{id}, each rule’s count 0 to
4 (account-addresses too since 0.53.0, each verification being one approval): 0, every
family’s default, means the maker’s own write is the record; 1 is the dual-control pair,
2 and above that many approvers, each a different person. A rule’s family names it as the
wire does — ACCOUNTS, ACCOUNT_ADDRESSES for the account addresses, TRADING_POLICIES
— and view=approved on a rule is
the count in force (until 0.48.0 GET /me composed the six as approvalPolicy). An
organisation starts with every rule at 0 — its creation, on the internal platform API,
makes the six — and turning on approvals is the organisation’s own, advanced step, one
family at a time: PUT /approval-rules/{id} with {"count": n} and an optional remark,
under that rule’s ETag, by an org:manage holder (since 0.46.0; before it the whole table
was restated on PUT /org/approval-policy). A raise or a restatement concludes at once, and withdraws a
lowering pending on the rule, which its maker then finds returned; a lowering is itself a
proposal on the rule — unless you are the organisation’s only person, with no other person
active or disabled (a disabled colleague still counts; an API key is no person) —
which a second person holding org:manage approves with POST /approval-rules/{id}/approve,
and its maker or any org:manage holder returns with
POST /approval-rules/{id}/withdraw (with nothing pending either answers 409
NOTHING_PENDING); while it is pending the rule’s view=latest shows the proposed count and
view=approved the count in force. A proposal already pending is judged by the rule in force at
its next approval (since 0.45.0; before it, by the count it was made under): raising a count
reaches it, and lowering one concludes nothing by itself yet — the next approval from someone
in its approvers concludes it; with nobody there, the maker restating it starts it over under
the lowered count, its approvals cleared (concluding at once only at 0), and a fresh approval
concludes it. Every row under maker-checker carries its proposal record, complete since
0.53.0 and written on every write a member makes, one the count let through at once
included: proposedBy (the maker — an Actor, a member or an API key — kept once the
proposal concluded), proposedAtNs, the maker’s remark, approvals ([{userId, approvedAtNs}], who has approved it so far and when — people, by user id), concludedAtNs
and concludedBy (when it concluded and who concluded it — the approver whose approval met
the count, or the maker at a count of 0, the two clocks then equal; null while it pends
or after a withdrawal) and its last withdrawal (lastWithdrawalProposedBy,
lastWithdrawalWithdrawnBy — actors — lastWithdrawalAtNs,
lastWithdrawalReason) — every maker body takes an optional remark and every /withdraw an
optional reason — each at
most 256 bytes; past that the register refuses 422 INVALID_FIELD, as it refuses every
string past the bound its description states (since 0.26.1: a name 128 bytes, a
reference another system minted — an identity provider’s id, a secretRef, a key id, a
fingerprint, a venue’s account reference — 256, a display name, an address and a memo
256, a diagnostic 512, an email address 254, an account’s displayName 64; bytes are
characters, the wire folding a character outside ASCII to ?) — the register stamps
proposedAtNs and remark when the proposal is made and writes the four
withdrawal members when it is withdrawn (since 0.25.0). No row carries a count: the count a
proposal is judged by is the rule in force, served on the inbox item; a concluded row’s
approvals says how many it took. A rule’s own lowering needs 1, whatever the rules say. The proposals across the families, with
what each changes and who may approve it, are one read: Approvals. Users and portfolios are not under maker-checker. Addresses are under it since 0.53.0, in the
protocol’s own words: a declaration (POST /account-addresses) or a connector’s observation
is the row’s proposal (pendingTransition ACTIVATE, the declarer its proposedBy —
null for an observed row), each verification by a person holding account-addresses:approve
is an approval on its record (POST /account-addresses/{id}/verify; the declarer verifying
their own is 403 SELF_APPROVAL, a repeat 409 ALREADY_APPROVED, an API key 403
CAPABILITY_DENIED), and the row lands VERIFIED when the organisation’s account-addresses
count is met — at 0, in the declaring member’s own call. A declaration deleted before it is
verified comes back to its declarer: POST /account-addresses/{id}/delete takes an optional
reason, and the inbox serves the row — now DELETED — returned, with who deleted it, when
and why; a verified row’s delete returns nothing, its record standing as it concluded.
Lifecycle
Every record spells its lifecycle in two words beyond the states that lead to ACTIVE:
DISABLED, the reversible stop — the row does not operate (an organisation’s members are
refused, a key’s connectors stop serving it, a disabled account trades nothing and its keys
stay ACTIVE while their account lanes park, connection reading DOWN with
ACCOUNT_DISABLED, since 0.61.0) and comes back
only through an explicit enable under the family’s own control — and DELETED, the end:
reached by an explicit delete, addressable by id with its history forever, its name free for a
new row, never reused. Three verbs act on it, on every family that has the state:
POST /{resource}/{id}/disable concludes at once (on an account it also states a reason),
/enable and /delete are proposals where the family is under maker-checker — the approver
concludes them with /approve, and the approvals inbox lists them as ENABLE
and DELETE — and conclude at once on users, portfolios and addresses. On a user,
/enable restates the row as it stands (Writes says what that pins), and
/delete is legal from every status but DELETED — straight from ACTIVE too, since
deleting reduces exposure — and is the cancel of an invitation, which /disable no longer
takes. A deleted member’s subject stays on the
deleted row as history (0.53.0): a removed member may be invited again, as a new user — a
new invitation at the address is accepted and their first sign-in claims it into the new row,
where it was refused IDP_REF_TAKEN before; without an open invitation their sign-in is 403
NOT_REGISTERED (403 FORBIDDEN_PRINCIPAL before 0.53.0). A disabled member keeps their seat and their
subject: disable a member who should keep the seat, delete one who leaves.
A key’s delete takes the approvals your organisation’s accounts count asks for (since
0.65.0, as every key change does; none at the default, 0) though it reduces exposure: the irreversible act affords a second
pair of eyes where the organisation asks for one, while its disable is always one person’s,
serving urgency. An account’s keys follow it (since 0.61.0): POST /accounts/{id}/delete,
under the accounts count, deletes the account’s own keys in the same answer (keys[] empties,
their material retired), and a key cannot be deleted on its own while it is the reading key of
a live account — 409 CREDENTIAL_IN_USE: rotate it (POST /accounts/{id}/keys/{keyId}/rotate),
or delete the account — though a transfers key deletes on its own. The verbs before 0.37.0 — suspend, reactivate, retire, freeze,
unfreeze, revoke — are not served since 0.44.0; the
changelog maps each to its successor. Since 0.39.0 a list
leaves its deleted rows out unless include=deleted or a status filter asks for them
(Reads); a by-id read serves a deleted row as ever, with its history.
Approvals
GET /approvals is the organisation’s inbox: one item per proposal across the families under
maker-checker — accounts (a change to one of an account’s keys among them since 0.65.0),
account addresses, the three policies, the risk limits (the risk family) and a lowering of one of the organisation’s approval rules (the
approval-rules family) — with what each changes and who may still approve it, so a
checker reads a diff rather than a record and a maker sees what came back and why. It is a
projection over the rows the gateway already serves: nothing on it is a record of its own,
and a row’s /approve and /withdraw routes are how an item moves.
- Three states.
status=pending(the default) lists the rows with a proposal awaiting approval —transitionis what it proposes,approvalswho has approved so far and when ([{userId, approvedAtNs}]),requiredApprovalshow many it needs as its rule stands now (so raising a count reaches a pending proposal;1on a rule’s lowering). A count lowered since the proposal was made concludes nothing by itself yet: the next approval from someone inapproversdoes; with nobody there, the maker restating it starts it over under the lowered count, its approvals cleared, and a fresh approval concludes it.status=returnedlists the rows whose last proposal was withdrawn and nothing proposed since:transitionisnull,returnedByActor,returnedAtNsandreasonsay who returned it, when and why, andreturnedByismaker(the proposer withdrew their own) orchecker(someone else returned it — a colleague, or on an approval rule the colleague whose raise or restatement superseded the lowering; that item keeps the lowering’s maker and the withdrawal, withproposedAtNsnullandremarkempty, since the row’s own record is the raise’s from then on —afteris the row as the raise left it, its record the raise’s). The item stands until the row’s next proposal.status=concluded(since0.53.0) is the organisation’s audit list: the rows whose last proposal concluded, each with who proposed it, who approved when, andconcludedAtNsandconcludedBy— the approver whose approval met the count, or the maker where the count was0and the write concluded at once;transitionis what concluded — the row’sconcludedTransition, the kind the conclusion cleared — andapproversis empty. The two conclusion members are on every item andnullon a pending or returned one. beforeandafterare the row in the family’s own shape. On a pending itembeforeis the row asview=approvedserves it — what the row returns to if the proposal is withdrawn — andnullon anACTIVATE(a new key, policy or organisation, a connected account, a re-proposed draft: nothing stands to compare with, however many approvals it has gathered);afteris the proposed record asview=latestserves it. On a returned itembeforeis alwaysnullandafteris the row as it stands after the withdrawal: the enforced record restated where one was enforced, otherwise the not-yet-live record as it stands; on a concluded itembeforeisnullandafterthe row as it stands now — the conclusion’s content as any later single-user act (a disable, a halt, an address’s delete) or machine fact left it, so an item concluded under one name may show astatusa later act set: the item’s owntransition,concludedByandconcludedAtNssay what concluded, who and when;after.statuswhat the row is now.familysays which shape:accountsthe account with itskeys[](the keys stated at a connection ride the account’sACTIVATEitem: one proposal, the probe’s readout on each key beside the declared flags; since0.65.0a change to one key is the account’sKEY_CHANGEitem, the key’s own transition and image inafter.keys[]— and since0.70.0each entry carries the key’sname,canReadBalances,canServeAddressesandrotateByNs, the fields an amend moves, proposed inafter.keys[]and enforced inbefore.keys[], so an approver holdingaccounts:approvewithoutvenue-keys:read— theTREASURYpreset — reads a rename or a new rotation deadline where it decides it),approval-rulesthe rule, and so on.approversis who may still approve: the organisation’s active people holding the family’sapprovecapability (org:managefor an approval rule’s lowering) — never an API key, which holds noapprovecapability — other than the maker (on an API key’s proposal, the key’s issuer and thekeyHolderitsafterrow names too) and those already inapprovals, ascending. Empty on a pending item means no one else can approve yet — the organisation invites or grants before the proposal can conclude; a returned or concluded item awaits nobody, so its list is empty.- Filters.
mine=truenarrows to the pending items awaiting you — you are inapprovers— and itstotalwithinclude=totalis the count for a bell; withstatus=returnedorstatus=concludedit refuses 400, since neither awaits anybody.proposedBy=menarrows to your own proposals, pending, (withstatus=returned) returned to you or (withstatus=concluded) concluded.family=narrows to one family (accounts,account-addresses,asset-policies,chain-policies,trading-policies,approval-rules,risk). Ariskitem’s row isGET /risk/limits/{entityId}, decided under/risk/limits/{entityId}/proposal/approveand/withdraw; its retirement readstransitionDELETE, as every family’s delete does. The inbox has one surface:view=latestis accepted, as on every one-surface collection, andview=approvedrefuses 400. Any other value, and any other parameter, refuses 400. The page’s four parameters apply as on every collection,sortamong them (defaultfamily, thenentityId); the order absent one isfamily(alphabetical by segment), thenentityId. - What you see is what you read. The inbox takes no read grant of its own: it lists a
family’s items exactly when your row reads that family (Capabilities), so
a member with
accounts:readsees the accounts items — a key’s change among them since0.65.0;venue-keys:readalone lists no accounts item, a key’s change included — and a member who reads nothing sees none — a page, never a 403. A rule’s lowering is read by membership, as the rules are, so every member sees it. The organisation lifecycle is never here: it is the platform’s act, at once, on the internal platform API — nothing of it pends, and an organisation’s own row carries no proposal. - Drafts are yours. An unsubmitted form has no state on the platform; the inbox begins at the submit. A client that wants drafts keeps them on its side.
Money
Every money value is a decimal string, in and out: "2.5", "0.00010000". On the wire
every money value is a Decimal — a scaled integer that carries its own scale beside it — so
the gateway reads it without reference data at all and serves it at exactly the scale the
value states. That is where the digit count you see comes from: it is the precision the
platform recorded for that value, not a width derived from anything else.
Do not read meaning into the digit count, and do not compare money as strings. The same
amount recorded at different precisions serves different strings — "2.5" and "2.500000"
are the same number — because each states the precision its own fact carried. Parse every
money field as a decimal and compare numerically. Two consequences worth stating plainly: the
string depends on the value alone, never on whether this member happens to hold the asset or
instrument a row references, so it does not change as reference data catches up; and the same
value read over the websocket edge serves the identical string.
On the way in, the gateway encodes each decimal at its own
scale — the fractional digits you send, trailing zeros dropped, so "1.50" and "1.5" are
one value — and states that scale beside the value on the wire. It consults no reference data
to do so (since 0.3.4), so it refuses nothing for precision and nothing for an asset or
instrument it does not hold: the platform judges the value. The orders owner aligns an order’s
price and qty to the instrument’s scales before it checks anything, so a price off the
tick is its 422 TICK_SIZE_VIOLATION; a policy amount is held at the scale you stated and
compared exactly. One asset or chain policy’s amounts share a scale — the finest any of them
states — so a finer sibling adds trailing zeros to the others on a read, and amounts that
cannot fit a 64-bit integer together at that scale (about nineteen digits between the largest
integer part and the finest places) are the register’s 422 INVALID_FIELD.
The grammar is the schema’s, and the gateway holds you to it (since 0.4.1): every money
property publishes pattern ^-?[0-9]+(\.[0-9]+)?$ and maxLength 64 — an optional minus,
ASCII digits, and at most one point with digits on both sides of it, in at most 64
characters — and a money string is accepted exactly when it matches both, judged as sent.
So no exponent ("1e3", "1E-7"), no leading plus, no bare point (".5", "5."), no
surrounding whitespace, no digits outside ASCII; leading and trailing zeros are fine. Mind
your number formatter: JavaScript’s String(0.0000001) is "1e-7", and Java’s
BigDecimal.toString() and Python’s str(Decimal) give "1E-7" — format money from an
exact decimal type in plain notation (toPlainString(), format(d, 'f')), or carry the
string you were served, which always matches. In JavaScript keep money in a string or a
decimal library, never a Number: toFixed rounds a binary float, and
(0.0000001).toFixed() is "0" — which means “unset”. A member below 0.4.1 read those
spellings as the numbers they spell.
The door’s own money refusals are all 400 MALFORMED_REQUEST, and none spends the key: a
value that is not a JSON string, one off the pattern or longer than the maxLength, one
with more than 18 fractional digits or past a 64-bit integer at its own scale, and an amount
beside an assetId or instrumentId that is absent or 0. "0", null or an absent field
all mean “unset” (the platform’s 0 sentinel), so a row read from GET round-trips into a
PUT body. Never send a scale of your own (priceScale, maxTicketAmountScale, …): the
document advertises none, and the gateway refuses 400.
The families below still matter on the way in — they say which record’s scale the gateway converts your value at — but on the way out every one of them is served at the scale its own value states.
Every money value states its own scale, so a row is an exact decimal whether or not this member holds the asset or instrument it references. Parse every money field as a decimal string and never assume its scale — a value that carried six places yesterday may carry two today if the venue restated it, and both are the same number.
Every money property carries the decimal pattern (^-?[0-9]+(\.[0-9]+)?$) and
maxLength 64, on the rows you read as on the bodies you send — the widest decimal served is
39 characters; a required money field always serves a decimal, an optional one serves null
at its sentinel.
Ids, sentinels, enums and sets
- Ids are opaque integers the platform mints — never contiguous, never meaningful,
unique per resource. Register ids (
orgId,userId,apiKeyId,credentialId, …) are 32-bit and cross as JSON numbers;orderId,executionId,instrumentIdand everyversionare 64-bit and cross as decimal strings (they exceed 2^53), in paths too. Timestamps (…AtNs,…TimestampNs) are epoch nanoseconds, also as decimal strings. - Sentinels. An optional field at its unset value serves
null— never a zero — and is markednullablein the schema; as input, absent andnullboth mean unset. Two named exceptions: a trading policy whoseinstrumentIdisnullis the organisation-wide default row (it carries the halt flag and the count ceilings); an order’svenueCumQtyservesnullfor “never reported”. - Enums cross by name (
"ACTIVE"), never by number, and every value set is append-only from1.0.0— before it, a minor may also remove or rename a value, and its changelog names it (Versioning). Reading, treat a name you do not know as the field’s unset value (UNKNOWN,NONE), never as an error — a closed-set validator breaks on the first append. Writing, the parse is strict: an unknown name, or the unset value itself, refuses 400 — omit an optional field instead; a required one has no unset spelling, and its absence refuses 400 too. Booleans are booleans; absent readsfalse. Strings are nevernull:""is “none”. - Sets (
capabilities, a credential’sobservedPermissions) serve as an array of names in declared order — empty means none, nevernull; an unknown name is skipped on reading and refused on writing. Sets are append-only too, on the same terms. A set’s names are one named schema that every array of it references —Capability,KeyPermission(0.60.0). - Appended fields carry
x-since-schema-versionin the schema (an order’salgoInstanceId, a balance’swallet): a member on an older schema serves the row without them, so absence there means “not served here”, not “unset”. The register’s members carry none since0.67.0: its schema was re-baselined, and every field it serves is required.
Errors
One envelope on every refusal the gateway answers — its own, the platform’s, and a request no route answers alike:
error.codeis the machine surface — a stable string to branch on. The code set is open: branch on the codes you know and treat an unknown one by its HTTP status. Until1.0.0a minor may also remove a code, and its changelog names it (Versioning), as0.44.0did.error.messageis for humans. Every refusal carries one; its wording may change without notice, so never parse it.error.requestIdis the request’s id. TheX-Request-Idresponse header carries the same value on every response, a success included: quote it when you ask about a request. Send your ownX-Request-Id— 8 to 128 of[A-Za-z0-9._-]— and it is the id used; anything else is replaced with a fresh one. The document declares the header on every operation, as a request header you may send and on every response.error.retryablesays whether sending the identical request again, itsIdempotency-Keyincluded, afterRetry-Afteror a short pause, can succeed with nothing else changed (Retrying has the rule).currentVersionsits besideerror, on a 412 only.
The envelope is the gateway’s. A request the web server turns away before the gateway reads
it — a request line it cannot parse, headers past its bound, a WebSocket upgrade — is
answered by the server itself, and so is a failure too deep for the gateway to answer.
Neither carries the envelope or X-Request-Id: treat such an answer by its status.
A member below 0.12.0 sends code, sometimes message, and neither requestId nor
retryable. Where retryable is missing, decide by the status and the code: treat a record
owner’s refusal as final for its key, and bound any retry of INTAKE_UNAVAILABLE and
NOT_SERVING, whose two cases (Retrying) a status and a code cannot tell apart.
The door’s codes — the gateway refused; nothing reached the platform, the key was not journaled, a retry takes fresh:
The 422s for a name stand only for a key the member answering holds no answer for: a key it holds answers as that key’s retry instead, whatever the name resolves to now (Orders, Algos).
The record owner’s codes — the platform judged the command, and the refusal is a fact on
its stream: it carries the position header, and a retry of the key replays it with
Idempotent-Replay: true. The full set is the OrgRegisterRejected.reason enum in the
document:
A retried register write is answered once, by the platform too (since 0.84.2). Within the
24 hours after a register write was answered — among its newest 32768 register answers, at least
as many as the gateway’s journal holds — the platform itself remembers its Idempotency-Key (by
you, the route’s command and the key): sending the same key again — including past the gateway’s
journal window, or to a member whose rebuilt journal never saw it — returns the first answer and
changes nothing. That is the first write’s 200, showing the row as it stands now, or the
refusal the first earned, with its status and code: a 409 where the first was refused one, and
never a 409 that the first write’s own success caused — NAME_TAKEN, NOTHING_PENDING,
ALREADY_APPROVED, ILLEGAL_TRANSITION. The platform looks the key up before it judges you
again, so a refusal of your standing is returned too, even after your standing has changed: send
that write under a fresh key. The answer carries Idempotent-Replay: true only when the gateway
replayed it from its own journal. The same key sent with the same command to another row — a
family’s create and its amend share one, as do PUT /users/{id} and PUT /me, and an
invitation and its resend — is refused 422 INVALID_FIELD. Past 24 hours a key is judged as
new.
The orders owner’s codes are under Orders, the algos owner’s under Algos, the risk limits’ under Risk limits.
Retrying
error.retryable is the answering member’s verdict on the refusal it sends: true when
sending the identical request again — the same Idempotency-Key included — after
Retry-After or a short pause, can succeed with nothing else changed. These are the
conditions that clear:
It is false for every other refusal, where something has to change first — the request,
its key, its precondition, the caller’s standing, or the platform’s own records: a 428 asks
for the If-Match the request lacked, a 409 or a 412 for a read before the next write, not
for the same write again, and a 422 for a name the platform does not hold yet waits for the
record, not for a resend.
Nine codes under a 429 or a 503 do not follow their status. Eight state how the service is
deployed, and are false wherever only a change to the deployment clears them; the ninth
is a record owner’s refusal:
A refusal a record owner judged is never retryable, whatever its status: it is a fact on the
stream and the recorded answer to its Idempotency-Key, so that key sent again replays it —
the flag included — with Idempotent-Replay: true. RATE_CEILING is the only one under a
status that otherwise clears. A refusal at the door journals nothing: where the flag is
true the identical request goes again under its key, and a corrected request may reuse the
key whatever the flag says (Writes has the rule).
Orders
POST /orders submits, POST /orders/{id}/cancel cancels, GET /orders and
GET /orders/{id} serve orders, and GET /executions and GET /executions/{id} serve
fills — one immutable economic event each (a bust or a correction is its own row), joined to
their order by orderId (?orderId= narrows), fills not yet attributed to an order
included. The four reads need orders:read, which orders:trade carries by implication
(Capabilities). An order’s cumQty and avgPx derive from its executions. The order surface has
one view, and an order’s ETag is its own version.
- The key is the client order id. On
POST /orderstheIdempotency-Keyis the order’sclientOrderId: 1 to 36 characters of the key grammar. A bodyclientOrderIdmay restate it, never contradict it. A retried key replays or attaches like any key, and one that reaches the platform afresh (after a member restart) restates the same order — the same key can never mint a second order; another user’s key is 409CLIENT_ORDER_ID_CONFLICT. - Name the instrument by
instrumentIdor byinstrument, the platform symbol ("OKX@BTC/USDT"): at least one, and both stated must agree (400). The gateway resolves the symbol before anything is sent and served rows carry the id — symbols are reference data’s to change, the id is the stable address. An instrument that is not held is 422INSTRUMENT_NOT_LIVEby either spelling: the orders owner answers it to an id it does not hold — a fact on the stream, with the position header, and the key (yourclientOrderId) is spent, so retry under a fresh one — and the gateway answers it to a symbol it cannot resolve to an id: nothing sent, no position header, and the same key retries fresh.price(LIMITonly; absent,nullor"0"forMARKET) andqtycross at their own scale, and the owner aligns them to the instrument’spriceScaleandqtyScalebefore its checks — a value off the tick or the step is its refusal, never the door’s. - Name the account by
accountIdor byaccount, its display name within your organisation ("okx-main"): the same rule, spelled the same way — at least one, and both stated must agree (400). The gateway resolves the name before anything is sent, so only the id crosses: a name is your organisation’s to change, and a command carrying one would name a different account after a rename. A name no live account of your organisation holds is 422ACCOUNT_NOT_ACTIVEat the door — nothing sent, no position header, and the key retries fresh; the orders owner answers the same code, as a fact, to an id it will not trade. An account still being classified has no bound name yet and is addressable by id alone. The WebSocket door takes the same alias, resolved through the same rule, so one submit body serves both lanes. - An account no key’s orders land in is refused 422
CREDENTIAL_UNAVAILABLE: an OKXfundingaccount, or a sub-account’s wallet read through the main account’s key. The order would execute in the key’s own trading account while booked to the account you named, so no key can place it for that account. Such an account’scapabilities.tradeisnull(Connection health says how to read it); trade a sub-account through its own key’stradingaccount. - A retried key replays, whatever its names resolve to now. The gateway’s 422 for a symbol
or a display name stands only for a key the member answering it holds no answer for. A retry
of a key it already holds answers as any retry does — the order placed, or the platform’s
refusal of it, replayed with
Idempotent-Replay: true; a submit still being carried, attached — even after the account was renamed or deactivated, or the member stopped holding the symbol. After the gateway’s 422, fix the name and retry under the same key: it is yourclientOrderId, so a retry under it can never place a second order, and a fresh key can. - The accept answers the
QUEUEDrow (200) or the platform’s refusal. The gateway pre-checks nothing else: the orders owner’s validation chain answers, with the observed value against the limit and the governing trading policy inerror.message. isReduceOnly(since0.57.0) places an order that may only reduce the account’s position: the venue holds it to the position it reduces — trimming, rejecting or cancelling the excess, depending on the venue — and never lets it add. Accepted on the venues’ derivatives that take it (the linear perpetuals and futures of OKX, Bybit and Binance USD-M; the WebSocket gateway’svenueCapabilitychannel says where, per product type) and refused 422UNSUPPORTED_AT_VENUEeverywhere else — spot has no position to reduce.- The account’s risk posture (Risk postures) is enforced at admission,
right after the order’s fields are checked (since
0.57.0).NORMALchanges nothing. UnderHEDGE_ONLYan order is admitted only if it reduces the account’s risk, else 409RISK_HEDGE_ONLY: when the posture comes from a breach on complete data (itsarma leverage limit orMARGIN_EQUITY_FLOORwith anobservedvalue, itsrateQualityPRIMARY), an order on any instrument is admitted if, for each coin it touches other than cash, the account’s exposure comes out smaller in size whatever its sign — a sell of 5 BTC of the quarterly against a 10 BTC perpetual long passes, and so does one that takes +10 past zero to −3, but not to −15 — counting your live orders on the same side, so two hedges cannot together overshoot. The exposure is the one the breachedarmmeasures: forGROSS_LEVERAGE_NO_SPOTandNET_LEVERAGE_NO_SPOT, your derivative positions alone — a 10 BTC short perpetual held against 10 BTC of spot reads −10, so buying the perpetual back passes — and a spot order, which those arms do not measure, never does; forGROSS_LEVERAGE_WITH_SPOTandMARGIN_EQUITY_FLOOR, derivatives together with the holdings in the venue’s margin wallets — coins in another wallet (OKXfunding) are not counted. Two exceptions are judged as cuts instead: an inverseMARKETorder, which states no price, so its exposure cannot be sized; and an order on an instrument the platform cannot yet value (its coin not in the risk figures — seeunsupportedInstrumentson the record), which counts toward no limit. When the data is in doubt (DATA_QUALITY,UNEVALUABLE, a fallback rate), only a cut passes: a derivative order withisReduceOnlyon a venue that takes it; on a derivative venue that does not, an order that stays within the account’s position, net of your live orders on the same side; a spot sell within the account’savailablebalance; or a spot buy that repays a borrowed short of the coin (a margined account’s negative balance), within what is owed net of your live buys of it. UnderBLOCKEDonly a cut is admitted — never a hedge — and from a breach on complete data a cut must shrink the exposure too; anything else is 409RISK_LIMIT_BREACHED. Either refusal’serror.messagestates the posture’sobservedagainst itsthreshold(a leverage multiple, or USD for the floor). Cancels are never refused for the posture. A reducing order relieves the posture when it fills, not when it rests: the posture moves on the record the fill produces. - Cancel is never gated — not on the reference price, not on the venue connection, not
on a trading halt — and takes no
If-Match(a stated one is 400): a cancel must never lose a version race. The accept answers the row withcancelRequestedAtNsset and the status unchanged; the venue confirms asynchronously andCANCELEDarrives later as an ordinary order update. “Is a cancel in flight” is a live status with a non-nullcancelRequestedAtNs; there is no pending-cancel status. Refused for 404UNKNOWN_ORDER, 422ORG_MISMATCH, 409ORDER_TERMINALor 409ORDER_STATUS_UNKNOWN(an order whose status this member cannot interpret). - Who placed it:
actoris the submitting principal — a member (USER) or an API key (API_KEY) — and is never restamped: a cancel’s actor rides the cancel, not the row. An order the platform’s autonomous algos placed carriesalgoInstanceId(the instance) and the platform’s own actor (MACHINE); a member’s or a key’s order carries the principal andalgoInstanceIdnull. ReadalgoInstanceId != nullas “an algo’s order”. A member or a key of the organisation may cancel such an order exactly as any other. - Money on orders: every value states its own scale on the wire (a
Decimal, since orders schema111.v1) and is served at exactly the scale the value itself states, with no reference data consulted: prices (price,avgPx,lastFillPx,fillPx), quantities (qty,cumQty,leavesQty,lastFillQty,venueCumQty,fillQty) and a fill’sfeeeach render every fractional digit the platform recorded — so the digit count you see is the precision that value states, never a width derived from the instrument or asset. A refusal’sobserved … against limit …legs inerror.messageare the decimals the owner stamped, each at the scale it states.
The orders owner’s refusals, by status (the full set is the OrderRejected.reason enum):
FILL_PRECISION_OVERFLOW is in the OrderRejected.reason enum and in no response of yours:
the orders owner answers it to a connector’s progress report, never to POST /orders or a
cancel. It means a venue stated a fill at a precision the order cannot hold in a 64-bit
integer — the fill was refused whole, never rounded to fit, and the platform’s operators are
paged; none is expected. You meet it only if you read refusals off the platform’s stream.
Balances
GET /account-balances serves your organisation’s latest observed balance per
(account, wallet, asset) — what each of your accounts holds at its venue, in each wallet the
venue keeps under the account, as the venue states it —
to a caller who reads accounts (accounts:read, or any accounts capability:
Capabilities).
The platform does not keep these books: its account connector polls the venue on the
account’s key and republishes each reading as a measurement (the custody domain’s
AccountBalance, schema 115), keyed latest-wins — a reading is superseded by the next and
never corrected, and a venue that stops reporting a wallet simply leaves its last reading in
place. Every row carries:
accountId,wallet,assetId,credentialId— the references.wallet(since0.61.0) is the wallet inside the venue account the reading is of, as the venue names it —tradingandfundingat OKX,unifiedat Bybit,spotat Binance; the value set is the venues’ own, open-ended: render it, never predict it. What an account owns in an asset is the sum of its wallets’ rows; what it can trade is the venue’s order wallet alone (tradingat OKX).credentialIdis the account’s own key the reading was taken through. A balance row carries no venue, symbol or classification of its own:GET /accounts/{id}names the venue, the keys and the account’s classification, and reference data names the asset. To view balances by classification (exchange treasury, hot vs cold), join the two collections onaccountId— both are your organisation’s whole set.total,available,held— the venue’s stated holding, what may move now and what the venue has locked (available + held = totalonly where the venue’s model is additive), decimal strings at the scale the reading itself states, served at exactly that scale with no reference data consulted — so the digit count you see is the precision the platform recorded, never a width derived from the asset.availableis what the venue would let move now (a withdrawal or transfer semantic — never “usable as margin”: collateral eligibility and haircuts are the venue’s own gates),heldwhat the venue itself has locked (order margin, pending withdrawals, venue-side freezes), andtotalthe load-bearing arm. Additivity (total = available + held) holds only where the venue’s model is additive. Zero is a measurement: the three are required and nevernull.unrealizedPnl— the unrealized PnL the venue counts insidetotal, a decimal string at the reading’s scale (since0.51.0). A venue that reports a trading wallet’s equity as its total — unrealized PnL of the wallet’s open positions included — states it beside; subtract it fromtotalfor the wallet’s cash.nullwhere the venue’stotalleaves unrealized PnL out, or where the reading predates the field — an account connector not yet on the release that states it, whosetotalmay still include the wallet’s unrealized PnL. Sototal − (unrealizedPnl ?? 0)is the cash only once every account connector states the field;"0"(at the reading’s scale) is a reading, not an absence.observedAtNs— the platform time of the reading (epoch nanoseconds, a decimal string, nevernull): the row’s own clock. The connector republishes a wallet’s reading on every change and restates every wallet on a heartbeat grid regardless (every 30 s by default), for as long as it serves the key that reads the account — the venue answering or not — and the clock stops when that lane stops. It does not tell a changed reading from a restated one, and it is not the account’s freshness: that is the account row’sreadAtNs(Connection health), the one clock to age.venueUpdatedAtNs,venueRevision— the venue’s own stamp on the balance and its sequence, where it states them (nullwhen it does not). The stamp is the venue’s as-of for the state it reported, never freshness on this platform: the holding’s change time where the venue stamps that (OKX), the account’s update time where it stamps that (Binance), the answer’s time where it stamps only that (Bybit) — as it stood at the latest observation of the wallet, so it can move without the holding moving and stand still while the platform reads the holding every 30 s. A reader that ages it calls an idle OKX account stale and a Bybit one fresh; read it for what the venue said about the state, and for nothing about this platform.
The collection is your organisation’s by construction: a reading names its account, the
account row names the organisation, and a reading whose account the member does not hold
(or another organisation’s) is indistinguishable from absent. Readings arrive once the
account’s reading key is ACTIVE and the account is live — a PENDING_APPROVAL connection
has none yet, and a DISABLED account’s stop with its lanes — through the key that reads
the account (Connection health). ?accountId= narrows to one
account’s wallets (a positive int32; an account outside your organisation, or one with no
reading yet, yields an empty collection). Rows are ordered by accountId, wallet then
assetId. The surface is one (?view=approved is 400), there is no entity route and no
ETag — the key is the triple and a reading carries no version — and the position header
moves on every reading, restatements included: treat X-Immix-Global-Sequence as the
consistency token it is, not as a change flag.
Where the surface is off. A member deployed without the balance surface — an environment
into which no account connector publishes readings yet — answers this route
503 BALANCES_UNAVAILABLE after admission, whatever the query, with no position header;
every other route is unaffected. It is the environment’s posture, not a transient: it clears
when the environment gains its connector, never by retrying, so a client that renders
balances shows “not available here” on it rather than an empty table.
Positions
GET /positions (since 0.52.0) serves your organisation’s derivative positions, one row
per (account, instrument) a fill has opened, to a caller who reads orders (orders:read, or
any orders capability: Capabilities) — a position is built from the fills
GET /executions already shows you, so it needs no grant of its own — or reads risk
(risk:read, or any risk capability, since 0.54.0). The platform derives
it: every fill, bust, correction and late attribution on ExecutionRecorded moves the row as
the venue keeps a position, and a venue’s busted or corrected fill rewinds the row and replays
it without that fill, or with its corrected values. It is the platform’s books, not a venue’s
report — compare it with the venue’s own figures, never assume they are one source. Spot
fills move no position: a spot holding is a balance (Balances). Every row
carries:
accountId,instrumentId— the key, the pair together;GET /accounts/{id}names the account’s venue, reference data the instrument.family— how the position is held:LINEAR(futures and perpetual swaps margined in the quote),INVERSE(coin-margined), orUNSUPPORTED— an instrument type the platform does not value (an option, a quanto, an instrument it holds no definition for), whose row keeps the raw contract count and statesnullfor every figure below that it could not compute. The value set is append-only: read an unknown value asUNSUPPORTED.qty— the signed position (positive long, negative short, zero flat) in units no contract definition can change: coins for a linear contract, USD face value for an inverse one.contractsis the count, derived fromqtyat the instrument’s current definition and never stored: when a venue changes a contract’s size,contractsfollows the venue’s count andqtydoes not move. On aLINEARorINVERSErow it isnullwhere the member holds no definition for the instrument; anUNSUPPORTEDrow always states its raw contract count, equal toqty, with or without a definition.cost,realizedPnl— insettleAssetId(the quote for a linear contract, the base coin for an inverse one where the instrument states no settle asset), at the price scale for a linear row and to the satoshi for an inverse one.costis signed with the position and is zero when flat;realizedPnlis cumulative since the position first opened and gross of fees.avgPxis the average entry price —cost ÷ qty(linear),qty ÷ cost(inverse) — rounded half-even to the price scale;nullwhen flat.funding— funding paid or received on the position since it first opened, insettleAssetId, positive when the account received it; cash besiderealizedPnl, never part of it or ofcost, and kept when the position returns to zero.nullforUNSUPPORTED.fees— the fees charged on the position’s fills, cumulative, one entry per fee asset (assetId,amount), a rebate negative.lastCause,lastExecutionId,lastFillTsNs,lastSeq— what last moved the row (FILL,BUST,CORRECTION,ATTRIBUTION, orMANUAL_ADJUSTMENTandFUNDING, which name no execution and leavelastExecutionIdon the last fill), the execution it was, when that fill happened at the venue (nullwhen the venue stated no time), and the platform stream position of the move. The page’s position is taken before its rows are read, so a row that moved meanwhile can carry alastSeqabove the page’sglobalSequence— the row is then newer than that position, never older.
A position that returns to zero keeps its row, its realized PnL and its fees: flat is a state, not an absence. Nothing is valued here — no mark and no unrealized PnL: those belong to the platform’s risk valuation, which this version does not serve per position. Every amount is a decimal string at the scale the row holds it (Money).
The collection is your organisation’s by construction, through the account as a balance’s
is: a position whose account the member does not hold, or another organisation’s, is
indistinguishable from absent. ?accountId= and ?instrumentId= narrow it (any of); rows are
ordered by accountId then instrumentId, or as sort (accountId, instrumentId,
lastSeq) asks. The surface is one (?view=approved is 400), there is no entity route and no
ETag.
Where the surface is off. A member deployed without the positions surface answers this
route 503 POSITIONS_UNAVAILABLE after admission, whatever the query, with no position
header; every other route is unaffected. It is the environment’s posture, not a transient:
show “not available here”, never an empty book.
Risk
GET /risk/records and GET /risk/exposures (since 0.54.0) serve the platform’s
valuation of each account — what it holds and owes, valued under one policy — to a caller
who reads risk (risk:read, or any risk capability; orders:read alone is refused 403
CAPABILITY_DENIED). Both are the platform’s own books, published by its risk owner and
served as last published: a read never re-values anything.
The record — one row per account, keyed by accountId:
nlvUsd— net liquidation value in USD: every valued asset the account holds at its rate, plus the unrealized PnL of its derivative positions. An asset with no USD rate that nothing open depends on (an airdrop, dust) is left out, and flaggedunvaluedon its exposure row. It counts every wallet the account holds.marginEquityUsd— the same, over the account’s margin wallets alone: at OKX the trading account, at Bybit the unified account, at Binance the spot and USD-M wallets together. It leaves out money a venue does not margin, such as OKX’s funding wallet. Binance margins USD-M on its own wallet, so a Binance figure also counts the spot wallet beside it. The leverage figures divide by it and the floor guards it.unrealizedPnlUsd,realizedPnlUsd,feesUsd,fundingUsd,transfersUsd— the PnL lines in USD. Unrealized is at the current marks and rates; realized, fees, funding and transfers are cumulative, each amount converted at its own event’s rate and never re-converted, so a later move in a coin’s price changes none of them. Realized PnL is gross of fees. Funding is each payment the venue booked and each approved funding adjustment, at its own rate; a payment is never also counted in transfers. A payment in an asset with no USD rate yet is left out until its first rate converts it, and the record is partial (isPartial) meanwhile.- The eight leverage figures —
{gross, net}×{Actual, Total}×{NoSpot, WithSpot}: per non-cash asset, the account’s USD exposure — its derivative positions’ legs, plus its holdings in the margin wallets underWithSpot, plus underTotalits resting orders on the side that would grow the exposure most — summed as absolute values (gross) or as a signed sum then absolute (net), over the margin equity: the net liquidation value of the account’s margin wallets alone (marginEquityUsd— at OKX the trading account, at Bybit the unified account, at Binance the spot and USD-M wallets together), so money parked in OKX’s funding wallet lowers no figure. Cash (USD and USD stablecoins) is never exposure. Each is a ratio to the margin equity as a decimal string at eight places:"0.42000000"is 0.42×,"6.00000000"6×. Over a margin equity barely above zero — an account at liquidation — a figure saturates at"92233720368.54775807", the largest the wire holds: read it as at least that, never as an exact ratio. isPartial,worstSource— whether some input was valued on a fallback price, left unvalued or refused, and the worst price tier any figure was valued at (PRIMARY,LKG_FRESH,LKG_STALE,MISSING). The figures stand, flagged.- Seven counters —
unsupportedInstruments,unmarkedPositions,basisResets,unmatchedCorrections,adjustments,instrumentRedefinitions,inventoryRefusals— andpositionDrift(falseuntil the venue’s own positions are compared).inventoryRefusalscounts the balances and fill legs refused because their quantity was too large to hold at the asset’s scale: each moved nothing, the record stays partial, and the count never resets.unsupportedInstrumentscounts every execution the figures refuse to value: one on an instrument type they do not value (itsGET /positionsrow readsUNSUPPORTED, its raw quantity kept), and one the venue reported with no price, which moves nothing; either keeps the record partial. balancesAsOfNs,pricedAtNs,cause,causeRef— the newest venue time of the balances folded, when the record was valued, and what moved it.
null is not 0. A figure the platform could not evaluate is null: nlvUsd when a
rate the account needs is missing (and marginEquityUsd with it); every leverage figure then,
or when the margin equity is zero or below;
balancesAsOfNs before the first balance. Show it as unknown, never as zero leverage.
When it moves. A record is published on a fill, a balance or another business event, on a
change in its data quality, when a leverage figure crosses a 0.1× step or NLV or the margin
equity moves 1 %, on a heartbeat, and whenever the account’s posture moves — then with cause
LIMIT (causeRef the limit row) when a change to the risk limits moved it — never on every
price tick. Live PnL between records is the positions’ business, not the record’s.
The exposures — one row per (account, asset): actualExposure (the holding plus every
derivative position’s leg in the asset, signed) and inventoryQty (the venue’s last restated
balance plus the account’s own fills since), each a decimal string at the scale it was stated
— never finer than the asset’s unit scale (eight places for an asset without one), whatever
digits the venue rendered;
costBasisUsd and realizedPnlUsd on the holding — null for a cash asset; rateQuality;
unvalued. A row moves on a business event touching its asset (a fill, bust,
correction, attribution, balance or adjustment) or when its rateQuality or unvalued
changes (a first rate, a feed going stale or recovering; cause VALUATION), never on a
price move within a tier: read value off the record.
Both collections are your organisation’s by construction, through the account, as positions
are. ?accountId= narrows both, ?assetId= the exposures (any of); rows are ordered by
accountId (then assetId), or as sort (accountId, assetId, pricedAtNs) asks. One
surface, no entity route, no ETag.
Where the surface is off. A member deployed without the risk reads answers both routes
503 RISK_UNAVAILABLE after admission, whatever the query, with no position header; every
other route is unaffected. Show “not available here”, never an account with no risk.
Risk limits
/risk/limits (since 0.55.0) holds the limits the platform judges each account’s
risk against. Every organisation has a default row (accountId 0), given to it
uncapped the moment it is active; an account may have its own row beside it. A row
carries seven thresholds, each a decimal string at eight places:
grossLeverageNoSpotSoft/Hard,netLeverageNoSpotSoft/Hard,grossLeverageWithSpotSoft/Hard— the leverage figures of the record, as ratios to the margin equity ("5.00000000"is 5×). Past a soft threshold the account is held to reducing its risk; past a hard one it is blocked.marginEquityFloorUsd— the margin equity in USD at or under which the account is blocked: the equity of the account’s margin wallets (marginEquityUsdabove), never its other wallets.
The thresholds are enforced through the account’s posture, which order
admission obeys (since 0.57.0): what HEDGE_ONLY and BLOCKED let through is
Orders’.
"0" is no cap; null is not stated. On an account’s row a threshold left null takes
the default row’s value, and an explicit "0" is uncapped there even where the default caps.
On the default row, which has nothing to inherit, null is no cap, as "0" is: dropping a cap
the default held is a loosening, and waits for the risk approval rule like any other.
The thresholds that govern an account are its own row’s where stated, the default’s
everywhere else.
Reads (risk:read, or any risk capability): GET /risk/limits and
GET /risk/limits/{id} serve the rows like any proposal-carrying resource — view=latest
(the default) shows a pending proposal’s thresholds, view=approved those in force, the
row’s version is its ETag, and the proposal record is the register rows’ as 0.53.0
completed it: the maker (proposedBy, an Actor, kept once the proposal concludes or is
withdrawn), pendingTransition ACTIVATE / AMEND / RETIRE, proposedAtNs, the
conclusion (concludedAtNs, concludedBy — the maker where a tightening concluded as
submitted, else the approver who met the count — and concludedTransition, what it concluded:
ACTIVATE, AMEND or RETIRE), approvals as {userId, approvedAtNs}
entries, the remark and the last withdrawal’s record (lastWithdrawalProposedBy,
lastWithdrawalWithdrawnBy); no count is stamped — the organisation’s risk rule in force is
read at each approval. updatedBy is who wrote the version: the MACHINE actor on the
default row the platform gives every organisation. Filters riskLimitId, accountId,
status, pendingTransition; sort by those, proposedAtNs, concludedAtNs and
updatedAtNs — an actor is an object no list orders by. Every actor a risk write stamps is a
member’s — the platform admits members alone to the risk writes (an API key reads the surface
by risk:read, is granted no risk:propose — 422 INVALID_FIELD at its issue or
restatement — and a risk write it sends is refused 403 CAPABILITY_MISSING, by the platform
rather than at the door); the one actor no member wrote is the default row’s updatedBy, the
MACHINE actor above.
Writes — every one takes an Idempotency-Key; the four on a row require If-Match:
A proposal is judged by its effect against the thresholds that govern the account now,
threshold by threshold, soft and hard separately. One that only tightens — a lower
leverage threshold, a higher floor, a cap where there was none — is in force as it is
submitted, by one person: stopping is never held up. One that loosens any threshold
waits for the approvals the organisation’s risk approval rule requires
(GET /approval-rules?family=RISK; Approvals lists the proposal), judged, like
every family’s, by the rule in force at each approval, and what governed the account keeps
governing meanwhile. So an account’s first row cannot
drop the default’s caps by leaving them out (they still apply) nor by raising them (that
loosens), and retiring a row is immediate when the default it falls back to is no looser.
A re-submit replaces the pending proposal and clears its approvals; the maker cannot approve
their own, nobody approves twice. The default row never retires.
The risk limits’ refusals, by status — facts on the stream, replayed for their key like every record owner’s:
A retried limit write is answered once, by the platform too. Within the 24 hours after a
limit write was answered, the platform itself remembers its Idempotency-Key (by you, the
route’s command and the key): sending the same key again — including past the gateway’s
journal window, or to a member whose rebuilt journal never saw it — returns the first answer
and changes nothing. An approval retried is never counted twice and never comes back
ALREADY_APPROVED; a proposal retried with the If-Match it first carried is not a
VERSION_CONFLICT; a create retried is the same row’s 201, never DUPLICATE_LIMIT; a
refusal retried is the same refusal, even if what refused it has changed since. The answer
shows the row as it stands now, and carries Idempotent-Replay: true only when the gateway
replayed it from its journal — any member, inside the window (since 0.82.0). Two exceptions: if you have since lost the capability
or your organisation is no longer ACTIVE, the retry is refused for that (a key replays only to
a caller still entitled to send it); and the same key sent to another row is refused 422 INVALID_FIELD. Past 24 hours a key is judged as new — use a fresh key per intended change, as
everywhere.
A member deployed without the risk limits answers every limit route 503 RISK_UNAVAILABLE,
and lists no risk item in the inbox.
Risk postures
GET /risk/postures (since 0.56.0; risk:read, or any risk capability) serves each
account’s posture — its latest record judged against the limits
that govern it, the worst limit winning — one row per account, keyed by accountId. Every
active account has a row from its first moment active.
posture—NORMAL;HEDGE_ONLY: past a soft threshold, or the record was valued on a fallback price (isPartial), or — under a configured limit — the account has no balance yet: it may only reduce its risk;BLOCKED: past a hard threshold, the margin equity at or under the floor, or a configured limit the platform cannot evaluate (a rate it needs is missing, or the margin equity is zero or below with no floor to breach): it may only cut. Order admission enforces it (since0.57.0) — what each posture lets through, and the 409 each refuses with, is Orders’; the platform’s algos are refused every placement underBLOCKEDbefore an order is sent.arm— what set it. A leverage limit orMARGIN_EQUITY_FLOORcomes withobserved, the reading when the posture changed (a ratio to the margin equity, or the margin equity in USD for the floor), andthreshold, the limit it reached — the soft one underHEDGE_ONLY, the hard one underBLOCKED.DATA_QUALITY(a partial record) andUNEVALUABLEmeasure nothing: both arenull, never0.NORMALnames no arm (UNKNOWN). Where several limits are breached at one level, one with a reading is named.riskLimitId,riskLimitVersion— the limit row the arm came from: the account’s own, or the organisation-wide default it inherits.nullwhen the posture names no row.recordPricedAtNs— thepricedAtNsof the account’s latest record published before the posture, which states the same verdict;nullbefore the account’s first record. It identifies the record, it does not fetch it:GET /risk/recordsserves only an account’s latest record, which is the one behind the posture while itspricedAtNsequals this value. Once a newer record is published the earlier one is no longer served here; theriskRecordchannel carried it when it was published.observedis the reading at the change, and may differ from that record’s figure: a record that moves the figures without moving the verdict publishes no posture.previous,rateQuality(the judged record’sworstSource),positionDrift,changedAtNs.
It moves only on a change — of the posture, its arm or the row it names, or, under
HEDGE_ONLY and BLOCKED, of the rate quality or drift. A limit change and an account turning
active re-judge at once: a tightening blocks without waiting for a fill, an approved loosening
releases at once. observed is therefore the reading at the change, not a live figure — the
live figures are the record’s.
?accountId= and ?posture= narrow the list (?posture=BLOCKED: the blocked accounts); rows
are ordered by accountId, or as sort (accountId, posture, changedAtNs) asks. One
surface, no entity route, no ETag. A member deployed without the postures answers
503 RISK_UNAVAILABLE: show “not available here”, never an account with no posture.
Risk adjustments
/risk/adjustments (since 0.58.0) holds the hand-made corrections of an account’s books:
a derivative position’s cost basis, realized PnL, a fee or its funding, or an asset inventory’s
cost basis or realized PnL in USD — never a quantity, which only a trade moves. Each is proposed by one
person and applied only once the organisation’s risk approvals are in — at least one,
whatever the rule says: a correction moves money-like figures in either direction, so it is
always dual-controlled.
An adjustment names the account and either a position’s instrumentId (GET /positions)
or an inventory’s assetId (GET /risk/exposures), and its arms, each a mode and a
decimal string:
costMode/cost,realizedPnlMode/realizedPnl— on a position in its settle asset, on an inventory in USD (at most eight places).feeMode/feewithfeeAssetId— a position’s fees in that asset.fundingMode/funding— a position’s cumulative funding, in the settle asset; refused (ARM_INVALID) on an inventory, which holds none.
SET replaces the figure, DELTA adds to it (a negative DELTA subtracts), NONE (or the
field left out) leaves it; a value is sent exactly when its mode is SET or DELTA. At least
one arm is set. reason is BASIS_CORRECTION, FEE_ASSET_CORRECTION or OTHER (which needs
a remark).
It applies as of its proposal. An approved adjustment moves the position or the inventory
as it stood when the adjustment was proposed (effectiveSeq), and every fill since is replayed
through it — so a SET basis is the basis the later fills realized against. Its record and
exposure rows move with cause MANUAL_ADJUSTMENT (causeRef the adjustment’s id), and the
record’s adjustments counter counts it. Approved after the platform has let go of the fills
it reaches back past — it keeps each fill while its order is retained, three days after the
order ends unless the venue’s retention is set shorter, and an inventory a bounded number of
its movements, so a busy one can lose them sooner — it applies to the position or inventory as it
stands, and the record’s unmatchedCorrections (a position’s) or basisResets (an
inventory’s) counts that: check the resulting figures by hand.
Reads (risk:read, or any risk capability): GET /risk/adjustments and
GET /risk/adjustments/{id}, every state of every adjustment — PENDING_APPROVAL, APPLIED,
WITHDRAWN — its version the ETag; its maker proposedBy, its withdrawer withdrawnBy
and updatedBy, who produced the state (the maker, an approver, the withdrawer), are
Actors (members’). Filters adjustmentId, accountId, status, reason; sort by
those and proposedAtNs. The id is a 64-bit integer, a decimal string. Adjustments are not
listed in Approvals yet: read
GET /risk/adjustments?status=PENDING_APPROVAL for the ones awaiting a checker.
Writes — each takes an Idempotency-Key and no If-Match (400 INVALID_IF_MATCH):
an adjustment’s state only moves forward, and the platform judges each act by it.
The adjustments’ refusals, by status — facts on the stream, replayed for their key like every record owner’s:
A retried adjustment write is answered once, by the platform too, exactly as a
limit write is: within 24 hours the same key returns the first answer and
changes nothing — a proposal retried is the same adjustment’s 201, an approval retried is
never counted twice.
A member deployed without the adjustments answers every adjustment route
503 RISK_UNAVAILABLE: show “not available here”, never an account with no adjustments.
Manual executions
/risk/manual-executions (since 0.72.0) books by hand a trade the platform never
received from a venue: a fill the connector missed or one made off-platform
(MISSED_TRADE), a position the account held before it was onboarded, at its real cost
(OPENING_POSITION), a venue liquidation or auto-deleveraging that closed contracts with no
fill (VENUE_LIQUIDATION, VENUE_ADL), a balancing trade that settles a quantity the platform
and the venue disagree on (RECONCILIATION_BREAK), or OTHER with a remark. A quantity is
always a trade — an adjustment never moves one — and a manual execution is
how a trade the stream never saw reaches the books. Like an adjustment it is drafted by one
person and booked only once the organisation’s risk approvals are in — at least one,
whatever the rule says.
A draft names the account, the instrumentId (listed at the account’s venue), the side,
qty and price as decimal strings, optionally liquidity (MAKER or TAKER) and a fee
with its feeAssetId (negative for a rebate), venueTsNs — when it traded, never after the
draft — its reason, and a reference: the venue’s trade id, or the counterparty’s or
desk’s reference, 1 to 64 printable characters.
The approval that meets the count records it. One execution appears on
GET /executions with provenance MANUAL, orderId "0", credentialId 0 and
the draft’s reference as its venueTradeId; the manual execution’s executionId names it.
The position moves as for any fill, at that moment: a missed spot fill whose coins the
balance already shows is booked as the late fill it is, the quantity counted once. Every other
execution states where it came from too — ACK, PUSH, QUERY or SWEEP, the connector’s
evidence — and an unattributed fill also has orderId "0": read provenance to tell a
booking by hand from a fill awaiting attribution.
One reference, one trade. The account must hold no execution of the instrument under the
reference already — from a connector, or a live draft’s: such a draft is 409
REFERENCE_TAKEN and nothing is created — when another live draft holds the reference, look at
it before drafting again. If a connector delivers the trade after the draft, or another draft
under the reference is recorded first, the approval that would record it is 409
REFERENCE_TAKEN too, and the draft stays pending for its maker to withdraw: the trade is on
the books once.
Reads (risk:read, or any risk capability): GET /risk/manual-executions and
GET /risk/manual-executions/{id}, every state — PENDING_APPROVAL, RECORDED, WITHDRAWN
— its version the ETag; its maker proposedBy, its withdrawer withdrawnBy and
updatedBy, who produced the state (the maker, an approver, the withdrawer), are Actors
(members’). Filters manualExecutionId, accountId, status, reason; sort by
those, proposedAtNs and venueTsNs. The id is a 64-bit integer, a decimal string. Manual
executions are not listed in Approvals: read
GET /risk/manual-executions?status=PENDING_APPROVAL for the ones awaiting a checker.
Writes — each takes an Idempotency-Key and no If-Match (400 INVALID_IF_MATCH).
The manual executions’ refusals, by status — facts on the stream, replayed for their key like every record owner’s:
A retried manual-execution write is answered once, by the platform too, as an adjustment’s is: within 24 hours the same key returns the first answer and changes nothing — an approval retried never books a second execution.
A member deployed without the manual executions answers every manual-execution route
503 RISK_UNAVAILABLE.
Connection health
A key row records what was decided about a key: submitted, approved, suspended,
deleted. Approval is not service. An ACTIVE key is one the platform may use, and
whether a connector is using it is a separate reading, which every key row carries as
health — on GET /accounts/{id}/keys and GET /accounts/{id}/keys/{keyId}, on both
views (behind venue-keys:read, as the rows are), on the answers of the key commands, and on
each entry of the account row’s keys[] (below). One key can be served by two connectors — the venue’s
account connector reads its balances, its order-entry connector places its orders — and each
reports on its own session, so health holds one reading per connector role:
health.account and health.trading (the CredentialHealthReadings schema). A key
that only reads balances is never served by an order-entry connector, so its health.trading
stays null; read the reading for the role you depend on. Each reading is:
null— that connector has not reported on the key. On anACTIVEkey whose flags call for the role (canReadBalancesforaccount,canTradefortrading) this is the case to act on: it is approved, and nothing is using it.- A report — the latest one (the
ConnectionHealthschema), each superseding the last:status—CONNECTED(serving),DEGRADED(serving, impaired) orDOWN(not serving: dialing, redialing, or refused by the venue).UNKNOWNis a status newer than the gateway can name; treat it asDOWN.role— the connector that reported,ACCOUNTorORDER_ENTRY: the reading’s own slot, carried on the report so it stands alone.exchangeId(since0.62.0) — the exchange the connector serves the key on: the key’s own, or a further market its key trades (Binance USD-M,102, for a Binance key). A key that trades more than one market has an order-entry connector for each, andhealth.tradingis the worst of their readings (DOWNbeforeDEGRADEDbeforeCONNECTED);exchangeIdsays which market it is.reason— why:NONEwhen nothing is wrong, otherwise the cause (AUTH_FAILED,IP_NOT_WHITELISTED,RATE_LIMITED,VENUE_MAINTENANCE, …).STARTUPis a lane’s first dial and the session it opens — aDOWNwith it is a key coming up for the first time, with no verdict yet;RECONNECTis every later dial and session, a redial after a drop or after a dial that failed — aDOWNwith it is a lane that has failed or dropped at least once.reportedAtNs— the platform time of the latest report, and the clock to judge freshness from. A serving connector restates its report on a heartbeat (every 30 s by default), soreportedAtNsadvances while a connector serves the key and stalls when none does: aCONNECTEDwhosereportedAtNshas stalled is a connector that stopped without saying so.transitionAtNs— the platform time the currentstatusbegan. Restatements leave it, and so does a change ofreasonalone, so the time since it is how long the key has been in this status.sinceNs— when the current status and reason began, on the connector’s own clock;venueRoundTripNs— the latest round trip to the venue,nullwhen not measured;detail— what the connector or the venue said, for people: display it, do not parse it.
health is observed, not decided: it changes without the key’s version moving, so
the ETag and If-Match never involve it, and it reads the same on view=latest and
view=approved. Each report moves the position (X-Immix-Global-Sequence), as every change
does.
Who reports. Every connector that uses a key reports on it, each under its own
role: the venue’s account connector fills health.account for every key whose account is
live — while the account is DISABLED its lane parks and the reading says DOWN with
ACCOUNT_DISABLED until the account returns — and its order-entry
connector fills health.trading for a key that trades. An order-placing connector reports on a
key once it has opened a session for it, which it does once an ACTIVE account trades through
the key — until then health.trading is null — and health.trading reads DOWN whenever
that session cannot place orders: while it connects, logs in and reconciles the account’s open
orders, and while the venue refuses its key (reason says which, for example AUTH_FAILED).
An order on an account whose trading key reads DOWN on the order’s market is refused
CONNECTION_DOWN; on a DEGRADED one it is admitted for as long as the trading policy’s
degradedGraceNs allows, counted from transitionAtNs. For a Binance key, admission reads the
order’s own market: a USD-M outage refuses USD-M orders and leaves spot orders admitted, even
though health.trading shows the outage.
The keys beneath an account. Since 0.61.0 an account’s keys are its own — created with
it, listed under it, deleted with it — and every account read (GET /accounts,
GET /accounts/{id} on both views, and the answer of every account command) carries them as
keys[] (the AccountKeys schema): the account’s live keys, ascending by keyId, each
as the view reads it (since 0.65.0: on the latest image the key’s latest image, so a pending
change shows; on ?view=approved as enforcement reads it — its approved record, else its
latest for a key never approved; the two agree while nothing pends) — with version (the
key’s own, what If-Match names on the key’s routes), name (since 0.70.0), trade and
transfer (the roles it holds; at most one live key per role sits beneath an account),
canReadBalances and canServeAddresses (since 0.70.0), status and
pendingTransition (a key stated at the connection rides the account’s activation, and every
later change to a key the account’s KEY_CHANGE), health (both readings, as the key’s own
row serves them), observed (what
the probe read at the venue: permissions, allowlist, outcome — NONE for a clean
answer, UNKNOWN until one, else why it failed — and probedAtNs), keyIdSuffix (the venue
key id’s last four characters), fingerprint, createdAtNs and rotateByNs (since 0.70.0;
null when no deadline is set) — the four of 0.70.0 completing the fields an amend moves
(trade carried canTrade already), served on the image the view reads so that an approver
without venue-keys:read reads the change in
the inbox (Approvals); a deleted key is no key of the account.
GET /accounts/{id}/keys/{keyId} serves the whole row — the venue key id, the venue’s own
permission and allowlist text, the probe’s detail — behind venue-keys:read. Beside them the row
carries two readings (ConnectionReading: {status, reason, readAtNs}), the venue’s word
beside the status — never a status, which is what an administrator decided —
connection, the account’s reading through the key that reads it, and trading, the
order-entry connector’s reading on its trading key (null when no key trades the account):
CONNECTING until anything has answered on the key; then the probe’s verdict, CONNECTED
where it answered clean or DOWN with its reason where it did not (IP_NOT_WHITELISTED —
add the address at the venue; AUTH_FAILED; PERMISSION_DENIED; ACCOUNT_EXISTS — another
live account of your organisation already holds that venue account, so this one reads no
balances and places no orders, its trading reading DOWN with the same reason: delete the
duplicate, or delete the other account and this one takes over at the next re-probe),
which the periodic re-probe recovers from once the venue answers, no re-submit; then the
connector’s latest report (CONNECTED, DEGRADED, DOWN with its reason — ACCOUNT_DISABLED
while the account is disabled, CONFIG_ERROR while the key serves another venue account than
the account names, both ids in the detail of that key’s health.account in keys[]: rotate it
onto a key of the account’s own venue account; a transfers key can also be deleted, a reading
key only with its account). A connector reports a dial in flight as DOWN with reason
STARTUP, and the report that opens a lane’s outage with one — its transitionAtNs and
reportedAtNs equal, the register stamping both on the fact that begins a status and holding
the first across every later report under it — counts as none while the probe’s verdict is
clean or absent: the reading stays CONNECTED, or CONNECTING. A key whose probe was refused
gets no such grace — its readings are DOWN either way, and the refusal may be stale by the
time a lane redials (an allowlist fixed since, the lane connected for days) — so the dial
reads as made, DOWN with reason STARTUP, and the refusal stays on the key’s row in keys[].
Every later report counts — the drop or refusal that ends the dial,
a redial’s STARTUP after it, a dial still in flight when the connector restates it a
heartbeat later — so a lane that never connects reads DOWN through its redials; the key’s
own health keeps every report as made, its two clocks telling an opening dial from a redial.
connection is null once the account is DELETED. The row’s
capabilities (the AccountCapabilities schema) is derived from keys[] the same way:
trade is the account’s own key where it trades — with that key’s status and its
health.trading reading — and transfer its dedicated transfers key, with the key’s status
and its health.account reading (the account connector executes transfers); each null where
no key beneath the account holds the role: a trade of null is an account nothing can trade
(POST /orders refuses 422 CREDENTIAL_UNAVAILABLE, Orders), a transfer of null
reads can’t transfer: add a transfers key. A pending change to a key changes none of this
until it is approved. And parentAccountId: on a sub-account — one whose key’s probe stated
a parent (parentExternalRef, the venue’s id for it, observed and never set by a member) —
your organisation’s row for that parent, else null; derived at the read, never recorded. Like
health, every one of these is derived, not decided: it changes with the keys’ records and
their readings without the row’s version moving, so the ETag never involves it, and it
reads the same on both views.
The account’s freshness. Every account row — GET /accounts, GET /accounts/{id} on both
views, and the answer of every account command — carries readAtNs: when the account was
last read at its venue, as the platform time of the latest report from the account connector
serving the key that reads the account — its own reading key while that key is ACTIVE,
else its transfers key, standing in for a suspended reading key (one rule, the connector’s
own; keys[] and capabilities name them) — whose health.account.reportedAtNs it is
(connection.readAtNs is the same clock) while that report says the lane’s sweeps read
every wallet: CONNECTED, or DEGRADED for any reason but RATE_LIMITED and
VENUE_UNAVAILABLE — a lane degraded by its push stream alone, the stream stale
(STREAM_STALE) or refused past its grace, whose every sweep still reads every wallet. It is
null while the report is DEGRADED as RATE_LIMITED or VENUE_UNAVAILABLE — the poll’s own
verdicts: its sweeps read some of the lane’s wallets or none, a venue refusing every sweep with
429s or one wallet’s endpoint failing while another answers — since nothing in the report says
when the account was last read cleanly (a lane that redials after a DOWN reports CONNECTED
before its first sweep answers, so even the time the degradation began can postdate an outage
with no clean read between); a stream refused as RATE_LIMITED reads like the poll’s verdict
and reads null too. And a status’s first report — the one whose reportedAtNs equals its
transitionAtNs — is no read: a lane that comes up reports CONNECTED before its first sweep
answers, so readAtNs stays null until a later report under the same status (the next
heartbeat restatement, 30 s on by default, the first sweep leaving at once) says the lane held
it; every move into a reading status costs a heartbeat of null, and a redial during an outage
never reads fresh. It is null while the report says DOWN or no connector
has reported on the key — and null once the account is DELETED, however its key’s lane
fares: nothing reads a deleted account, so its last readings stand, never refreshed. It is the one clock to
age for an account, and it answers one question — is this account being read now? It
advances on the connector’s heartbeat for as long as the account is read, so a time that
stops advancing is a connector that stopped without saying so, and null is a report that
establishes no clean read of the account — nothing reads it, or a partial sweep may have read
its wallet without the report able to say so — the key’s health.account saying why (DOWN or
DEGRADED with its reason, or no report at all). Nothing on a balance row says it: observedAtNs moves on every heartbeat the
connector serves the key, the venue answering or not, and venueUpdatedAtNs is the venue’s
own stamp on the state it reported, which can move without the holding moving
(Balances). Like health and capabilities, it is derived, not decided: it
changes without the row’s version moving, so the ETag never involves it, and it reads the
same on both views.
Who reads an account. Its balances are read by its own reading key while that key is
ACTIVE; while it is suspended, the account’s dedicated transfers key reads in its stead when
it is ACTIVE (every exchange key reads balances), so suspending the reading key never freezes
the balances of an account that goes on trading, and the reading key reads again when it
returns. Each balance on GET /account-balances names the key that stated it
(credentialId). An account whose only key is suspended is not read until the key returns;
no account is read through another account’s key — a sub-account is connected with a key of
its own, and nothing lists, offers or reads through a parent.
Algos
An algo instance is a strategy the platform runs for your organisation: created from a
loaded algo version (the catalog, GET /algos/versions — the platform’s, not yours:
every version per engine pool with its manifest and the JSON Schema its documents must
conform to) with a config document, started and stopped by your users, placing orders of
its own. Its orders are machine flow — algoInstanceId set, the MACHINE actor — and
GET /algos/instances/{id}/orders is exactly its rows, in the OrderUpdated shape of
Orders. Everything under /algos needs algos:manage for the writes and
algos:read for the reads — which algos:manage carries by implication and the Admin preset
spells (Capabilities) — scoped to their organisation.
Instances and documents. GET /algos/instances lists the instances its terminal state has not reached, in id order — DELETED ones left out unless include=deleted or a status filter asks (Reads, since 0.39.0); GET /algos/instances/{id} serves one with its
attribution — createdBy, and lastUpdatedBy with lastCause and lastCommandKind, each
an Actor: null with CONFIG_APPLIED, ENGINE_FAULT, DIVERGED or STRATEGY when the
engine, the platform’s own rule or the instance’s own algo moved it, a member or an API key with COMMAND or HALT — its
upgradePolicy (below), and an
ETag: "<configSeq>", the sequence number of its latest document. The documents are the
instance’s history: GET …/configs (oldest first) and …/configs/{seq}, each the JSONC text
as submitted — a name in it reads as the id it named, the name beside it as a comment (below)
— its outcome (STAGED until the engine judges it, then APPLIED or REFUSED with
the engine’s detail), outcomeAtNs (null while staged), who submitted it and when, and
the accountIds and instrumentIds the platform projected from it. The algos reads have
one surface (?view= other than latest is 400) and no status filter; another
organisation’s instance is 404 everywhere, indistinguishable from an absent id.
A new version of an instance’s algo. When the engines of an instance’s pool load a new
version of its algo, the instance moves to it: algoVersionId names the new version,
transitionSeq advances, lastUpdatedBy is null and lastCommandKind
REPORT_ALGO_VERSIONS, and lastCause says what the new version did by the instance’s
upgradePolicy — VERSION_RESUMED (RESUME, the default: its orders kept, its state
resumed on the new version), VERSION_RESTARTED (RESTART: its orders cancelled, started
afresh) or VERSION_STOPPED (STOP: its orders cancelled, a STARTED instance STOPPED) —
or SCHEMA_MISMATCH when the new version’s params schema refuses the instance’s document
(its applied one; for a CREATED instance, its latest submitted one),
whatever the policy: the instance lands ERROR, unless it is still CREATED, which it stays.
To recover an ERROR instance, submit a document the new schema takes, then stop it and start
it — a start while the refused document is still the one in force is refused with the schema’s
reason; a CREATED one needs only the document, and once the engine accepts it the instance is
STOPPED, ready to start. Under RESUME, a new version that cannot read the state its
predecessor saved never starts the instance silently afresh: a STARTED one lands ERROR
after its move, with lastCause ENGINE_FAULT and its orders cancelled, and a STOPPED one
lands ERROR the same way at its next start; stop it, then start it, to run it afresh.
Whenever the engine replaces an instance’s strategy — a RESTART move, or a start after
ERROR — the new strategy’s client order ids continue from the next multiple of a trillion
(a<instanceId>-1000000000000 and up), so they never repeat its predecessor’s, and no event of
a predecessor’s order reaches it. The policy is set at the create (upgradePolicy, optional,
RESUME when absent or null) and changed by POST /algos/instances/{id}/upgrade-policy
(below). Engines running a release before 0.78.1’s ignore it, and you can see it:
after a VERSION_RESTARTED or VERSION_STOPPED move the instance’s new client order ids
continue below a<instanceId>-1000000000000, its saved state is lost under any policy, and one
with resting orders at the move is contained for good — lastCause DIVERGED, ERROR (or
STOPPED under STOP), its orders cancelled — recovered only by a new instance.
The create. POST /algos/instances with algoVersionId, pool, displayName and
document — and an optional upgradePolicy (above) and, as on every algos write, an optional
remark (below) — creates the instance with its first document in one request.
The document is one JSON string holding JSONC — comments allowed, one object, typed by
the version’s schema — and the door holds it to the platform’s bound of 6,144 bytes of
UTF-8: past it, 413 DOCUMENT_TOO_LARGE with nothing sent; everything else about the
text is the platform’s to judge (422, naming the field — the table below). On every algos
write the Idempotency-Key is the command’s commandKey (1 to 64 of [A-Za-z0-9._~-];
a body commandKey is refused 400, as a body actor is), and
on the instance routes a body instanceId must equal the path’s. The remark — why the
change is made, at most 256 bytes of UTF-8, recorded with it — is optional on every algos
write: absent, null or "" is no remark, and past 256 bytes it is 422 INVALID_FIELD. A
key names one operation here as everywhere (Writes): reused on another algos
route — a halt after a create, a stop after a start — or on another instance, it refuses 409
IDEMPOTENCY_KEY_REUSED while the journal remembers it. The create answers 201
with the row once both the instance and its document (configSeq 1) are recorded — or 202
with Location: /operations/{key} past the deadline, like every write (Writes);
the operation record’s outcome then carries the instanceId and configSeq the pair
minted, and a retry of the key replays the 201 with Idempotent-Replay: true. A new
instance is CREATED until the engine applies its document, then STOPPED.
Naming an account or an instrument. Wherever the version’s schema types a reference
("format": "account" or "format": "instrument"), the document may state an id — a JSON
number — or a name, a JSON string: an account’s display name in your organisation, an
instrument’s platform symbol (OKX@BTC/USDT) — the names POST /orders accepts, resolved the
same way (surrounding spaces trimmed, then exact; "700" is a name, never the id). The
gateway resolves each name when the create or the config write arrives and sends the document
with the name replaced by its id, the name kept beside it as a comment where it fits:
is staged, and read back, as
Every other byte — your comments, the layout, the other values — is kept as you wrote it. A
name is resolved once: renaming the account later never moves the running instance, and
submitting the document again resolves it again — the staged document’s
accountIds/instrumentIds show what it named each time. Ids are your environment’s, so
keep documents with names in your own source and submit them to each environment, rather
than copying a staged document across. A name nothing here holds is 422
REFERENCE_UNKNOWN_ACCOUNT or REFERENCE_UNKNOWN_INSTRUMENT from the gateway itself —
nothing sent, nothing journaled, the key free for a retry; the message names the value’s
path and the name. So is an instrument the document states by an id nothing here holds
(REFERENCE_UNKNOWN_INSTRUMENT: fix the reference), or one held but not open to trading
(REFERENCE_INSTRUMENT_NOT_LIVE: wait for reference data to reopen it) — the gateway judges
every instrument reference before sending, for a version this member holds (a version it has
not yet heard reported crosses as written, as before), and the order path refuses a placement
on a closed instrument regardless. The
6,144-byte bound holds as written and as sent: a document that fits as
written but not once its names are ids is 413 DOCUMENT_TOO_LARGE (the comments are dropped
before that happens). A retry of a key the member answering it already holds replays its answer
whatever its names resolve to now: a refusal answers only a key’s first attempt. A version this
member has not caught up with yet — one loaded a moment ago — sends the document as written,
and the platform refuses its names 422 FIELD_TYPE_MISMATCH — a fact, so the key is spent:
once GET /algos/versions lists the version, retry under a new key.
Re-configuring. PUT /algos/instances/{id}/config with document (and an optional
remark) stages a new document — legal in every state but DELETED, while the instance
runs too — under If-Match: "<configSeq>", the instance’s ETag, required as on every
entity write: absent is 428 PRECONDITION_REQUIRED, * the explicit unconditional, a weak
validator is 400 INVALID_IF_MATCH, and a stale one is 412 CONFIG_SEQ_CONFLICT with
currentVersion and a fresh ETag — re-read, reapply, retry. It answers 200 with the
staged document (no ETag: a document carries no version); the engine’s verdict is a
later state on …/configs/{seq}, and until it lands a second write is 409 CONFIG_PENDING.
A refused document leaves the applied one in force.
Start, stop, delete, halt. POST /algos/instances/{id}/start, /stop and /delete
take an optional { remark } ({}, or no body at all, is a complete request) and no
If-Match — one refuses 400 INVALID_IF_MATCH: stopping is the safe direction, and no
version race may lose it — and answer 200 with the row. start needs a STOPPED instance
whose document is applied and whose algo its pool still loads (by name, under whatever version
the pool now holds — else 422 VERSION_NOT_ON_POOL), and a document in force its version’s
params schema takes: after a SCHEMA_MISMATCH a start is refused 422 with the schema’s reason
(FIELD_MISSING, …) until a document the new schema takes is applied; stop takes a
STARTED or ERROR one (the engine cancels its live orders as the change applies); delete
is a verb route rather than the DELETE method, so the key and an optional remark ride as on
every write, and is terminal — the row and its documents stay readable, the id is never
reused, its orders keep naming it; a started instance stops first. POST /algos/halt, with
the same optional body, stops every started instance of your organisation, in id order, and
answers 200 with count — 0 when nothing was started, so the call always has an answer.
An algo that stops itself. An algo may decide its work is done — a parent order filled,
an inventory limit reached — and stop on its own (since 0.79.0). The instance moves
STARTED → STOPPED with lastCause STRATEGY, lastCommandKind
REPORT_ALGO_INSTANCE_STOP and lastUpdatedBy null; its live orders are cancelled and its
timers disarmed, as at your stop. It keeps its state: start resumes it where it stopped.
When your stop or halt crosses it, whichever the platform records first stands: yours, and the
instance is STOPPED under your COMMAND or HALT; the algo’s, and your stop is refused 409
ILLEGAL_TRANSITION (the instance is already STOPPED) and a halt does not count it. The row
says that the algo stopped it, not why.
The upgrade policy. POST /algos/instances/{id}/upgrade-policy with
{ "upgradePolicy": "RESUME" | "RESTART" | "STOP" } — the policy required, an optional
remark beside it — changes what a new version of the instance’s algo does to it (above). It
takes the key and the body rules of the other instance actions and, like the stop, no
If-Match (one refuses 400 INVALID_IF_MATCH), so no version stamp can refuse it. A pool’s
roll takes the policy in force when its report completes: set the policy, and see it answered,
before the pool rolls — a set sequenced after the roll applies to the next one. It is legal in every state but DELETED (409 ILLEGAL_TRANSITION),
and it is not a move: it answers 200 with the row carrying the new upgradePolicy, every
other field — status, transitionSeq, the attribution, the ETag — as it was. The policy
parses strictly: absent, null, UNKNOWN or a name the API does not know is 400
MALFORMED_REQUEST, nothing sent.
Where the surface is off. A member deployed without the algos surface — an environment
whose algos owner has not established yet — answers every /algos route 503 ALGOS_UNAVAILABLE
after admission, with no position header; every other route is unaffected. It is the
environment’s posture, not a transient, exactly as BALANCES_UNAVAILABLE is.
The algos owner’s refusals, by status (the full set is the AlgoRejected.reason enum; the
message carries the detail — the field’s path, the capability, the current sequence number):
Versioning
info.versionis the version of this document — semver, hand-bumped in the same change as the changelog section that describes it. A break is a route, field, code, enum member or generated identifier removed, renamed or retyped, a parameter made required, or a served value changed so that a request built from it as the previous document allowed is refused (0.84.0’s absoluteLocation,0.85.0’sLocationcarryingminGlobalSequence): a major from1.0.0, the first customer pin, and until then a minor headed!, the changelog saying which (0.40.0is the first such removal). A minor is a route, field or enum member added (regenerate: a closed enum type gains a member). A patch is prose, and behaviour inside the published shapes and code set short of a break — what a value is served as, which requests the door refuses, and a constraint keyword that writes such a rule into the schema once the door already enforces it, as0.4.1’smaxLengthdid. Whatever the part, the changelog says what each side of the deploy window sees, and the newest section of the changelog is always headed by the served version.- No deprecation window. Until
1.0.0a route or member a minor replaces or removes goes in that minor, as the roles routes did in0.40.0, never kept beside its successor:0.44.0removed the last aliases, the routes0.37.0’s vocabulary replaced (/suspend,/reactivate,/retire,/freeze,/unfreeze,/revoke) — generate from the newest document and call what it publishes. info.x-immix-register-schema,info.x-immix-orders-schema,info.x-immix-custody-schemaandinfo.x-immix-algos-schemaname the platform wire schemas the message shapes derive from (114.v24,111.v4,115.v3,121.v3): every schema undercomponents.schemasthat shares a name with a message (CredentialUpdated,SubmitOrder,AccountBalance,CreateAlgoInstance, …) is generated from that schema, and those schemas are append-only from1.0.0(before it a break may reshape them, in a minor headed!as above) — an appended property carriesx-since-schema-version.- Generated clients. The document is written to be generated from: one row schema per
resource (
CredentialRow, …) that its read and its writes share, anoperationIdon every operation, named types for the capability scopes and the preset names (Capability,CapabilityPresetName), and an openError.code. Regenerate before you meet a new minor.