Skip to content
QwryAI
Documentation
Pages

Getting Started

Authentication

Authenticate with an API key or an OAuth token, choose what each key may do, and stay inside the rate limits

Every request to the QwryAI API carries a credential in the Authorization header. Most integrations use an API key you create in the dashboard. Apps that act for other QwryAI users, such as an AI assistant your customers connect, use an OAuth access token instead. Either way, the credential acts as the member who created it and can never do more than that member's role allows.

Bearer Token Authentication

All requests to the Chat API and the Tools API (except the health check) need a Bearer credential:

Code
Authorization: Bearer <api-key>

The Tools API also accepts the key in an x-api-key header, for clients that can't set Authorization:

Code
x-api-key: <api-key>
CredentialLooks likeChat API (/api/v2)Tools API (/public/v1)
API keystarts with cb_live_YesYes
OAuth access tokenstarts with qwa_NoYes

Getting an API Key

API keys belong to the workspace. Members with the Admin or Manager role create and delete them; other members see the list without Create API key.

  1. Open API keys

    In the sidebar, open Workspace settings › API keys. The page lists every key in the workspace, masked, with the access each one has underneath. Until the first key exists, it shows No API keys found.

    Workspace settings › API keys
  2. Select Create API key
    Select Create API key.
  3. Choose the key's permissions and confirm

    Create New API Key lists the permissions you can give the key, all switched on. Switch off anything the integration doesn't need, then select Confirm. The key never gets more than your own role allows, now or later.

    Create New API Key
  4. Copy the key

    The new key joins the list, masked, with its access listed underneath. Open its ⋯ menu and select Copy key. The eye button, Show key, reveals the whole key on screen if you need to read it.

Permissions

Each key holds the permissions you switched on when you created it. Each tool needs one permission, and a key sees only the tools its permissions allow. The Chat API needs Chat with agents.

PermissionCodeWhat it allows
Chat with agentsUSE_CHATList agents, start customer conversations, send customer messages, and search knowledge and product documentation.
Manage conversations and helpdeskMANAGE_CHATRead conversations, tickets and analytics; reply as a human agent, add notes, resolve, and pause the AI.
Read agent settingsREAD_AGENT_CONFIGURATIONInstructions, model, chat interface, sources, knowledge gaps, integrations, webhooks and deploy status.
Change agent settingsMANAGE_AGENT_CONFIGURATIONInstructions, model, chat interface, styles, spam and country rules, and deploy channels.
Change sources and trainingMANAGE_AGENT_SOURCESAdd, edit, delete and restore sources, answer knowledge gaps, and start training.
Read actions and proceduresREAD_AUTOMATIONActions, procedures, drafts, publication state, widgets and templates.
Change actions and proceduresMANAGE_AUTOMATIONCreate, edit, enable, disable and delete actions, procedures and webhooks.
View plan and creditsVIEW_BILLINGPlan, credit balance and credit usage.

The permissions are checked against the creator's current role on every request. If the creator's role is lowered, the key loses whatever the new role can't do; if the creator leaves the workspace, the key stops working. To see what a key holds right now, call GET /public/v1/me:

Bash
curl 'https://api.qwryai.com/public/v1/me' \
  -H 'Authorization: Bearer YOUR_API_KEY'
JSON
{
  "success": true,
  "data": {
    "plan": "growth",
    "authType": "api_key",
    "creatorRole": "Admin",
    "granted": ["USE_CHAT", "MANAGE_CHAT", "READ_AGENT_CONFIGURATION"],
    "permissions": [
      { "permission": "USE_CHAT", "label": "Chat with agents" },
      { "permission": "MANAGE_CHAT", "label": "Manage conversations and helpdesk" },
      { "permission": "READ_AGENT_CONFIGURATION", "label": "Read agent settings" }
    ],
    "tools": ["get_account_context", "list_agents", "search_knowledge", "query_conversations", "list_sources"]
  }
}

granted is what the key was given; permissions is what it holds now, after the creator's role is applied. The response also carries your workspace's tenantId.

Example Request

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": "Hello!"}'

OAuth access tokens

Apps that connect to other people's QwryAI workspaces use OAuth 2.0 with PKCE instead of asking for an API key. The person approving the connection picks the workspace and the permissions, just as they would for a key.

DetailValue
Discoveryhttps://api.qwryai.com/.well-known/oauth-authorization-server
Grant typesauthorization_code (with PKCE S256), refresh_token, and the device code grant
Client registrationDynamic, at /oauth/register; public clients, no client secret
ScopesThe permission codes in the table above
Access tokenqwa_…, valid for 1 hour
ApprovalLasts 90 days; refreshing a token doesn't extend it

Send the access token exactly like an API key, Authorization: Bearer qwa_…, to the Tools API. The Chat API accepts API keys only. The MCP server and the CLI use this flow for you.

Rate Limiting

The two APIs have separate limits:

APILimitCounted per
Chat API1,000 requests per 10-second sliding windowAPI key and caller IP address
Tools API2,000 requests per 15 minutesCredential (API key or OAuth token)

The Chat API also caps how many streamed replies can be open at once. When it's full, a new streaming request gets the same 429 until a stream finishes.

Rate Limit Headers

HeaderDescription
X-RateLimit-LimitRequests allowed in the window.
X-RateLimit-RemainingRequests left in the current window.
X-RateLimit-ResetUnix time, in seconds, when the window resets.
Retry-AfterSeconds to wait before retrying. Only on 429 responses.

Handling Rate Limits

Past the Chat API limit, you get a 429:

JSON
{
  "error": {
    "code": "RATE_LIMIT_TOO_MANY_REQUESTS",
    "message": "Too many requests, please try again later"
  }
}

Past the Tools API limit, you get a 429 with its own code:

JSON
{
  "error": {
    "code": "INTEGRATION_RATE_LIMIT_EXCEEDED",
    "message": "Too many integration requests, please try again later."
  }
}

Wait for the number of seconds in Retry-After, then try again:

JavaScript
async function fetchWithRetry(url, options) {
  const response = await fetch(url, options);

  if (response.status === 429) {
    const retryAfter = parseInt(response.headers.get("Retry-After") ?? "1", 10);
    await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
    return fetchWithRetry(url, options);
  }

  return response;
}

Request ID

Chat API responses carry an x-request-id header. Send your own x-request-id and QwryAI echoes it back; otherwise it generates one. Include it when you contact support about an error.

Code
x-request-id: 3f6c2a9e-1b7d-4e58-9c0a-5d2e8f7b4a61

Authentication errors

HTTP statusChat API codeTools API codeWhen
401AUTH_MISSING_API_KEYAPI_KEY_REQUIREDNo credential was sent.
401AUTH_INVALID_API_KEYINVALID_API_KEY / INVALID_OAUTH_TOKENThe credential is malformed, deleted or unknown.
401AUTH_EXPIRED_API_KEYAUTH_EXPIRED_API_KEYThe key has expired.
403SUBSCRIPTION_API_RESTRICTED_PLANAPI_ACCESS_PLAN_REQUIREDThe workspace's plan doesn't include API access.
403AUTH_INSUFFICIENT_PERMISSIONSCREATOR_NOT_ACTIVEThe key lacks Chat with agents (Chat API), or its creator is no longer in the workspace.
403—INSUFFICIENT_PERMISSIONThe key doesn't hold the permission this tool needs; required names it.

See Error Handling for every code.

Explore the documentation