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

# Introduction

> Build on Chatling with the REST API: set up AI agents, manage conversations, work with contacts and data, and more.

The Chatling API lets your code do what your team does in the dashboard. Set up AI agents and train them on your content, chat with them as a user from your own app, and handle their conversations on every channel, from replying as a team member to assigning, labeling, and ending them.

## Base URL

```
https://api.chatling.ai/v3
```

## Get started

**1. Create an API key**

In the dashboard, go to **Project settings > API** and generate a key. See [Authentication](https://docs.chatling.ai/api-reference/v3/authentication.md).

**2. Make your first request**

Retrieve the key to check that it works:

```bash theme={null}
curl https://api.chatling.ai/v3/me \
  -H "Authorization: Bearer $CHATLING_API_KEY"
```

**3. Build**

Browse the endpoints in the reference, and learn how [authentication](https://docs.chatling.ai/api-reference/v3/authentication.md), [errors](https://docs.chatling.ai/api-reference/v3/errors.md), and [pagination](https://docs.chatling.ai/api-reference/v3/pagination.md) work.

> [!TIP]
>
> To use Chatling from AI apps such as Claude, ChatGPT, or Cursor without writing code, connect the [MCP server](https://docs.chatling.ai/api-reference/v3/mcp.md).

## Conventions

### AI agents and chatbots

Chatling has two kinds of agent: AI agents and flow-builder chatbots.

* Most endpoints work with both. Resources that belong to an agent, such as conversations, contacts, knowledge base sources, labels, teams, channels, and analytics, take either kind's ID as `agent_id`.
* Only the endpoints that manage the agent itself are separate: [`/agents`](https://docs.chatling.ai/api-reference/v3/agents/list-agents) for AI agents and [`/chatbots`](https://docs.chatling.ai/api-reference/v3/chatbots/list-chatbots) for chatbots. Using one kind's ID at the other's path returns 404, with a message pointing to the right path.
* Some endpoints, such as WhatsApp templates and variables, are marked **Available for AI agents only**. They return 409 `unsupported_agent_type` for a chatbot.
* A chatbot's flow doesn't run through the API. When you [send a chatbot a user message](https://docs.chatling.ai/api-reference/v3/conversations/send-user-message.md), it answers from its knowledge base using the AI settings you pass in `ai`.

### Idempotent requests

The API supports idempotency for safely retrying `POST` requests without performing the same operation twice. If a request times out or fails because of a network error, retry it with the same `Idempotency-Key` header. Use a unique value, such as a V4 UUID:

```bash theme={null}
curl https://api.chatling.ai/v3/contacts \
  -H "Authorization: Bearer $CHATLING_API_KEY" \
  -H "Idempotency-Key: 4f1d2c3b-7a8e-4b9c-a0d1-e2f3a4b5c6d7" \
  -H "Content-Type: application/json" \
  -d '{"agent_id": "AGENT_ID", "first_name": "Ada", "email": "ada@example.com"}'
```

For 24 hours, retrying with the same key and the same request returns the saved response, with an `Idempotent-Replayed: true` header. Only successful responses are saved, so you can retry a failed request with the same key.

Use a new key for each new request. Reusing a key for a different request returns 422 `idempotency_key_reused`.

### Request IDs

Each API request has a request ID, returned in the `X-Request-Id` header and in error responses. Include it when you contact support.

> [card] [Authentication](https://docs.chatling.ai/api-reference/v3/authentication.md)
>
> API keys, key restrictions, and rate limits.

> [card] [Errors](https://docs.chatling.ai/api-reference/v3/errors.md)
>
> The error format and error codes.

> [card] [Pagination](https://docs.chatling.ai/api-reference/v3/pagination.md)
>
> Paginate through lists with cursors.


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