Developers

ChatInCart API

A REST API and signed webhooks for syncing contacts, reading conversations and replying as your team — so ChatInCart fits into your CRM, help desk and data stack.

Overview

  • Base URL: https://api.chatincart.com/api/v1
  • JSON in, JSON out. Send Content-Type: application/json on writes.
  • Timestamps are ISO 8601 in UTC. IDs are integers.
  • Available on Growth and Scale plans. Replies sent through the API are human replies, so they never use AI credits.

Authentication

Create a key in Dashboard → Settings → Developers. Owners and admins can create keys. The full key is shown once; we store only a hash. Send it as a bearer token:

Request
curl https://api.chatincart.com/api/v1/me \
  -H "Authorization: Bearer cic_live_••••••••"
Response 200
{
  "data": {
    "workspace": { "id": 12, "name": "Acme", "slug": "acme", "plan": "Growth" },
    "api_key": { "name": "HubSpot sync", "prefix": "cic_live_Ab3d", "scopes": ["contacts:read"], "expires_at": null }
  }
}

Keys belong to a workspace, not a person, and keep working if the creator leaves. Revoke a key at any time; it stops working immediately.

Scopes

Grant each key only what it needs. A request without the right scope returns 403 insufficient_scope.

ScopeAllows
contacts:readList and fetch contacts
contacts:writeCreate (upsert by email) and update contacts
conversations:readList conversations and read messages
conversations:writeReply to a conversation as a teammate
tickets:readList and fetch tickets and their messages
tickets:writeCreate tickets, change status/priority/assignee/tags, reply and add notes

Rate limits

Limits apply per API key, per minute: 240 on Growth and 600 on Scale. Every response includes:

X-RateLimit-Limit: 240
X-RateLimit-Remaining: 239

Over the limit you get 429 rate_limited with a Retry-After header (seconds). Back off and retry after that time.

Errors

Errors use one shape. Branch on type, not on the message text.

Response 422
{
  "error": {
    "type": "validation_failed",
    "message": "The request has invalid fields.",
    "fields": { "email": ["The email field must be a valid email address."] }
  }
}
StatustypeMeaning
401authentication_failedMissing, invalid, expired or revoked key
403plan_upgrade_requiredThe workspace plan does not include API access
403insufficient_scopeThe key lacks the scope for this endpoint
404not_foundNo such resource in this workspace
409conflictAnother message is being sent to this conversation; retry shortly
422validation_failed / invalid_authorInvalid input; see fields
429rate_limitedToo many requests; see Retry-After
500server_errorOur fault. Safe to retry with backoff

Pagination

List endpoints are cursor-paginated, newest first (messages oldest first). Pass limit (1–100, default 25) and the next_cursor from the previous page as cursor.

{
  "data": [ ... ],
  "meta": { "limit": 25, "has_more": true, "next_cursor": "eyJpZCI6MTIzLCJfcG9pbnRzVG9OZXh0SXRlbXMiOnRydWV9" }
}

Contacts

A contact is a person who chatted with one of your AI agents (a “portal”). Use GET /portals to list portal IDs.

GET/contactscontacts:read
Filters: portal_id, email, external_id, updated_since (ISO date), limit, cursor.
GET/contacts/{id}contacts:read
Returns one contact.
Contact object
{
  "object": "contact",
  "id": 981,
  "portal_id": 4,
  "email": "jane@example.com",
  "name": "Jane Doe",
  "phone": "+15550100",
  "external_id": "crm_123",
  "avatar_url": null,
  "location": { "country_code": "US", "city": "Austin", "timezone": "America/Chicago" },
  "attribution": {
    "referrer": "https://www.google.com/",
    "utm_source": "newsletter",
    "first_page_url": "https://acme.com/pricing",
    "current_page_url": "https://acme.com/checkout"
  },
  "blocked": false,
  "last_seen_at": "2026-11-15T10:02:11+00:00",
  "created_at": "2026-11-01T08:00:00+00:00",
  "updated_at": "2026-11-15T10:02:11+00:00"
}
POST/contactscontacts:write
Upsert by email within a portal: returns 201 when created, 200 when an existing contact was updated. Body: portal_id (required), email (required), name, phone, external_id.
Request
curl -X POST https://api.chatincart.com/api/v1/contacts \
  -H "Authorization: Bearer $CHATINCART_KEY" \
  -H "Content-Type: application/json" \
  -d '{"portal_id": 4, "email": "jane@example.com", "name": "Jane Doe", "external_id": "crm_123"}'
PATCH/contacts/{id}contacts:write
Update any of name, phone, external_id, blocked. Blocked contacts cannot send messages.

Conversations

GET/conversationsconversations:read
Filters: portal_id, contact_id, handled_by (ai | human), updated_since.
GET/conversations/{id}conversations:read
Returns one conversation.
Conversation object
{
  "object": "conversation",
  "id": 5521,
  "portal_id": 4,
  "contact_id": 981,
  "title": "Order status",
  "handled_by": "human",
  "handoff_reason": "customer_request",
  "assignee_id": 7,
  "country_code": "US",
  "started_at": "2026-11-15T09:58:00+00:00",
  "last_message_at": "2026-11-15T10:02:11+00:00",
  "created_at": "2026-11-15T09:58:00+00:00"
}

handoff_reason is one of customer_request, agent_takeover, ai_credits_exhausted, or null.

GET/conversations/{id}/messagesconversations:read
Messages oldest first. author_type is contact, ai or teammate.
POST/conversations/{id}/replyconversations:write
Reply as a teammate. Body: body (required, up to 10,000 characters) and optional author_email — a workspace owner, admin or agent (defaults to the key's creator). The conversation switches to your team, the AI stops replying in it, and the customer sees the message live. Uses no AI credits.
Request
curl -X POST https://api.chatincart.com/api/v1/conversations/5521/reply \
  -H "Authorization: Bearer $CHATINCART_KEY" \
  -H "Content-Type: application/json" \
  -d '{"body": "Your order ships today. Tracking: 1Z999...", "author_email": "sam@acme.com"}'

Tickets

Tickets are addressed by their workspace ticket number — the #1042 your customers see. Statuses: new, open, pending (waiting on the customer), on_hold, solved, closed. Priorities: low, normal, high, urgent.

GET/ticketstickets:read
Filters: status, priority, assignee_id, contact_id, requester_email, updated_since.
GET/tickets/{number}tickets:read
Returns one ticket, including SLA due dates and AI triage.
POST/ticketstickets:write
Body: subject, body, requester_email (required); requester_name, portal_id (links the contact), priority, type, tags, custom_fields.
PATCH/tickets/{number}tickets:write
Change status, priority, type, subject, assignee_id, tags or custom_fields. Every change is recorded in the ticket's audit trail and fires ticket.updated.
GET/tickets/{number}/messagestickets:read
Public replies, oldest first. Add include_notes=1 for internal notes too.
POST/tickets/{number}/messagestickets:write
kind: reply (emailed to the requester, status becomes pending unless you pass status), note (internal) or customer (add a message from the customer, e.g. from your own form). Replies and notes are authored by author_email (an owner, admin or agent; defaults to the key's creator).
Ticket object (abridged)
{
  "object": "ticket", "id": 311, "number": 1042,
  "subject": "Order has not arrived", "status": "open", "priority": "high", "type": "question", "channel": "email",
  "requester": { "email": "jane@example.com", "name": "Jane Doe" }, "assignee_id": 7, "tags": ["shipping"],
  "sla": { "first_response_due_at": "2026-11-16T10:00:00+00:00", "resolution_due_at": "2026-11-18T17:00:00+00:00", "breached_at": null, "breach_type": null },
  "ai": { "summary": "Order #5531 missing after 10 days.", "triage": { "category": "Shipping", "sentiment": "negative", "language": "en" } },
  "csat": null, "created_at": "2026-11-15T09:58:00+00:00"
}

Webhooks

Add HTTPS endpoints in Settings → Developers and choose events. We send a POST with a JSON body; respond with any 2xx within 10 seconds. Redirects are not followed.

EventWhen
contact.createdA new contact (visitor or customer) was created
contact.updatedEmail, name, phone, external ID, avatar or blocked status changed
conversation.createdA customer started a conversation
conversation.message.createdA message was added by the customer, the AI or a teammate
conversation.handed_offA conversation moved from the AI to your team
ticket.createdA ticket was created
ticket.updatedA ticket changed status, priority, assignee or fields
ticket.reply.createdA public reply or internal note was added to a ticket
Payload
POST /your/endpoint
ChatInCart-Signature: t=1763201000,v1=5f2c...e91a
ChatInCart-Event: conversation.message.created
ChatInCart-Event-Id: 2f6c1d0e-7a2b-4c1e-9a55-0b8f3c9d1e22
ChatInCart-Delivery-Attempt: 1

{
  "id": "2f6c1d0e-7a2b-4c1e-9a55-0b8f3c9d1e22",
  "type": "conversation.message.created",
  "created_at": "2026-11-15T10:02:11+00:00",
  "workspace_id": 12,
  "data": {
    "message": {
      "object": "message", "id": 77120, "conversation_id": 5521,
      "author_type": "contact", "author_user_id": null,
      "body": "Where is my order?", "created_at": "2026-11-15T10:02:11+00:00"
    }
  }
}
  • Retries: failed deliveries (non-2xx, timeout, connection error) are retried after 30s, 2m, 10m, 30m, 2h and 6h — 7 attempts over about 9 hours. Retries reuse the same id, so de-duplicate on it.
  • Ordering is not guaranteed. Use created_at and fetch the latest state from the API when order matters.
  • Auto-disable: an endpoint is switched off after 15 events in a row fail all retries. Re-enable it in the dashboard once fixed. You can send a test event and retry any failed delivery from the delivery log.

Verifying signatures

Each endpoint has a signing secret (whsec_…). The signature is HMAC-SHA256 of {t}.{raw body} with your secret, hex-encoded. Compute it over the raw request body, compare in constant time, and reject timestamps older than 5 minutes.

Node.js (Express)
import crypto from "node:crypto";
import express from "express";

const app = express();

app.post("/webhooks/chatincart", express.raw({ type: "application/json" }), (req, res) => {
  const header = req.get("ChatInCart-Signature") ?? "";
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const expected = crypto
    .createHmac("sha256", process.env.CHATINCART_WEBHOOK_SECRET)
    .update(`${parts.t}.${req.body}`)
    .digest("hex");

  const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
  const valid = parts.v1 && parts.v1.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
  if (!fresh || !valid) return res.sendStatus(400);

  const event = JSON.parse(req.body);
  // handle event.type, de-duplicate on event.id
  res.sendStatus(204);
});
PHP
$body = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_CHATINCART_SIGNATURE'] ?? ''), $sig);
$expected = hash_hmac('sha256', ($sig['t'] ?? '') . '.' . $body, getenv('CHATINCART_WEBHOOK_SECRET'));

if (abs(time() - (int) ($sig['t'] ?? 0)) > 300 || ! hash_equals($expected, $sig['v1'] ?? '')) {
    http_response_code(400);
    exit;
}
$event = json_decode($body, true);
Python (Flask)
import hmac, hashlib, os, time
from flask import request, abort

@app.post("/webhooks/chatincart")
def chatincart_webhook():
    raw = request.get_data()
    parts = dict(p.split("=", 1) for p in request.headers.get("ChatInCart-Signature", "").split(","))
    expected = hmac.new(os.environ["CHATINCART_WEBHOOK_SECRET"].encode(),
                        f"{parts.get('t')}.".encode() + raw, hashlib.sha256).hexdigest()
    if abs(time.time() - int(parts.get("t", 0))) > 300 or not hmac.compare_digest(expected, parts.get("v1", "")):
        abort(400)
    event = request.get_json()
    return "", 204

Security checklist

  • Keep keys on your server. Never put an API key in a browser, mobile app or public repository.
  • Use one key per integration with the fewest scopes, and set an expiry for temporary access.
  • Rotate a webhook secret from the dashboard if it may have leaked; the old secret stops working immediately.
  • Always verify webhook signatures and timestamps before trusting a payload.
  • Webhook URLs must be public HTTPS. Private, loopback and cloud-metadata addresses are rejected.

Versioning

The API is versioned in the path (/v1). Within v1 we only make additive changes: new endpoints, new optional parameters, new fields and new event types. Build clients that ignore unknown fields. Breaking changes ship as a new version with advance notice.