Tickets API Reference
Authentication
Every site has one API key (shown on the site page, looks like ak_...). Send it on every request:
Authorization: Bearer ak_..., otherwise you get 401 {"error":"unauthorized"}.
If a key leaks, click "Rotate" on the site page — the old key stops working immediately.
GET /api/v1/tickets — List tickets
| Parameter | Description |
|---|---|
status | open | done | all (default all) |
after_id | When > 0, only tickets with id > after_id are returned, ascending (for incremental polling) |
limit | ≤ 100, default 100 |
curl -H "Authorization: Bearer ak_xxx" \
"https://aicustomerbot.com/api/v1/tickets?status=open&after_id=0"
# {"site":"My Shop","tickets":[{"id":12,"question":"...","email":"","status":"open", ...}]}
Polling recipe: first call with after_id=0 pulls everything; remember the largest id.
Then call with after_id=largest id every 30–60s and append the ascending list.
GET /api/v1/tickets/{id} — Ticket detail
curl -H "Authorization: Bearer ak_xxx" \
https://aicustomerbot.com/api/v1/tickets/12
# {"site":"My Shop","ticket":{"id":12,...,"messages":[{"role":"user","content":"...","created_at":"..."}]}}
If the ticket is linked to a widget conversation (conv_id > 0), all messages of that conversation are included.
POST /api/v1/tickets/{id}/status — Update status
curl -X POST -H "Authorization: Bearer ak_xxx" -H "Content-Type: application/json" \
-d '{"status":"done"}' https://aicustomerbot.com/api/v1/tickets/12
# {"ok":true} # status must be open | done
Webhook (push instead of poll)
Set webhook_url in Site Settings and every new ticket is POSTed:
{"event":"ticket.created",
"ticket":{"id":12,"site":"My Shop","question":"...","email":"","note":"",
"page_url":"https://...","status":"open","created_at":"2026-10-25T10:00:00+00:00"}}
Minimal receiver (Flask, 3 lines):
@app.post("/hook")
def hook():
t = request.json["ticket"]; print(t["id"], t["question"]); return {"ok": True}
Failed notifications are not retried — run the after_id incremental poll as a fallback.
Telegram push
- In Telegram find @BotFather →
/newbot→ get a bot token (123456:ABC-...). - Send the bot any message from your own Telegram.
- Open
https://api.telegram.org/bot<TOKEN>/getUpdatesand find"chat":{"id":number}— that is your chat_id (negative for groups). - Paste token and chat_id into Site Settings; new tickets are pushed to that chat automatically.