Skip to content
Verified

Open a support ticket

File a ticket on your plan's desk from outside code, and poll it until someone replies.

ticket_api_submit opens a ticket on the desk your API key's plan owns, the same desk the dashboard's Ticketing screen manages. ticket_api_get reads one back, including the public replies, everything you need to build a "contact us" form backed by a real desk instead of a mailbox.

Methods

POST/cpi/ticket_api_submit
user

API: Submit Ticket

External service: opens a ticket on the desk owned by the API key. Requires a plan with full API access.

POST/cpi/ticket_api_get
user

API: Get Ticket

External service: one ticket with its public interactions. Internal notes are never returned.

Walkthrough

Submit the ticket

name, email and details are required. The email doubles as the contact-book lookup: resubmitting from the same address links to the same contact, the way add a contact does.

curl -s https://xuda.ai/cpi/ticket_api_submit \
  -H 'content-type: application/json' \
  -d '{
    "api_key": "YOUR_API_KEY",
    "name": "Priya Shah",
    "email": "[email protected]",
    "subject": "Cannot export invoices",
    "details": "The export button on the invoices page does nothing.",
    "priority": 2
  }'
const res = await fetch('https://xuda.ai/cpi/ticket_api_submit', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    name: 'Priya Shah',
    email: '[email protected]',
    subject: 'Cannot export invoices',
    details: 'The export button on the invoices page does nothing.',
    priority: 2,
  }),
});
const { code, data } = await res.json();
if (code > 0) console.log(data.ticket_no, data.id);
import requests

res = requests.post(
    'https://xuda.ai/cpi/ticket_api_submit',
    json={
        'api_key': 'YOUR_API_KEY',
        'name': 'Priya Shah',
        'email': '[email protected]',
        'subject': 'Cannot export invoices',
        'details': 'The export button on the invoices page does nothing.',
        'priority': 2,
    },
)
body = res.json()
if body['code'] > 0:
    print(body['data']['ticket_no'], body['data']['id'])

2. Poll it for a reply

Save data.id from the submit call and read it back with ticket_api_get whenever you want to check for movement; interactions only ever carries the public thread, internal desk notes are filtered out before this method answers.

curl -s https://xuda.ai/cpi/ticket_api_get \
  -H 'content-type: application/json' \
  -d '{"api_key":"YOUR_API_KEY","ticket_id":"tkt_3b7a10982341"}'
const res = await fetch('https://xuda.ai/cpi/ticket_api_get', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ api_key: 'YOUR_API_KEY', ticket_id: 'tkt_3b7a10982341' }),
});
const { code, data } = await res.json();
if (code > 0) console.log(data.status, data.interactions.length);
import requests

res = requests.post(
    'https://xuda.ai/cpi/ticket_api_get',
    json={'api_key': 'YOUR_API_KEY', 'ticket_id': 'tkt_3b7a10982341'},
)
body = res.json()
if body['code'] > 0:
    print(body['data']['status'], len(body['data']['interactions']))

The response

Both methods answer the same narrow, external-safe ticket view, no owner ids, no internal state:

json
{
  "code": 1,
  "data": {
    "ticket_no": "TK-1042",
    "id": "tkt_3b7a10982341",
    "source": "api",
    "channel": "api",
    "status": "open",
    "status_stage": "new",
    "subject": "Cannot export invoices",
    "details": "The export button on the invoices page does nothing.",
    "topic": null,
    "subtopic": null,
    "requester": {
      "name": "Priya Shah",
      "email": "[email protected]",
      "phone": "",
      "company": ""
    },
    "reference_id": null,
    "priority": 2,
    "due_ts": null,
    "date_created_ts": 1737042311422,
    "last_activity_ts": 1737042311422,
    "status_ts": 1737042311422
  }
}

ticket_api_get adds one more key, interactions, an array of { direction, from, channel, body, ts } in thread order, empty until someone on the desk (or the requester, over another channel) replies.

Errors

Next