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

# Authentication

> API keys and JWT access tokens

## API Key (recommended)

Generate an API key from the [Datagate dashboard](https://platform.getdatagate.com). Keys start with `dg_live_` and are shown once — store it securely.

<CodeGroup>
  ```python Python theme={null}
  from datagate import DatagateClient

  client = DatagateClient(api_key="dg_live_...")
  ```

  ```typescript TypeScript theme={null}
  import { DatagateClient } from "datagate";

  const client = new DatagateClient({ apiKey: "dg_live_..." });
  ```

  ```bash curl theme={null}
  curl -H "Authorization: Bearer dg_live_..." \
    https://api.getdatagate.com/v1/datasets/discover
  ```
</CodeGroup>

## JWT Access Token

If you authenticate via the login flow (email + 2FA), you receive a 15-minute JWT access token. This is primarily used by the dashboard, but SDKs accept it too:

<CodeGroup>
  ```python Python theme={null}
  client = DatagateClient(access_token="eyJhbGciOiJIUzI1NiJ9...")
  ```

  ```typescript TypeScript theme={null}
  const client = new DatagateClient({ accessToken: "eyJhbGciOiJIUzI1NiJ9..." });
  ```
</CodeGroup>

Both methods use the same `Authorization: Bearer <credential>` header. The SDK does not handle login or token refresh — the caller provides a valid credential.

## Key Management

| Action          | Endpoint                   | Notes                                          |
| --------------- | -------------------------- | ---------------------------------------------- |
| Generate/rotate | `POST /v1/auth/api-keys`   | Replaces any existing key. Raw key shown once. |
| Revoke          | `DELETE /v1/auth/api-keys` | Deletes key, no replacement.                   |

Manage your API key from the dashboard under **API Keys**.

## Environment Variables

For MCP servers and CI/CD, set your key as an environment variable:

```bash theme={null}
export DATAGATE_API_KEY="dg_live_..."
```
