For the complete documentation index, see llms.txt. This page is also available as Markdown.

Backend API

The Backend API lets you programmatically access your Zipchat conversation data and manage your AI's configuration. Sync conversations with your CRM, reply to customers, and manage rules and skills.

The Backend API lets you programmatically access your Zipchat conversation data and manage your AI's configuration. Use it to sync conversations with your CRM, build custom analytics dashboards, take over conversations from the AI, reply to customers, and manage rules, custom tools (skills), and variables — all from your own systems.

Getting Started

  1. Go to Settings > Integrations in your Zipchat dashboard

  2. Click Enable on the Backend API card

  3. Copy your API key (prefixed with zc-) — store it securely, it is only shown once

Authentication

Include your API key as a Bearer token in the Authorization header:

Authorization: Bearer zc-your_api_key_here

All requests must be authenticated. Unauthenticated or invalid requests return 401 Unauthorized.

The API accepts two kinds of token, interchangeably, on every endpoint:

Chat-level tokens (zc-)

Scoped to a single chat. Generated per chat in Settings > Integrations > Backend API. A chat token only authenticates requests whose :chat_id matches the chat it belongs to — any other chat_id returns 401.

User-level tokens (zcu-)

Personal to a user and work against any chat that user can access (chats they own or are a member of). Generate or regenerate one under Account > Settings (/account/settings/edit). Use the same Authorization: Bearer zcu-... header. A user token used against a chat_id the user cannot access returns 401 and never reveals whether that chat exists.

Both token types can call every endpoint below. Two caveats for user tokens:

  • Role model: configuration writes (updating the prompt, creating/updating/deleting rules, custom tools and variables) follow the same permissions as the dashboard. A member-role (read-only) user's token receives 403 Forbidden on those endpoints but can still use all read and conversation endpoints.

  • Revocation: user tokens authenticate independently of the chat's Backend API integration — disabling that integration revokes only the chat-level zc- key. To cut off a user token, revoke it in that user's Account > Settings, or remove the user from the chat.

Tokens are environment-specific: a token generated in production only works against production, and vice versa for staging/local environments.

Base URL

Endpoints

List Chats

Lists the chats reachable with your credential, so clients can discover chat ids. With a user token this returns every chat the user can access; with a chat token it returns only that token's chat.

Parameters

Parameter
Type
Default
Description

page

integer

1

Page number

per_page

integer

50

Items per page (max 100)

Response


List Conversations

Returns a paginated list of non-empty conversations for the given chat, including archived conversations. Results are ordered by last message time descending, then ID descending.

Parameters

Parameter
Type
Default
Description

page

integer

1

Page number

per_page

integer

50

Items per page (max 100)

last_message_at_since

string

—

ISO 8601 timestamp. Only return conversations with last_message_at >= this time. Does not detect status-only changes.

updated_at_since

string

—

ISO 8601 timestamp. Only return conversations with updated_at >= this time, including archive, escalation, purchase and sentiment changes.

Response

Page context

Both list and detail responses include these nullable page-context fields:

Field
Type
Description

current_url

string or null

Stored page URL associated with the customer's latest storefront message. Sending a message from another page updates it; browsing alone does not.

start_link

string or null

First available page URL captured for the conversation. Later messages from other pages do not replace it.

Use these URLs to map conversations to products in your system. They are page URLs, not product IDs, and a conversation can discuss multiple products even if it started on a product page. Both fields may be null when page context is unavailable, including on non-storefront channels or older conversations. Reading either endpoint does not modify them.

archived and updated_at are included in both list and detail responses. updated_at uses microsecond precision and reflects changes to the conversation record; it is not a change log for every nested lead or message edit.

Incremental status sync

Use updated_at_since alone to pick up archive/unarchive and escalation changes even when no message has been added. If both timestamp filters are provided, both must match (AND). Invalid timestamps return 422; omitted or blank filters are ignored.

  1. Perform an initial paginated fetch and upsert conversations by ID.

  2. Record the time at the start of each polling cycle, and fetch every page using the same updated_at_since value from the previous completed cycle, with an overlap (for example, one minute).

  3. Only advance the checkpoint after all pages succeed. Deduplicate overlapping results by conversation ID, using updated_at to avoid applying older responses.

  4. Periodically reconcile your tracked conversations, including archived ones, via the detail endpoint so missed archive or unarchive changes can be recovered. Pagination uses offsets, so concurrent changes can move records between pages; it is not a snapshot.

Keep archived records in your local sync state so that a later unarchive can return them to your queue. Retain timestamp precision and account for client/server clock skew when choosing an overlap. The filter reflects conversation updates, not deletions or every update to associated records. No status-change webhook is provided.

The lead and assignee fields are null when not set. last_escalated_at is set when the conversation was escalated by the AI or via the API; last_escalation_resolved_at is set when the escalation was marked resolved in the dashboard or via the API.

Sentiment and purchases

Both list and detail responses include the classifications shown on the dashboard's Insights card, and the orders attributed to the conversation:

Field
Type
Description

customer_sentiment

string or null

The customer's buying stage, shown as "Customer sentiment" on the dashboard: discovery (browsing, no product in mind), conviction (weighing a specific product), post_purchase (asking about an order already placed) or other.

customer_sentiment_reason

string or null

One sentence explaining the customer_sentiment verdict.

purchase_sentiment

string or null

How much the conversation influenced its purchases: strongly_influenced, influenced or not_influenced. One verdict covers every purchase in the conversation. Always null when purchases is empty.

purchase_sentiment_reason

string or null

One sentence explaining the purchase_sentiment verdict.

purchases

array

Orders attributed to the conversation, oldest first. Empty when none.

Each purchase has:

Field
Type
Description

order_id

string

The store's order ID (the Shopify order ID on Shopify stores).

order_total

string

Order total as a decimal string (for example "29.9"), in currency.

currency

string

ISO 4217 currency code.

line_items

array

Ordered items, each with id (string), title, price (decimal string) and quantity (integer). Empty when the store did not report items.

created_at

string

When Zipchat recorded the purchase.

Sentiments are classified once a conversation has been idle for 24 hours, so both are null (pending) on recent conversations. Recording a purchase and classifying either sentiment move the conversation's updated_at, so the incremental sync on updated_at_since described above picks them up.


Get Conversation

Returns a single conversation with its messages.

Parameters

Parameter
Type
Default
Description

message_page

integer

1

Message page number

message_per_page

integer

100

Messages per page (max 200)

message_created_at_since

string

—

ISO 8601 timestamp. Only return messages created since this time.

Response

The current_url and start_link fields have the same meaning and nullable types as in the list response.

The show endpoint returns expanded lead details (including first_name, last_name, shopify_customer_id, and additional_attributes) compared to the list endpoint. The assignee, last_escalated_at, last_escalation_resolved_at, sentiment and purchases fields follow the same shape as on the list endpoint.


List Users

Returns the users (the chat owner and any chat participants) who can be assigned to a conversation on this chat.

Parameters

Parameter
Type
Default
Description

page

integer

1

Page number

per_page

integer

50

Items per page (max 100)

Response

avatar_url is null when the user has not uploaded an avatar.


Get User

Returns a single user. Returns 404 if the user is not in the assignable set for this chat — the endpoint will never leak information about users from other chats.

Response


Update Conversation Assignment

Takes a conversation over from the AI (manual mode) or hands it back to the AI. This is a single atomic operation: setting assignee_id to a user puts the conversation into manual mode; setting it to null puts it back into AI mode and unassigns.

Use GET /chats/:chat_id/users to discover valid assignee_id values.

Request body

Or, to hand back to the AI:

Response

Errors

Status
Error message
Cause

404 Not Found

Conversation not found

The conversation does not belong to this chat.

422 Unprocessable Entity

assignee_id is required (use null to assign to AI)

The body did not include assignee_id.

422 Unprocessable Entity

assignee_id is not an assignable user for this chat

The given user is not the chat owner or a participant.


Archive or Unarchive Conversation

Sets the same archived state as the dashboard's Archive/Unarchive action, including for conversations that were never escalated.

Request body

Send false to unarchive. The archived field is required and must be a JSON boolean; strings, numbers, null, arrays and objects are rejected. Repeating the same request preserves the state and does not advance updated_at.

Response

Archiving does not change last_message_at, escalation timestamps, assignment, or AI reply mode. Resolving an escalation does not archive a conversation. The internal conversation lifecycle's closed state is separate from the merchant's archive action and is not exposed by this API.

Errors

Status
Error message
Cause

404 Not Found

Conversation not found

The conversation does not exist or does not belong to this chat.

422 Unprocessable Entity

archived is required and must be a JSON boolean

Missing or invalid archived value.

Standard authentication and rate limits apply.


Escalate or Resolve Conversation

Updates the conversation's escalation timestamps and updated_at. It does not archive the conversation, send notifications, or change its assignment.

Request body

Field
Type
Description

resolved

boolean

Optional, defaults to false. When false (or omitted), escalates: sets last_escalated_at to now and clears last_escalation_resolved_at (so a previously resolved conversation is re-opened). When true, resolves: sets last_escalation_resolved_at to now and leaves last_escalated_at untouched.

Sending no body escalates the conversation.

Response

The same shape for both operations:

currently_escalated is true when last_escalated_at is set and not yet resolved.

Errors

Status
Error message
Cause

404 Not Found

Conversation not found

The conversation does not belong to this chat.


Send Manual Message

Sends a manual reply from a human agent on a conversation that is currently in manual mode. The message is sent through whichever channel the conversation uses (web, email, WhatsApp, Instagram, Messenger).

You must take the conversation over first with PATCH /conversations/:id/assignment — sending while the conversation is still in AI mode returns 422.

Request body

Field
Type
Description

message

string

The reply text. Required.

sender_id

integer

The user id that should be recorded as the sender. Must be a member of GET /chats/:chat_id/users. Required.

Response

Errors

Status
Error message
Cause

404 Not Found

Conversation not found

The conversation does not belong to this chat.

422 Unprocessable Entity

message is required

Empty or missing message.

422 Unprocessable Entity

sender_id is required

Missing sender_id.

422 Unprocessable Entity

sender_id is not an assignable user for this chat

Sender is not the chat owner or a participant.

422 Unprocessable Entity

Conversation is in AI mode; assign it to a user before sending a manual message

Call the assignment endpoint first.

422 Unprocessable Entity

Cannot send: customer last messaged more than 24 hours ago on a Meta channel

WhatsApp / Instagram / Messenger enforce a 24-hour reply window from Meta. Wait for the customer to message again.


Get Master Prompt

Returns the chat's Additional instructions rule as master_prompt. master_prompt is null when the chat has no Additional instructions rule, even if other rules are turned on. This is common: new agents get their instructions as generated rules.

Response


Update Master Prompt

Replaces the chat's Additional instructions rule, or creates it when the chat has none. The chat's other rules are not changed.

Request body

Field
Type
Description

master_prompt

string

The new master prompt. Required. Leading/trailing whitespace is stripped. Must not exceed the chat's configured maximum length. The chat's other turned-on rules count toward the same master_prompt_max_length.

Response

Errors

Status
Error message
Cause

403 Forbidden

Your role does not allow configuration changes

User token belongs to a read-only (member-role) user.

422 Unprocessable Entity

master_prompt is required

The body did not include master_prompt.

422 Unprocessable Entity

master_prompt cannot be blank

The value was null, empty, or whitespace-only. Blank values are rejected rather than silently erasing the prompt. To remove it, delete the Additional instructions rule through Rules.

422 Unprocessable Entity

master_prompt must be at most N characters long

The prompt exceeded master_prompt_max_length.

422 Unprocessable Entity

Instructions can't take the turned-on rules past N characters. M characters are left.

The new text plus the chat's other turned-on rules would exceed master_prompt_max_length.


Custom Tools (Skills)

Custom tools (labeled "skills" in the dashboard) are per-chat actions the AI can invoke.

List

Paginated (page, per_page, max 100).

Create

Field
Type
Description

name

string

Required, max 255 chars.

instructions

string

Required, max 10000 chars.

channels

array

Channels the tool is active on. When omitted, defaults to the template's install channels if custom_tool_template_id is given, otherwise ["all channels"].

active

boolean

Optional, defaults to true.

variable_ids

array

Optional. IDs of existing pool variables to attach to this tool. Must be an array of ids (422 otherwise).

Returns 201 with the serialized custom tool. Validation failures return 422 with an error message — including an unknown icon_id or custom_tool_template_id (icon_id does not exist / custom_tool_template_id does not exist).

Update

Same body shape as create (all fields optional; custom_tool_template_id is create-only and ignored here). variable_ids, when present, is the full desired set of attached variables: missing ones are attached and absent ones detached (detaching only removes the link — the pooled variable itself is untouched). Omit the key to leave attachments unchanged. Returns 200, or 404 if the tool does not belong to this chat.

Delete

Returns 204 No Content, or 404 if the tool does not belong to this chat.


Variables

Variables are a per-chat pool of secrets (e.g. API keys) that custom tools reference. Values are write-only — they are encrypted at rest and never returned by the API; responses expose only a has_value flag.

List

Paginated (page, per_page, max 100).

kind is user for normal variables or managed_shopify for the reserved, auto-managed SHOPIFY_API_KEY.

Create

Field
Type
Description

name

string

Required. Uppercase letters, digits, and underscores only (e.g. API_KEY). Unique per chat.

value

string

Required. Stored encrypted; never returned.

custom_tool_ids

array

Optional. Custom tools to attach this variable to.

Returns 201. Validation failures (bad name format, duplicate, reserved name) return 422.

Update

Updates the value only. The change propagates to every custom tool the variable is attached to.

Returns 200. Returns 422 if value is blank, 404 if the variable is not on this chat, or 422 when targeting the managed SHOPIFY_API_KEY (it cannot be edited via the API).

Delete

Returns 204 No Content. Returns 404 if the variable is not on this chat, or 422 for the managed SHOPIFY_API_KEY (it cannot be deleted).


Rules

Rules are the agent's named instructions. Every turned-on rule available on a conversation's channel goes into the AI's prompt, in ID order. kind is custom for a rule the merchant wrote, generated for one onboarding research wrote, or additional_instructions for the chat's one Additional instructions rule. That is the rule the deprecated /prompt endpoints read and write. kind is never writable.

The instructions of all turned-on rules together must fit in master_prompt_max_length. A single rule is capped at instructions_max_length: 2,000 characters, or the chat's whole limit for the Additional instructions rule.

List

Paginated (page, per_page, max 100). active_instructions_length is the total length of the turned-on rules' instructions, so master_prompt_max_length - active_instructions_length is what is left.

Create

Field
Type
Description

name

string

Required, max 255 chars.

instructions

string

Required, max instructions_max_length.

channels

array

Channels the rule applies on. Defaults to ["all channels"].

active

boolean

Optional, defaults to true.

Creates a custom rule and returns 201 with the serialized rule.

Update

Same body shape as create, every field optional. An omitted channels key is left as it is. Updating a generated rule turns it custom, so a later onboarding run keeps it. The Additional instructions rule keeps its kind. Returns 200 with the serialized rule.

Delete

Returns 204 No Content. Deleting the Additional instructions rule clears the master prompt, so Get Master Prompt then returns null.

Errors

Status
Error message
Cause

403 Forbidden

Your role does not allow configuration changes

User token belongs to a read-only (member-role) user.

404 Not Found

Rule not found

The rule does not belong to this chat.

422 Unprocessable Entity

Name can't be blank, Instructions can't be longer than 2,000 characters. Shorten them or split them into two rules., ...

A validation failed. Messages are joined into one sentence.

422 Unprocessable Entity

Instructions can't take the turned-on rules past 10,000 characters. 120 characters are left.

Creating, editing or turning on the rule would take the turned-on total past master_prompt_max_length.

Rate Limiting

The API allows 120 requests per 60-second window per credential (per chat integration for chat tokens, per user for user tokens).

Every response includes rate limit headers:

Header
Description

X-RateLimit-Limit

Maximum requests per window (120)

X-RateLimit-Remaining

Requests remaining in the current window

X-RateLimit-Reset

Unix timestamp when the window resets

When the limit is exceeded, the API returns 429 Too Many Requests.

Error Codes

Status
Description

401 Unauthorized

Missing or invalid API key

403 Forbidden

User token's role does not allow configuration changes (prompt, rules, custom tools, variables)

404 Not Found

Conversation, user, rule, custom tool, or variable not found

422 Unprocessable Entity

Invalid parameter (e.g., malformed timestamp, missing field, ineligible assignee)

429 Too Many Requests

Rate limit exceeded

Examples

Discover your chats with a user token

List rules, then add one

Create a custom tool with a secret variable

Copy a custom tool to another chat

Fetch the latest conversations

Fetch conversations with new message activity since a timestamp

Fetch a single conversation with messages

Paginate through messages

Take over a conversation, reply, and hand it back to the AI

Escalate, then resolve a conversation

Archive and sync status changes

Last updated