Ticket
Ticket creation
To create a ticket, send a POST request with an API key in the X-Api-Key header:
| POST https://queue-api.obmessage.ai/api/v1/tickets
X-Api-Key: {{API_KEY}}
Content-Type: application/json
|
Request example
The following body is valid JSON. Replace topic_id with the ID of a configured topic; the fields inside data depend on that topic's template.
| {
"topic_id": "519ac790-85cd-411e-b744-d21d83f21178",
"data": {
"id": 1,
"name": "Juan",
"lastname": "Pérez"
}
}
|
With API_KEY set in the environment, you can send the request using curl:
| curl --request POST 'https://queue-api.obmessage.ai/api/v1/tickets' \
--header "X-Api-Key: $API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"topic_id": "519ac790-85cd-411e-b744-d21d83f21178",
"data": {
"id": 1,
"name": "Juan",
"lastname": "Pérez"
}
}'
|
Result when creating the ticket
A 200 OK result returns a response like this one. The values are illustrative:
| {
"id": "d680591d-3636-49ae-a8a5-91542897db13",
"topic_id": "519ac790-85cd-411e-b744-d21d83f21178",
"status_id": 1,
"ticket_number": "A001",
"sla_minutes": 60,
"priority": 1,
"created_at": "2024-07-29T13:56:20.58197239Z"
}
|
If the topic has with_turn set to true, a turn is also generated. An illustrative response would be:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 | {
"id": "d680591d-3636-49ae-a8a5-91542897db13",
"topic_id": "519ac790-85cd-411e-b744-d21d83f21178",
"status_id": 1,
"ticket_number": "A001",
"turn": {
"id": 1,
"created_at": "2024-07-29T13:56:20.58197239Z",
"attention_date": "2024-07-29",
"start_hour": "09:00:00",
"end_hour": "17:00:00",
"code": "A001"
},
"sla_minutes": 60,
"priority": 1,
"created_at": "2024-07-29T13:56:20.58197239Z"
}
|
The response field types are:
| Field | Type |
id, topic_id | UUID as a string |
status_id, sla_minutes, priority | Integer |
ticket_number | String |
created_at | UTC date and time |
turn.id | Integer |
turn.created_at | UTC date and time |
turn.attention_date | Date (yyyy-mm-dd) |
turn.start_hour, turn.end_hour | Time (hh:mm:ss) |
turn.code | String |
Field description
| Field | Type | Description | Required / Default value |
topic_id | uuid | ID of the topic from which the ticket will be created. | ✔ |
status_id | int | Parent status of the ticket. | The topic’s status_default is used. If the topic does not have a default status, this field is required. |
customer_status_id | int | Customer status of the ticket. | The topic’s status_default is used. If the topic does not have a default status, the value will be null. |
assigned_user_id | uuid | ID of the user to whom the ticket will be assigned. | ✖ |
sla_minutes | int | Ticket SLA value. | If not sent, the topic’s sla_minutes value is used. |
priority | int | Ticket priority. Allowed range: [1-10]. | The default value is 1. If not sent, the topic’s default_priority value is used. |
comment | string | Comments associated with the ticket. | ✖ |
attachments | []JSON | Files attached to the ticket. The ID of the file registered in the fileserver must be sent. | ✖ |
data | JSON | Set of data associated with the ticket. This data is displayed according to the configured template. | ✔ |
turn_id | int | ID of the turn that will be used to copy the code when the ticket turn is generated. | ✖ |
attention_date | string | Service date on which the turn will be handled, in yyyy-mm-dd format. | datetime.NOW |
bot_script_id_success | int | Aless integration: ID of the script to which the bot should jump if the ticket is created successfully. | ✖ |
bot_script_id_failed | int | Aless integration: ID of the script to which the bot should jump if an error occurs while creating the ticket. | ✖ |
Errors when creating the ticket
If the topic used is outside the configured schedule, the following error is returned:
| {
"code": "error.invalid_reference",
"message": "error creating ticket: 'no schedules or turn'"
}
|
Try it in Postman