> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsidemax.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticating a WebSocket Connection on Upside

> Send an Auth message over WebSocket to associate your connection with an account and unlock private channel subscriptions on Upside.

Authenticating your WebSocket connection tells the server which account the connection belongs to. While some private channels currently accept an account address directly in the subscription parameters, sending an `Auth` message first is the recommended pattern — it ensures your connection is ready for all private streams and is required for any future access-controlled features.

## Sending the Auth message

After opening the WebSocket connection, send the following JSON frame:

```json theme={"system"}
{"msg": "Auth", "accountId": 3}
```

<ParamField body="msg" type="string" required>
  Must be the fixed string `"Auth"`. This identifies the message type to the server.
</ParamField>

<ParamField body="accountId" type="number" required>
  Your numeric account ID. This is the value returned by the `registerAccount` action — not your wallet address.
</ParamField>

## Server response

The server replies with an `AuthResult` frame on the same connection:

```json theme={"system"}
{"msg": "AuthResult", "success": true, "accountId": 3}
```

<ResponseField name="success" type="boolean">
  `true` if the authentication was accepted. `false` if the `accountId` was not found or was invalid.
</ResponseField>

<ResponseField name="accountId" type="number">
  Echoes back the `accountId` from your request so you can correlate the response in async handlers.
</ResponseField>

## Error response

If authentication fails, the server returns a `success: false` result:

```json theme={"system"}
{"msg": "AuthResult", "success": false, "accountId": 999}
```

Check that the `accountId` was registered on-chain via `registerAccount` before retrying.

## After authenticating

Once you receive `"success": true`, you can subscribe to any channel — including `orderUpdates`, `openOrders`, and `userFills` — and the server will associate those streams with your account context.

<Note>
  Private channels (`orderUpdates`, `openOrders`, `userFills`) currently accept the account address directly in the subscription `user` field without requiring prior `Auth`. However, authenticating first is strongly recommended for forward compatibility — the access model may tighten in future releases.
</Note>

<Tip>
  Re-send your `Auth` message immediately after every reconnect, before re-subscribing to any channels. This keeps your connection authenticated without any gap in coverage.
</Tip>
