> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.paradex.trade/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.paradex.trade/_mcp/server.

# Authentication

To access private channels in the Paradex WebSocket API, you must authenticate your connection. This page explains how to authenticate your WebSocket connection using a JWT token.

## Authentication Process

Authentication is required to subscribe to private channels. The JWT (bearer) token is obtained from the `POST /auth` endpoint of the REST API.

**Important**: After the initial authentication, you do not need to re-authenticate your WebSocket connection for the lifetime of the connection.

### Authentication Request

To authenticate your WebSocket connection, send an authentication message with the following format:

```json
{
  "jsonrpc": "2.0",
  "method": "auth",
  "params": {
    "bearer": "YOUR_JWT_TOKEN"
  },
  "id": 0
}
```

### Authentication Parameters

| Parameter | Type   | Description | Required |
| --------- | ------ | ----------- | -------- |
| bearer    | string | JWT token   | Yes      |

### Authentication Response

Upon successful authentication, you will receive a response similar to:

```json
{
  "jsonrpc": "2.0",
  "result": {
    "node_id": "a1b2c3d4e5f6g7h8"
  },
  "usIn": 1682556415569005368,
  "usDiff": 1291796,
  "id": 0
}
```

## Example: Authenticating a WebSocket Connection

The auth request and its response are JSON-RPC text frames in both encodings. The SDK sends them for you and negotiates SBE for any public channels the same connection subscribes to:

```python
import asyncio

from paradex_py import Paradex
from paradex_py.api.ws_client import ParadexWebsocketClient
from paradex_py.environment import TESTNET


async def main():
    paradex = Paradex(
        env=TESTNET,
        l1_address="0xYOUR_L1_ADDRESS",
        l2_private_key="0xYOUR_L2_PRIVATE_KEY",
    )
    ws_client = ParadexWebsocketClient(env=TESTNET, sbe_enabled=True)
    ws_client.init_account(paradex.account)
    await ws_client.connect()
    print("Authenticated")


asyncio.run(main())
```

If you implement the handshake yourself, send the `auth` request shown above as a text frame, and remember to append the SBE parameters to the connection URL so public channels are not silently delivered as JSON.

## Authentication Errors

If authentication fails, you will receive an error response. Common authentication errors include:

| Error Code | Description            |
| ---------- | ---------------------- |
| 40110      | Malformed Bearer Token |
| 40111      | Invalid Bearer Token   |
| 40112      | Geo IP blocked         |

For more information on error handling, see the [Error Handling](/ws/general-information/error-handling) section.