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

# Authenticate weya API requests with an API key

> Create a weya API key in the dashboard, send it in the x-api-key header on every request, and handle authentication and rate limit errors.

The weya API authenticates every request with an API key sent in the `x-api-key` header. A key acts as the user who created it: requests see that user's agents, phone numbers and campaigns, and anything you create through the API belongs to that user.

## Base URL

All endpoints in the [API reference](https://docs.weya.ai/api-reference/Agents/getAgents.md) are relative to:

```text theme={null}
https://api.weya.live/backend
```

For example, `POST /api/call/createBatch` is `https://api.weya.live/backend/api/call/createBatch`.

## Create an API key

**1. Open API keys**

In the [weya dashboard](https://nexus.weya.ai), open the profile menu and select **API Keys**.

**2. Create a key**

Create a new key and copy it.

**3. Store it as a secret**

Keep the key in your secret manager or an environment variable, never in source code or in a browser.

> [!WARNING]
>
> An API key has the same access as the user who created it. Use it only from your servers, and delete it from **API Keys** straight away if it leaks.

## Send the key

Add the key to every request in the `x-api-key` header:

```bash cURL theme={null}
curl --location 'https://api.weya.live/backend/api/call/get-phone/YOUR_USER_ID?limit=10' \
  --header "x-api-key: $WEYA_API_KEY"
```

```javascript Node.js theme={null}
const res = await fetch(
  "https://api.weya.live/backend/api/call/get-phone/YOUR_USER_ID?limit=10",
  { headers: { "x-api-key": process.env.WEYA_API_KEY } }
);
const body = await res.json();
```

```python Python theme={null}
import os, requests

res = requests.get(
    "https://api.weya.live/backend/api/call/get-phone/YOUR_USER_ID",
    params={"limit": 10},
    headers={"x-api-key": os.environ["WEYA_API_KEY"]},
)
body = res.json()
```

## Find your user ID

Some endpoints, such as [Upload Campaign CSV](https://docs.weya.ai/api-reference/Campaigns/uploadCSV.md) and [Start Campaign](https://docs.weya.ai/api-reference/Campaigns/startCalling.md), take a `userId`. Get it once from your profile, which returns the user that owns the key as `data._id`:

```bash cURL theme={null}
curl --location 'https://api.weya.live/backend/api/auth/profile' \
  --header "x-api-key: $WEYA_API_KEY"
```

## Response format

Most endpoints return the same envelope. Check `status` before you read `data`:

```json theme={null}
{
  "status": true,
  "code": 200,
  "message": "",
  "errorMessage": "",
  "data": {}
}
```

| Field | Meaning |
| - | - |
| `status` | `true` when the request succeeded |
| `code` | The HTTP status code |
| `message` / `errorMessage` | A human-readable description of the result or the error |
| `data` | The result. Its shape is documented on each endpoint's page |

## Authentication errors

| Status | Cause | What to do |
| - | - | - |
| `401` | The `x-api-key` header is missing, or the key doesn't exist or was deleted | Check the header name and that the key is still listed under **API Keys** |
| `403` | The key is valid but can't act on this resource, for example a campaign another user owns | Use a key that belongs to the resource's owner |

## Rate limits

Requests are rate limited per client IP address. When you go over a limit, the API returns `429` with a message that says how long to wait, and the standard `RateLimit` response headers show your remaining requests.

| Endpoints | Limit |
| - | - |
| Calling and campaigns (`/api/call/...`) | 10,000 requests per 10 minutes |
| WhatsApp, video agents, knowledge bases, custom tools and voices | 1,000 requests per 15 minutes |

> [!TIP]
>
> To add many contacts, send them in one request instead of one request per contact. [Add Calls to Campaign](https://docs.weya.ai/api-reference/Campaigns/addCallsToBatch.md) accepts thousands of contacts per call and splits them into chunks for you.

## Next steps

> [card] [API quickstart](https://docs.weya.ai/get-started/api-quickstart.md)
>
> Launch a campaign and receive results with four requests.

> [card] [API reference](https://docs.weya.ai/api-reference/Agents/getAgents.md)
>
> Every endpoint, with request and response examples.


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