Hoppa till innehållet
Verifierad

Öppna ett supportärende

Skicka in ett ärende på din plans supportdisk från kod utifrån, och fråga efter svar tills någon svarar.

ticket_api_submit öppnar ett ärende på den supportdisk som din API-nyckels plan äger, samma disk som instrumentpanelens skärm Ticketing hanterar. ticket_api_get läser tillbaka ett, inklusive de publika svaren, allt du behöver för att bygga ett "kontakta oss"-formulär som backas av en riktig disk i stället för en brevlåda.

Metoder

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.

Genomgång

Skicka in ärendet

name, email och details är obligatoriska. E-postadressen fungerar också som uppslag i kontaktboken: att skicka igen från samma adress länkar till samma kontakt, på samma sätt som lägg till en kontakt gör.

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. Fråga efter svar

Spara data.id från inskicksanropet och läs tillbaka det med ticket_api_get när du vill se om något har hänt; interactions innehåller bara den publika tråden, interna anteckningar på disken filtreras bort innan den här metoden svarar.

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']))

Svaret

Båda metoderna svarar med samma smala, externt säkra ärendevy, utan ägar-id och utan internt tillstånd:

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 lägger till ytterligare en nyckel, interactions, en array av { direction, from, channel, body, ts } i trådordning, tom tills någon på disken (eller den som ber om hjälp, över en annan kanal) svarar.

Fel

Nästa