Connect to WebSocket
Connect to Tachyon WebSocket notifications using registered WebSocket credentials.
Endpoint
GET wss://tachyon.rath.fi/wsThis endpoint requires a WebSocket upgrade and cannot be called with the documentation's HTTP request client.
Authentication
Send the WebSocket key returned by POST /api/user/register-websocket in the connection header:
x-ws-token: YOUR_WEBSOCKET_KEY| Header | Required | Description |
|---|---|---|
x-ws-token | Yes | Persistent, user-specific WebSocket key returned during registration. |
Connection Response
| Status | Description |
|---|---|
101 Switching Protocols | WebSocket connection established. Messages are streamed over the upgraded connection. |
| Unauthorized | The x-ws-token header is missing or invalid. The server sends an unauthorized message and closes the socket. |
Connection Workflow
- Register WebSocket credentials using
POST /api/user/register-websocket. - Read
data.wsUrlanddata.apiKeyfrom the registration response. - Connect to
data.wsUrlwithdata.apiKeyin thex-ws-tokenheader. - Keep the connection open to receive transaction status notifications.
Use the URL returned by registration instead of hardcoding it. A successful upgrade returns 101 Switching Protocols; notifications are then delivered as WebSocket messages rather than HTTP response bodies.
Complete Example
response=$(curl -s -X POST "https://tachyon.rath.fi/api/user/register-websocket" \
-H "Authorization: Bearer YOUR_JWT")
WS_URL=$(echo "$response" | jq -r '.data.wsUrl')
WS_API_KEY=$(echo "$response" | jq -r '.data.apiKey')
websocat -H="x-ws-token: $WS_API_KEY" "$WS_URL"Credential Behavior
- The WebSocket key is persistent, user-specific, and reusable across connections.
- It authenticates WebSocket connections only; it is not a Tachyon transaction API key.
- Send it in the
x-ws-tokenheader. Query-parameter authentication is not supported. - Keep it server-side where possible and revoke it if exposed.
Message Format
Connection Confirmation
Tachyon sends an initial message after authenticating the connection.
{
"message": "WebSocket connected!"
}Transaction Notification
Status changes are sent directly as transaction payloads without an event, type, or data wrapper.
{
"txId": "68fa3450539a3c9d28bbca33",
"chainId": 8453,
"status": "EXECUTED",
"costUSD": 0.8400561743999754,
"totalNativeTokenUsed": "1000000000000000",
"gasPrice": "1000000000",
"txHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
"submittedAt": "2025-10-23T13:57:36.672Z",
"updatedAt": "2025-10-23T13:57:39.172Z",
"retries": 0
}Notification Fields
| Field | Description |
|---|---|
txId | Tachyon transaction identifier. |
chainId | Numeric chain ID where the transaction was submitted. |
status | Current transaction status. |
costUSD | Recorded execution cost in USD. |
totalNativeTokenUsed | Native token amount used for execution. |
gasPrice | Gas price recorded for the transaction. |
txHash | On-chain execution transaction hash, when available. |
submittedAt | Time the transaction was submitted to Tachyon. |
updatedAt | Time the transaction status was last updated. |
retries | Number of execution retries. |
Client Message Echo
If the client sends a message, Tachyon returns it as an echo response.
{
"echo": "client message"
}Transaction Status Values
| Status | Description |
|---|---|
NOT_PICKED_UP | Transaction was accepted but has not yet been picked up for execution. |
PENDING | Transaction is being processed. |
EXECUTED | Transaction successfully executed on-chain. |
FAILED | Transaction execution failed. |
NEEDS_TO_BE_RETRIED | Transaction will be retried automatically. |
Message Handling Examples
Filter Transaction Notifications
websocat -H="x-ws-token: $WS_API_KEY" "$WS_URL" | \
jq 'select(.txId != null)'Monitor Specific Transaction
TX_ID="68fa3450539a3c9d28bbca33"
websocat -H="x-ws-token: $WS_API_KEY" "$WS_URL" | \
jq --arg txid "$TX_ID" 'select(.txId == $txid)'Extract Execution Hashes
websocat -H="x-ws-token: $WS_API_KEY" "$WS_URL" | \
jq 'select(.status == "EXECUTED") | .txHash'Monitor Transaction Costs
websocat -H="x-ws-token: $WS_API_KEY" "$WS_URL" | \
jq 'select(.txId != null) | { txId, cost: .costUSD }'Connection Management
Using wscat
wscat -c "$WS_URL" -H "x-ws-token: $WS_API_KEY"Using websocat
websocat -H="x-ws-token: $WS_API_KEY" "$WS_URL"Use Cases
- Real-time dashboard: stream transaction status updates into an operations view.
- Failure alerts: detect
FAILEDorNEEDS_TO_BE_RETRIEDstatuses as they happen. - Execution tracking: capture
txHashimmediately after execution. - Cost reporting: aggregate
costUSDand native-token usage from notifications.
Troubleshooting
Authentication Failed
Make sure the WebSocket API key is sent in the x-ws-token header.
Connection Closed
Reconnect when the socket closes.
while true; do
websocat -H="x-ws-token: $WS_API_KEY" "$WS_URL"
sleep 5
doneNo Messages Received
Verify that the WebSocket connection is established, the API key is valid, and transactions are being submitted for your account.