> 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

Credential types and headers for Titan API requests.

Titan accepts two credential types. The one you use depends on how you obtained access.

|                   | Developers Portal                                             | Distributor                                                             |
| ----------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------- |
| Credential        | API key                                                       | JWT                                                                     |
| Header            | `x-api-key: <key>`                                            | `Authorization: Bearer <jwt>`                                           |
| Query alternative | —                                                             | `?auth=<jwt>`                                                           |
| Host              | `portal.api.titan.exchange`                                   | Endpoint supplied by Triton or QuickNode                                |
| Interfaces        | REST                                                          | REST (Titan Gateway); WebSocket (Titan Direct) for enterprise customers |
| Obtain from       | [developer.titan.exchange](https://developer.titan.exchange/) | Your distributor                                                        |

{% hint style="warning" %}
Credentials are not interchangeable. An API key sent to a distributor endpoint, or a JWT sent to `portal.api.titan.exchange`, returns `401`. Match the credential to the host.
{% endhint %}

## Developers Portal — API key

Send the key in the `x-api-key` header on every request:

```
x-api-key: <your key>
```

Keys are created at [developer.titan.exchange](https://developer.titan.exchange/) and scoped to an organization. Key verification, handling and rotation are covered in [Developers Portal → Authentication](/titan/developer-doc/developers-portal/authentication.md).

## Distributor — JWT

Distributor access uses a **JSON Web Token (JWT)** issued by Titan or a Titan distributor. Submit it one of 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 is not possible (for example, 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 credentials in client-side code.** Set up a middleware proxy that injects the token or key server-side. See the [middleware example](https://github.com/Titan-Pathfinder/titan-sdk-ts/blob/main/examples/middleware.ts) for a basic reference.
{% endhint %}

{% hint style="info" %}
If a distributor connection drops unexpectedly, check the token's expiration first. An expired JWT is the most common cause of distributor authentication failures.
{% endhint %}

## Getting credentials

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