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

# API Keys

> Authenticate your requests to the Datadash API.

Every API request must be authenticated with an API key, sent in the `X-Api-Key` header.

```bash theme={null}
curl -X POST https://api.datadash.xyz/api/v1/positions/active \
  -H "X-Api-Key: $DATADASH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"page": {"limit": 50}, "filter": [{"field": "userId", "operator": "eq", "value": "0xAb8D...90F1"}]}'
```

Requests without a key, or with a revoked or malformed one, return `401`:

```json theme={null}
{ "code": "unauthenticated", "message": "missing credentials: supply an X-Api-Key header or a bearer token" }
```

Keys are managed from the [API Keys](https://datadash.xyz/settings/api-keys) page in the dashboard. You can also reach it from the wallet menu in the top-right corner, under **API Keys**.

## Creating a key

**1. Open the API Keys page**

Sign in at [datadash.xyz](https://datadash.xyz) and go to [Settings → API Keys](https://datadash.xyz/settings/api-keys).

**2. Name the key**

Click **Create key** and give it a name, like `production`. Names are 1–30 characters, **letters and digits only**, with no spaces, dashes or underscores. Each name has to be unique within your account.

**3. Copy the key**

The key is shown once. Click **Copy**, store it somewhere safe, then click **Done**.

```bash theme={null}
export DATADASH_API_KEY="datadash_AGB1c2VyXzAxSFEy..."
```

> [!WARNING]
>
> The key is shown **once, at creation**. Datadash stores only a hash of it and can never show it to you again. If you lose it, revoke the key and create a new one.

## Viewing your keys

The API Keys page lists each key's name, last three characters, and creation date. That's enough to tell your keys apart without exposing them.

## Revoking a key

Click the trash icon next to a key and confirm with **Revoke key**. Revocation takes effect within a few seconds across all servers, and every later request with that key returns `401`. You can't undo a revocation.

## Keeping keys safe

* **Never ship a key in client-side code.** Anything in a browser, mobile app, or public repository is readable by anyone. Call the API from your own server instead.
* **Use one key per environment or service.** If a key leaks, you revoke just that one instead of breaking everything at once.
* **Load keys from environment variables or a secret manager**, not from source.
* **Rotate on exposure.** Create the replacement, switch traffic to it, then revoke the old key.

> [!NOTE]
>
> A key carries the full access of the account that created it. Treat it like a password.

## Next steps

> [card] [Filtering](https://docs.datadash.xyz/filters.md)
>
> Narrow any list endpoint with typed conditions and AND/OR groups.

> [card] [Generate a client](https://docs.datadash.xyz/openapi-clients.md)
>
> Build a typed TypeScript or Python client from the OpenAPI spec.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.