Create A Ticket
Create a ticket on behalf of an end user with POST /tickets.
Create a ticket on the desk the token belongs to. The requester is the end user
you are filing for, keyed by email. That user is created on first use. The
token is only the channel: the agent UI shows "API Via {token name}" so it is
clear how the ticket arrived.
Body
Example
curl -X POST https://acme.headoni.app/api/v1/tickets \
-H "Authorization: Bearer hd_your_secret_here" \
-H "Content-Type: application/json" \
-d '{
"email": "alice@example.com",
"name": "Alice",
"subject": "Login broken on staging",
"body": "I loop back to /sign-in after typing my email.",
"priority": "high"
}'const res = await fetch("https://acme.headoni.app/api/v1/tickets", {
method: "POST",
headers: {
Authorization: "Bearer hd_your_secret_here",
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "alice@example.com",
name: "Alice",
subject: "Login broken on staging",
body: "I loop back to /sign-in after typing my email.",
priority: "high",
}),
});
const { ticket } = await res.json();Response
201 Created. The response is minimal. Read the full ticket back with
Get A Ticket.
{
"ticket": {
"id": "1490375649312800768",
"number": 1247,
"subject": "Login broken on staging",
"priority": "high",
"requester": { "email": "alice@example.com" }
}
}Errors
| Status | error | Meaning |
|---|---|---|
| 400 | invalid_body | A field is missing or malformed. See issues. |
| 400 | department_not_found | departmentId is not on this desk or is deleted. |
| 400 | ticket_type_not_found | ticketTypeId is not on this desk or is archived. |
| 401 | unauthenticated | Missing or invalid token. |
| 403 | insufficient_scope | Token lacks tickets:create. |
| 403 | token_desk_mismatch | Token belongs to a different desk than the host. |