WebSockets
Real-time balance, transaction, KYC and IBAN updates via WebSocket.
Connect to the IBEx WebSocket endpoint to receive real-time push notifications for balance changes, new transactions, KYC/IBAN status updates, and more — without polling.
Endpoint
Append ?blockchainId=<chainId> to target a specific chain (e.g. wss://api.ibex.fi/ws?blockchainId=421614).
If omitted, the server uses the default chain.
Browsers cannot set custom headers on
new WebSocket(). Use the query parameter for chain selection.
Authentication
WebSocket connections require JWT authentication. After opening the socket, send a single JSON message:
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "auth" |
token | string | Yes | JWT obtained from POST /v1.2/auth/sign-in or /v1.2/auth/refresh |
clientName | string | No | Label for monitoring and debugging |
The server verifies the JWT and resolves the user's Safe wallet on the target chain. On failure, an auth_error message is returned.
Quick start
Initial data sequence
After successful authentication, the server automatically sends the following messages in order:
| # | Message type | Content |
|---|---|---|
| 1 | auth_success | Safe address and confirmation |
| 2 | balance_data | Current token balances |
| 3 | transaction_data | Recent transaction history |
| 4 | chainid_data | Default and supported chain IDs |
| 5 | recovery_data | Social recovery status |
| 6 | user_data | User profile, signers, safes, IBAN info |
No explicit request is needed — data is pushed automatically.
Server → client messages
All messages are JSON with type, data, and timestamp (ISO 8601).
auth_success
auth_error
balance_data
Sent after auth and in response to get_balance.
balance_update
Pushed when the wallet balance changes on-chain.
new_transaction
Pushed when a new transaction is detected on-chain.
transaction_data
Full transaction list, sent after auth or in response to get_transactions.
chainid_data
recovery_data
user_data
user.iban.updated
Pushed when an IBAN status changes.
user.ky.updated
Pushed when the KYC status changes.
error
Generic error for failed requests.
Client → server messages
Once authenticated, you can request data on demand.
get_balance
Server responds with balance_data. If requestId is provided, it is echoed in data.requestId.
get_transactions
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "get_transactions" |
requestId | string | No | Echoed in the response for correlation |
params.limit | number | No | Max transactions to return |
params.startDate | string | No | Filter start date (ISO format) |
params.endDate | string | No | Filter end date (ISO format) |
Server responds with transaction_data.
Keep-alive
The server sends a WebSocket ping every ~30 seconds. Standard clients reply with pong automatically — no action required.
Error handling & reconnection
| Close code | Meaning | Action |
|---|---|---|
| 1006 | Abnormal closure | Reconnect with backoff |
| 1008 | Policy violation / invalid JWT | Refresh token, then reconnect |
| 1011 | Server error | Wait and reconnect |
Recommended reconnection strategy:
HTTP fallback
When WebSocket is unavailable, use these REST endpoints with Authorization: Bearer <token>:
| Purpose | Method | Endpoint |
|---|---|---|
| Balances | GET | /v1.2/users/me/balances |
| Transactions | GET | /v1.2/users/me/transactions |
| User data | GET | /v1.2/users/me |
Pass X-Blockchain-Id: <chainId> header to target a specific chain.
Best practices
- Authenticate immediately — send the
authmessage as soon asonopenfires. - Use
clientName— helps identify connections in monitoring and debugging. - Use
requestId— correlate on-demand requests with their responses. - Exponential backoff — cap reconnection delay at 30 seconds with a max attempt count.
- Clean up — close the socket on logout or when the component unmounts.
- Secure connections — always use
wss://in production.