> For the complete documentation index, see [llms.txt](https://titan-exchange.gitbook.io/titan/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://titan-exchange.gitbook.io/titan/developer-doc/getting-started/authentication.md).

# Authentication

The Titan API uses **JSON Web Tokens (JWTs)** for authentication. Every connection requires a valid token issued by Titan or a Titan distributor.

## Submitting your token

You can submit your JWT in two ways:

As a **Bearer token** in the `Authorization` header — the recommended approach for server-side integrations:

```
Authorization: Bearer <your-jwt>
```

As a query parameter — for browser clients or environments where setting custom headers isn't possible (e.g. WebSocket clients that only support [`Sec-WebSocket-Protocol`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Sec-WebSocket-Protocol)):

```
wss://YOUR_ENDPOINT/api/v1/ws?auth=<your-jwt>
https://YOUR_ENDPOINT/api/v1/quote/swap?auth=<your-jwt>
```

{% hint style="warning" %}
**Do not expose your JWT in client-side code.** Set up a middleware proxy that injects the token server-side. See the [middleware example](https://github.com/Titan-Pathfinder/titan-sdk-ts/blob/main/examples/middleware.ts) for a basic reference — you can build your own middleware to fit your stack and authentication flow.
{% endhint %}

{% hint style="info" %}
If your connection drops unexpectedly, check your token's expiration first — an **expired token is the most common cause** of authentication failures.
{% endhint %}

## Getting a token

See [Get API Access](/titan/developer-doc/getting-started/api-access.md).
