Skip to navigation

Authentication

URL — No public environment serves this socket yet.

Credentials

ticket

Sent as query parameter ticket

The browser’s credential. A browser cannot send an Authorization header on the WebSocket handshake, so it first exchanges its bearer for a ticket with the REST API’s POST /ws-tickets ({"stream": "trading"}, answered {"ticket", "expiresAtNs", "stream"}), then opens the WebSocket with ?ticket=<ticket> on its URL, the ticket unchanged: it is URL-safe as served. One of the two schemes, never both.

  • One ticket, one session, soon. A ticket opens one session, once, and only before expiresAtNs: 10 seconds after it is created by default, or your token’s expiry if that comes first. Create a new ticket for every connection attempt, a reconnect included; a ticket you used, or one refused at the handshake, opens nothing.
  • It is a credential. It carries your identity, so treat it like your token: the answer that carries it is Cache-Control: no-store, and nothing should log the ticket or the URL that carries it.
  • The session lasts as long as your credential, not the ticket. The session a ticket opens ends at your token’s expiry; renew the credential over the open socket with op: auth. A ticket an API key created opens a session that ends with the key — disabled, deleted or rotated — never with a clock.
  • Creating one is admitted like any other REST call. A credential that does not verify is 401 and a principal the platform refuses 403, so a refused principal never gets a ticket — and, unlike a refused handshake, a browser can read why: stop on either. A token with no expiry cannot create one (401): a ticket never opens a session that outlives its token. An API key, which states no expiry, can.
  • Creating one is limited to 60 a minute per principal — a member or an API key. Past it, POST /ws-tickets answers 429 RATE_LIMITED with Retry-After; a malformed request does not count.
  • POST /ws-tickets answers 503 TICKETS_UNAVAILABLE when the REST API member you reached holds no ticket signing key, so a retry there changes nothing — unlike the handshake’s 503, which is retried. A browser cannot open this socket until the REST API serves tickets; any other client sends its bearer token on the handshake instead.
  • No Idempotency-Key. A replayed answer would hand a retry the same single-use ticket, so every call mints a new one.
  • From a browser on another origin, the call needs your origin on the REST API’s list: each deployment grants cross-origin access (CORS) to the exact origins it lists, and from any other origin the browser refuses the call — make it through your backend instead.

bearer

Sent as header Authorization: Bearer … (JWT, or an API key’s immix_<keyId>_<secret>)

Every other client’s credential on the handshake, as Authorization: Bearer …: a member’s access token, stating an expiry — or an API key’s immix_<keyId>_<secret>, which states none and whose session ends with the key. One of the two schemes, never both.

Create a WebSocket ticket

REST API POST /ws-tickets

Exchanges your bearer for a ticket that opens one WebSocket stream once — trading or market-data, as the body names it; the other refuses it. An API key’s opens trading alone (403 FORBIDDEN_PRINCIPAL). Pass it as ?ticket= on that URL before expiresAtNs. It carries your identity and never outlives a token; never cache or log it. No Idempotency-Key: every call mints a new one.

Request parameters

ParameterTypeRequiredDescription
streamstringYesThe WebSocket stream the ticket opens: trading (the trading WebSocket) or market-data (the market-data WebSocket). One of trading, market-data.

Response parameters

ParameterTypeRequiredDescription
ticketstringYesOpaque and URL-safe as served: put it in the WebSocket URL as ?ticket= unchanged, and never parse it. It opens one session, once.
expiresAtNsstringYesWhen the ticket stops opening sessions, in epoch nanoseconds: the ticket’s lifetime, or your token’s expiry if that comes first (an API key states none, so its ticket runs the whole lifetime). Open the WebSocket before then, or create another ticket.
streamstringYesThe stream the ticket opens, as the request named it. One of trading, market-data.

Refusals

StatusDescription
400Refused at the door — nothing reached the platform and the key was not journaled: a missing or malformed Idempotency-Key, a malformed If-Match (an absent one is 428 PRECONDITION_REQUIRED), malformed JSON, a body actor (or userId, its spelling before the actor), a body restating the path or If-Match differently, a money string off its pattern (an exponent, a plus sign, a bare point, surrounding whitespace) or past its maxLength, or one no value here can state (over 18 fractional digits, or past a 64-bit integer at its own scale), or any other value outside the schema.
401No bearer token, or one that does not verify.
403CAPABILITY_DENIED: a read your capabilities do not cover, or a staging route without its propose bit (accounts:propose). NOT_REGISTERED: no row or open invitation at your verified address, an unknown organisation, or an unclaimed row (an administrator admits it). EMAIL_UNVERIFIED: verify, then sign in again. INVITATION_EXPIRED: an administrator re-invites. FORBIDDEN_PRINCIPAL: no org_id, a non-ASCII ref, a disabled user, a binding with no user. ORG_NOT_ACTIVE: disabled, pending or deleted. Owners’ 403s carry the position header and Idempotent-Replay.
429Shed at once: INBOX_FULL or IN_FLIGHT_FULL (this member’s bounds; nothing queued, the key not journaled), the intake’s or the ticket route’s RATE_LIMITED, or the orders owner’s RATE_CEILING (the organisation’s per-minute ceiling — a refusal on the stream, replayed like any, so its retryable is false and the order goes again under a fresh key). Retry-After says when.
503This member cannot mint tickets now: NOT_PRIMED — it is still catching up; retry shortly — PROJECTION_BEHIND — behind your minGlobalSequence; retry after Retry-After — or TICKETS_UNAVAILABLE — it holds no ticket signing key, so a retry here changes nothing: a browser cannot open a WebSocket through this member until it serves tickets, and any other client sends its bearer token on the WebSocket handshake instead.

The session is open and authenticated

The first frame of every session, sent before the client says anything — unless something changed between the handshake and this frame, when the first frame is sessionClosing instead: PRINCIPAL_REVOKED (4003, not retryable) when access was revoked, SESSION_EXPIRED (4001, retryable) when the API key was rotated (reconnect with the current secret) or the session was announced too late to be served. The session was authenticated on its handshake, so there is no auth to ack, and this carries what the ack carries — the grant, never the grantee. Subscribe straight away. To renew the credential before expiresAtNs, re-auth over the open socket with op: auth, for the same principal; its answer is authAck. On an API key’s session expiresAtNs is null: nothing to renew, and the session ends with the key.

ParameterTypeRequiredDescription
eventstringYessessionOpened
msgTypestringYessessionOpened
dataobjectYesWhat this session may do and until when — the grant, never the grantee: no identifier rides it. Read at admission and fixed for the session: the gates themselves read the register’s row at each frame, so a grant withdrawn since refuses the next subscribe or write, and one withdrawn from a channel the session watches closes it (4005).
> capabilitiesarray of stringsYesScope strings in choice order — the same vocabulary as the HTTP lane’s GET /me, published here as an enum rather than promised in prose. Shape your affordances from these, never from a token claim.
> expiresAtNsstring, nullableYesWhen this session’s credential lapses and the session is closed — the token’s exp, which every token states. Null on a session an API key opened: a key states no expiry, and the session ends when the key is disabled, deleted or rotated (sessionClosing), or when you close it; sessionExpiring never fires for it.

Re-authenticate the session

Op auth

The in-band re-auth: a session is authenticated on its handshake (a ticket or a bearer token), and this op renews its credential over the open socket — answer the sessionExpiring hint with it, or schedule it off expiresAtNs. It is never the way in: from 1.4.0 a handshake without a credential is refused, so no session ever owes it. The answer carries the GRANT, not the grantee — what this session may do and until when, with no identifier in it, because the client presented the token and already knows who it is.

A session may re-auth with a fresh credential for the SAME principal, which renews its lease. A credential naming a different principal is refused FORBIDDEN_PRINCIPAL and the session keeps the one it was opened with: the identity is immutable for the life of the socket. An API key’s session owes no re-auth — nothing on it lapses — and one with the key’s own bearer is answered like any other.

Request parameters

ParameterTypeRequiredDescription
opstringYesauth
reqIdstringYesEchoed byte-exact on the answer. Printable ASCII, escape-free; anything else answers MALFORMED.
paramsobjectYes
> tokenstringYesThe bearer token, verbatim.

Response parameters

The grant, never the grantee. capabilities are the register row’s bits — not token claims, so they reflect what an administrator has granted rather than what was true when the token was issued — read at admission and fixed for the session. An administrator clearing one does not change an open session’s grant: re-auth over the socket to pick up the new set. expiresAtNs is when the session closes; schedule a re-auth off it rather than decoding the token.

ParameterTypeRequiredDescription
opstringYesauth
reqIdstringYesEchoed byte-exact on the answer. Printable ASCII, escape-free; anything else answers MALFORMED.
successbooleanYestrue
sessionobjectYesWhat this session may do and until when — the grant, never the grantee: no identifier rides it. Read at admission and fixed for the session: the gates themselves read the register’s row at each frame, so a grant withdrawn since refuses the next subscribe or write, and one withdrawn from a channel the session watches closes it (4005).
> capabilitiesarray of stringsYesScope strings in choice order — the same vocabulary as the HTTP lane’s GET /me, published here as an enum rather than promised in prose. Shape your affordances from these, never from a token claim.
> expiresAtNsstring, nullableYesWhen this session’s credential lapses and the session is closed — the token’s exp, which every token states. Null on a session an API key opened: a key states no expiry, and the session ends when the key is disabled, deleted or rotated (sessionClosing), or when you close it; sessionExpiring never fires for it.

Refusal parameters

ParameterTypeRequiredDescription
opstringYesThe op being answered, or “error” when it could not be read.
reqIdstring, nullableYes
successbooleanYesfalse
codestringYesA closed enum, but tolerate an unknown value: codes are appended as the surface grows, and retryable tells you what to do whatever the code says. The door’s codes — INVALID_*, UNKNOWN_INSTRUMENT, UNKNOWN_ACCOUNT, UNKNOWN_ORDER, NOT_SERVING, OWNER_ABSENT, BACKPRESSURE — arrived in 1.1.0 beside the ops that write, and are the whole of what that version added here. A client generated against 1.0.0 meets them the first time it sends a write. UNAUTHENTICATED is not emitted from 1.4.0: every session is authenticated on its handshake, so no op can arrive before authentication. It stays in the set, which is append-only. NOT_REGISTERED (retryable: false) arrived in 1.5.0 — a minor, as 1.2.0 was for capabilityScope: a typed client’s refusalCode enum gains a member, so regenerate, or keep the default arm this description asks for. The register holds no claimed row for the principal: its organization is not registered on the platform, its subject binds no row and this socket claims no invitation (a first sign-in claims one on the HTTP lane — GET /me, or the ticket mint), or its row is one nobody has claimed. AWAITING_ADMISSION is not emitted from 1.5.0: the door discovers nobody, so there is no admission to await; it stays in the set. OWNER_ABSENT is reserved and not emitted by this version: when the orders owner is not established, a write refuses NOT_SERVING today. It is published so that a client’s handling of it is written once rather than added later, but do not expect to observe it before a release says otherwise. FORBIDDEN_CAPABILITY answers a subscribe from 1.7.0 as well as the two writes: the session’s principal holds no capability of the named topic’s family — the family’s <family>:read, or any verb of it — and failedTopicIndex names the entry. Not retryable: a grant on the register row clears it, never a resend. One of NOT_PRIMED, UNAUTHENTICATED, SESSION_EXPIRED, RATE_LIMITED, MALFORMED, UNKNOWN_OP, INVALID_TOKEN, FORBIDDEN_PRINCIPAL, ORG_NOT_ACTIVE, AWAITING_ADMISSION, FORBIDDEN_CAPABILITY, UNKNOWN_TOPIC, TOPIC_NOT_ACTIVE, TOO_MANY_TOPICS, INVALID_FIELD, INVALID_PRICE, INVALID_QTY, INVALID_CLIENT_ORDER_ID, UNKNOWN_INSTRUMENT, UNKNOWN_ACCOUNT, UNKNOWN_ORDER, NOT_SERVING, OWNER_ABSENT, BACKPRESSURE, NOT_REGISTERED.
messagestringYesDisplay text. May change between versions; never parse it.
retryablebooleanYes
failedTopicIndexintegerNoPresent on a topic refusal: the zero-based index into params.topics AS SENT of the entry that caused it.

This session’s credential lapses soon

Sent once per credential, one lead time before the lapse. Re-auth over the open socket with a fresh credential for the same principal and keep your subscriptions; renewing re-arms the hint. It exists because a client that schedules its own refresh may simply not be running when its timer fires — a throttled background tab — where an inbound frame is something the browser will deliver.

ParameterTypeRequiredDescription
eventstringYessessionExpiring
msgTypestringYessessionExpiring
dataobjectYes
> expiresAtNsstringYes
> inMsintegerYes