Docs
Documentation

Chat, Lead Conversion and Support Tickets APIs

Call Central AI from your own server.

On this page: Before you start · Chat API · Lead Conversion API · Support Tickets API · All server endpoints

Before you start

  • Every API on this page takes your external API key in the X-API-Key header. It begins with cax_ and is secret: call these APIs from your own server, never from a browser or a mobile app. Find it on Security (administrators and teammates with Agent Configuration access).
  • Your widget key (ca_…) is not accepted here. Sending it is answered with LEGACY_API_KEY_RETIRED (or, during the changeover period, works with a Sunset header naming the date it stops).
  • Examples call http://centralai.daffodil-bd.com. Replace YOUR_EXTERNAL_API_KEY with your key, read from an environment variable, never hard-coded.

Chat API

POST http://centralai.daffodil-bd.com/chat/api/v1/ — talk to your agent from your own app: your front end talks to your server, and your server talks to Central AI.

  • Origin: this API also checks the Origin header against your allowed domains, so your server must send one of them.
  • Rate limit: 100 requests per 60 seconds per key; beyond it, 429 with Retry-After.
  • Credits: send_message uses your chat credits; the other actions do not.

One endpoint, four actions (send_message, get_history, get_sessions, new_session). Every action needs email: the customer the conversation belongs to.

ActionBodyAnswer
send_messageemail, message; optional name, phone, session_idresponse, session_id, session_name, message_count
get_historyemail; optional session_id (latest if left out)history (role, content, timestamp), session_id
get_sessionsemailsessions, total
new_sessionemail; optional name, phonesession_id, session_name
curl -X POST "http://centralai.daffodil-bd.com/chat/api/v1/" \
  -H "X-API-Key: YOUR_EXTERNAL_API_KEY" \
  -H "Origin: https://yourshop.com" \
  -H "Content-Type: application/json" \
  -d '{"action": "send_message", "email": "[email protected]", "message": "Do you deliver to Chattogram?"}'
{"success": true, "response": "Yes, we deliver across Bangladesh...",
 "session_id": "...", "session_name": "...", "message_count": 2}

Errors answer {"success": false, "error": "...", "code": "..."}. The codes, with their HTTP status: MISSING_API_KEY (401), INVALID_API_KEY (401), LEGACY_API_KEY_RETIRED (401), NO_DOMAINS_CONFIGURED (403), ORIGIN_NOT_ALLOWED (403), RATE_LIMIT_EXCEEDED (429), METHOD_NOT_ALLOWED (405), INVALID_JSON (400), NO_SUBSCRIPTION (403), SUBSCRIPTION_INACTIVE (403), CREDITS_EXHAUSTED (429), ACTION_REQUIRED (400), UNKNOWN_ACTION (400), EMAIL_REQUIRED (400), EMAIL_INVALID (400), MESSAGE_REQUIRED (400), AGENT_ERROR (500), AGENT_FAILED (500), INTERNAL_ERROR (500).

Never call the Chat API from a browser. The key would be in your page source, and anyone could read your customers’ conversations by guessing an email address. For chat inside a web page, use the widget.

Lead Conversion API

Tell Central AI which leads became customers, from your CRM, billing or shop, so your reports show what the agent actually won.

  • POST http://centralai.daffodil-bd.com/api/v1/leads/conversions/ — report one conversion, or a batch {"conversions": [...]} of at most 100. A batch is checked whole before anything is written.
  • GET http://centralai.daffodil-bd.com/api/v1/leads/lookup/ — find the lead a conversion would match, by external_id, email, phone.
  • No Origin header is needed. Limit: 60 requests per 60 seconds per company, shared by both.

Each conversion needs at least one match key; they are tried in this order: lead_id, external_id, email, phone, ip. Optional fields: value, currency, reference (your own id; the same reference is never counted twice), occurred_at (ISO 8601) and note. A match by ip only suggests the lead for a person on your team to confirm; report by external_id, email or phone wherever you can.

curl -X POST "http://centralai.daffodil-bd.com/api/v1/leads/conversions/" \
  -H "X-API-Key: YOUR_EXTERNAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "value": "85000.00", "currency": "BDT", "reference": "ORDER-1042"}'
{"success": true,
 "results": [{"result": "converted", "matched_on": "email", "reason": "conversion_recorded", "lead": {...}}],
 "summary": {"converted": 1, "suggested": 0, "already_converted": 0, "no_match": 0, "total": 1}}

No code at all? On Won Leads in the dashboard you can create a CRM connector: a secret URL that HubSpot, Zoho CRM, Salesforce or any JSON sender posts closed deals to.

Support Tickets API

Read the support tickets your agent raises, for a helpdesk or your own system. First set the ticket mode to External API in your agent’s settings.

MethodPathWhat
GET/api/v1/support-tickets/Your support tickets, newest first.
GET/api/v1/support-tickets/{ticket_id}/One ticket with its conversation.
PATCH/api/v1/support-tickets/{ticket_id}/update/Change status or priority. PATCH only.

List filters: status (open, in_progress, resolved, closed), priority (low, medium, high, urgent), since (ISO 8601), limit (default 50, at most 100) and offset. The update takes a JSON body with status and/or priority, by PATCH only.

curl "http://centralai.daffodil-bd.com/api/v1/support-tickets/?status=open&limit=10" \
  -H "X-API-Key: YOUR_EXTERNAL_API_KEY"

Errors answer {"error": "...", "message": "..."}; the error string is stable (API key required, Invalid API key, API key retired, Invalid JSON, Invalid status, Invalid priority, Ticket not found, Server error).

All server-to-server endpoints

MethodPathCredentialWhat
POST/chat/api/v1/ X-API-Key Chat API
POST/knowledge/api/v1/sync/ X-API-Key Knowledge Sync
POST/api/v1/leads/conversions/ X-API-Key Report won leads
GET/api/v1/leads/lookup/ X-API-Key Look up a lead
GET/api/v1/support-tickets/ X-API-Key List tickets
GET/api/v1/support-tickets/{ticket_id}/ X-API-Key Get a ticket
PATCH/api/v1/support-tickets/{ticket_id}/update/ X-API-Key Update a ticket
POST/api/v1/leads/conversions/hooks/{token}/ Connector URL CRM connector

Signed in? Full error tables for every API are on your dashboard’s API reference (Lead Conversion, Support Tickets, error shapes).

Signed in? Your own keys, endpoint addresses and the full error tables are on the API reference inside your dashboard. These public pages never show anyone’s key: examples use placeholders such as YOUR_EXTERNAL_API_KEY.