Chatamatic

Help

API keys and REST API

API keys are for scripts, servers and assistants that cannot sign in through a browser. If you are connecting Claude, ChatGPT, Cursor or VS Code, you do not need a key: see Connect an AI assistant.

The API reads and configures a workspace. Like an assistant, it cannot send a message to anyone, change billing or manage members.

Create a key

Owners and admins can do this.

  1. Open Settings, then API keys & agents.
  2. Under API keys, choose New key.
  3. Give it a Name that says where it will be used, such as "Reporting script".
  4. Tick the Permissions it needs. Give it no more than that.
  5. Choose Create key.
  6. Copy the key now. It is shown once. We store only a fingerprint of it, so it cannot be shown again.

A key starts with cmk_.

Permissions

Permission Allows
Read campaigns List and read campaigns and their posts
Create and edit campaigns Create, edit, duplicate and delete campaigns, and change their status
Read leads List, count and export leads
Update and delete leads Change and delete leads
Read analytics and trigger history Analytics, exports and the trigger log
Read connected accounts and posts Connected accounts, their health, and synced posts. Also GET /workspaces/{id}, which returns the workspace itself

A key can never do more than the person who created it. Only owners and admins can create keys. If the person who created a key is later made an editor, the key keeps working with editor permissions until an owner or admin revokes it: it can no longer delete a campaign, for example, whatever is ticked. If that person leaves the workspace, their keys stop working.

Keep keys safe

Make a request

Send the key in the Authorization header:

curl https://api.chatamatic.io/api/agent/v1/workspaces/WORKSPACE_ID/campaigns \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json"

WORKSPACE_ID is the number of the workspace the key belongs to. The Your own code tab under Connect an agent on the same page shows this request with your workspace's number filled in.

A key works for one workspace only.

A successful response wraps the result in data. An error looks like this:

{"error": {"code": "insufficient_scope", "message": "…", "status": 403}}

Endpoints

All paths start with https://api.chatamatic.io/api/agent/v1.

Method and path Does
GET /workspaces/{id} The workspace, its plan and usage
GET /workspaces/{id}/campaigns List campaigns
POST /workspaces/{id}/campaigns Create a campaign
GET /workspaces/{id}/campaigns/options The channels and trigger types you can use
GET /workspaces/{id}/campaigns/{campaign} Read one campaign
PUT or PATCH /workspaces/{id}/campaigns/{campaign} Edit a campaign
DELETE /workspaces/{id}/campaigns/{campaign} Delete a campaign
POST /workspaces/{id}/campaigns/{campaign}/duplicate Duplicate a campaign
GET or PUT /workspaces/{id}/campaigns/{campaign}/posts Read or set its posts
GET /workspaces/{id}/leads List leads
GET /workspaces/{id}/leads/count Count leads
GET /workspaces/{id}/leads/export Export leads
PATCH /workspaces/{id}/leads/{lead} Update one lead
PATCH /workspaces/{id}/leads Update several leads
DELETE /workspaces/{id}/leads/{lead} Delete one lead
DELETE /workspaces/{id}/leads Delete several leads
GET /workspaces/{id}/analytics Analytics summary
GET /workspaces/{id}/analytics/report Full analytics report
GET /workspaces/{id}/analytics/export Export analytics
GET /workspaces/{id}/trigger-logs The trigger log
GET /workspaces/{id}/trigger-logs/count Count triggers
GET /workspaces/{id}/channel-accounts Connected accounts
GET /workspaces/{id}/integrations/health Health of each connection
GET /workspaces/{id}/posts Synced posts

The text people wrote in comments and messages is never returned by the API. You get who triggered a campaign and which keyword matched.

Errors

Code Status Meaning
unauthenticated 401 The key is missing, wrong, revoked or expired
insufficient_scope 403 The key lacks the permission for this request
workspace_mismatch 403 The key belongs to a different workspace
forbidden 403 The role of the person who made the key does not allow this
workspace_suspended 403 The workspace is suspended
not_found 404 No such record
stale_version 409 The campaign changed since you read it. Read it again before editing
validation_failed 422 Something in the request is invalid. errors names each field
post_limit_exceeded 422 The plan's posts-per-campaign limit is reached
subscription_required 402 The workspace has no subscription
campaign_limit_exceeded 402 The plan's active-campaign limit is reached
too_many_requests 429 Slow down. Retry-After says how long to wait
server_error 500 Our fault. Send us the reference from the response

Rate limit

120 requests a minute for each key. Past that you get too_many_requests with a Retry-After header.

Creating campaigns (POST /workspaces/{id}/campaigns) has a second limit of 50 an hour. It is counted for the person who made the key, not for the key: all of that person's keys, and the campaigns they create in the dashboard, share it.

Stuck on something these pages do not cover? Write to [email protected].