Aller au contenu
Vérifié

Ouvrir un ticket de support

Déposez un ticket sur le guichet de votre forfait depuis du code externe, et interrogez-le jusqu'à ce que quelqu'un réponde.

ticket_api_submit ouvre un ticket sur le guichet que possède le forfait de votre clé API, le même guichet que gère l'écran Ticketing du tableau de bord. ticket_api_get en relit un, réponses publiques comprises : tout ce qu'il faut pour construire un formulaire « contactez-nous » adossé à un vrai guichet plutôt qu'à une boîte mail.

Méthodes

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.

Pas à pas

Soumettre le ticket

name, email et details sont obligatoires. L'e-mail sert aussi de clé de recherche dans le carnet de contacts : renvoyer depuis la même adresse se rattache au même contact, comme le fait ajouter un contact.

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. L'interroger pour une réponse

Conservez data.id de l'appel d'envoi et relisez-le avec ticket_api_get chaque fois que vous voulez vérifier s'il y a du mouvement ; interactions ne porte que le fil public, les notes internes du guichet sont filtrées avant que cette méthode ne réponde.

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

La réponse

Les deux méthodes répondent avec la même vue de ticket étroite et sûre pour l'extérieur, sans identifiant de propriétaire ni état interne :

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 ajoute une clé de plus, interactions, un tableau de { direction, from, channel, body, ts } dans l'ordre du fil, vide tant que quelqu'un du guichet (ou le demandeur, par un autre canal) n'a pas répondu.

Erreurs

Suite