Examples
Copy-paste examples for the most common integrations, in curl, JavaScript and PHP.
Replace yourcompany.chaosdesk.io with your workspace address and $TOKEN with an API token.
Create a ticket (Zendesk-compatible API)
curl https://yourcompany.chaosdesk.io/zd/api/v2/tickets.json \
-u "integration@example.com/token:$TOKEN" \
-H "Content-Type: application/json" \
-d '{"ticket": {"subject": "Order 1042 arrived damaged",
"comment": {"body": "The box was crushed."},
"requester": {"name": "Lea Novak", "email": "lea@example.com"},
"tags": ["damaged", "order"]}}'
Find a ticket by your own id
curl "https://yourcompany.chaosdesk.io/zd/api/v2/tickets.json?external_id=order-1042" \
-u "integration@example.com/token:$TOKEN"
Search
curl -G https://yourcompany.chaosdesk.io/zd/api/v2/search.json \
--data-urlencode "query=type:ticket status:open tags:vip" \
-u "integration@example.com/token:$TOKEN"
Export every ticket (REST API, cursor pagination)
const base = 'https://yourcompany.chaosdesk.io';
let url = `${base}/api/tickets?cursor=&limit=100`;
while (url) {
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.TOKEN}`, Accept: 'application/ld+json' } });
const page = await res.json();
for (const ticket of page.member ?? page.data ?? []) console.log(ticket.id, ticket.subject);
url = page.links?.next ? new URL(page.links.next, base).toString() : null;
}
Receive a webhook (PHP)
$raw = file_get_contents('php://input');
$ts = $_SERVER['HTTP_X_DESK_TIMESTAMP'] ?? '';
$sig = $_SERVER['HTTP_X_DESK_SIGNATURE'] ?? '';
$expected = base64_encode(hash_hmac('sha256', $ts.'.'.$raw, getenv('DESK_WEBHOOK_SECRET'), true));
if (abs(time() - (int) $ts) > 300 || !hash_equals($expected, $sig)) {
http_response_code(401);
exit;
}
$event = json_decode($raw, true);
http_response_code(204);
More detail: webhooks, rate limits and pagination, the API reference.