# API Overview > Chat with your agents and manage your workspace from your own code, with one API key The QwryAI API has two parts that share the same API keys. The **Chat API** talks to an agent the way a customer would and streams its answers back. The **Tools API** reads and changes everything else: agents, conversations, tickets, sources, actions and settings. Both return JSON and use the same Bearer key, so one key can power a support bot in your app and a nightly report in the same project. > [!NOTE] > > **Paid plan required.** API keys work on the **Starter**, **Growth** and **Enterprise** plans. On **Free**, the **API keys** page shows **Unlock API access by subscribing to one of these plans** and requests are refused. [View plans](/pricing) > [!TIP] > > Prefer the terminal? The [QwryAI CLI](/docs/cli/overview) calls the same Tools API from your shell or CI. > [!WARNING] > > The Chat API sends messages only into conversations where the AI is still replying. Once a teammate takes a conversation over, or it ends, the Chat API refuses it with `CHAT_CONVERSATION_NOT_ONGOING`; start a new conversation instead. To read conversations from **every** channel, use the Tools API's [conversation search](/docs/api-reference/v2/conversation-search) and `query_conversations`. ## What is the QwryAI API? The API exposes what you can do in the dashboard as two surfaces: | Surface | Base URL | What it does | | - | - | - | | Chat API | `https://api.qwryai.com/api/v2` | Send customer messages to an agent, stream the reply, retry an answer and return the result of a client action. | | Tools API | `https://api.qwryai.com/public/v1` | Call any of the workspace tools your key allows, such as `list_agents`, `query_conversations`, `query_tickets` or `list_sources`, with a JSON body. | The Chat API follows a REST shape with structured error codes and Server-Sent Events streaming. The Tools API is a single tool-call endpoint: you name the tool in the path and pass its arguments as the body. Every tool that changes something returns a review first, and nothing changes until you apply it. The same tools power [Backstage](/docs/user-guides/chatbot/backstage), the [MCP server](/docs/developer-guides/mcp) and the CLI. **Base URLs:** ``` https://api.qwryai.com/api/v2 https://api.qwryai.com/public/v1 ``` ## Quick Start **1. Create an API key** Open **Workspace settings › API keys** and select **Create API key**. In **Create New API Key**, keep the permissions your integration needs switched on (the Chat API needs **Chat with agents**) and select **Confirm**. The key appears in the list; open its **⋯** menu and choose **Copy key**. See [Authentication](/docs/api-reference/v2/authentication) for every permission. ![The API keys page under Workspace settings, with the Manage keys heading and the Create API key button.](annotated/01-api-keys.webp "Workspace settings › API keys") > [!WARNING] > > Keep your key on your server. Anyone who has it can act in your workspace with the permissions it carries. **2. Find your agent's id** Call the `list_agents` tool. Each agent comes back with its `id`, which the Chat API takes in the path and the Tools API takes as `chatbotId`. ```bash curl -X POST 'https://api.qwryai.com/public/v1/tools/list_agents' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{}' ``` **3. Send your first message** ```bash curl -X POST 'https://api.qwryai.com/api/v2/agents/YOUR_AGENT_ID/chat' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "message": "Hi! Do you ship to Canada?", "stream": false }' ``` **Response:** ```json { "data": { "id": "5b0e7c1a-2f4d-4c55-9a51-6d8e3f2b9c10", "role": "assistant", "parts": [ { "type": "text", "text": "Yes, we ship to Canada. Orders arrive in 5 to 8 business days." } ], "metadata": { "conversationId": "fd5ae9e1-9b30-4503-b346-ccd4d7ef16a3", "userMessageId": "0c4f6a2e-8d13-4b7a-b0e9-1a2c3d4e5f60", "userId": null, "finishReason": "stop", "usage": { "credits": 1 } } } } ``` Without `"stream": false`, the same call streams the reply as it's written. See [Streaming](/docs/api-reference/v2/streaming). ## Endpoints **Chat API** · `https://api.qwryai.com/api/v2` | Method | Endpoint | Notes | | - | - | - | | `POST` | `/agents/{agentId}/chat` | Send a message or continue a conversation | | `POST` | `/agents/{agentId}/conversations/{conversationId}/retry` | Regenerate an answer | | `POST` | `/agents/{agentId}/conversations/{conversationId}/tool-result` | Return a [client action](/docs/api-reference/v2/client-actions) result | **Tools API** · `https://api.qwryai.com/public/v1` | Method | Endpoint | Notes | | - | - | - | | `GET` | `/me` | Your workspace, plan, the key's permissions and the tools they unlock | | `GET` | `/tools` | Every tool your key can call, with its input schema | | `POST` | `/tools/{toolName}` | Call a tool; the body is its arguments | | `POST` | `/reviews/{reviewId}/apply` | Apply a change a tool prepared for review | A health check that needs no key lives at `GET https://api.qwryai.com/api/v1/health`. The guides in this section map each area to its tools: [Agents](/docs/api-reference/v2/agents), [Conversation Search](/docs/api-reference/v2/conversation-search), [Sources](/docs/api-reference/v2/sources), [Helpdesk](/docs/api-reference/v2/helpdesk) and [WhatsApp](/docs/api-reference/v2/whatsapp). ## Response Headers Chat API responses carry these headers: | Header | Description | | - | - | | `x-request-id` | The request's id. Send your own `x-request-id` and it's echoed back; otherwise QwryAI generates one. Include it when you contact support. | | `X-RateLimit-Limit` | Requests allowed in the current window. | | `X-RateLimit-Remaining` | Requests left in the current window. | | `X-RateLimit-Reset` | Unix time, in seconds, when the window resets. | Tools API responses carry `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` with that API's own limit. See [Rate limiting](/docs/api-reference/v2/authentication#rate-limiting). ## Next Steps > [card] Authentication | /docs/api-reference/v2/authentication | API keys, permissions, OAuth and rate limits. > [card] Streaming | /docs/api-reference/v2/streaming | Read answers as they're written, over Server-Sent Events. > [card] Error Handling | /docs/api-reference/v2/error-handling | Error envelopes and every error code. > [card] Pagination | /docs/api-reference/v2/pagination | Page through tools that return lists.