API: tickets
General conventions in How the API works.
A ticket is an anonymous credential (code) with a list of items to withdraw and/or return
at EAS devices. It only exists in EAS accounts. How items relate to products and serial numbers:
Products › How tickets use products.
| Endpoint | Permission |
|---|---|
POST /api/v1/tickets | tickets:create |
GET /api/v1/tickets | tickets:read |
GET /api/v1/tickets/:id | tickets:read |
POST /api/v1/tickets/:id/activate · /deactivate · /cancel | tickets:update |
DELETE /api/v1/tickets/:id | tickets:delete |
Cancelling leaves the ticket unusable and in the history; deleting removes it entirely and frees its code. An issued ticket cannot be edited: name, expiration, devices and items are fixed when it is created; it only changes state (activate, deactivate, cancel) or is deleted.
:id is the ticket's id or code, and allowedDeviceIds accepts ids or serials (see
References). Anything that does not exist in the account returns 404.
The ticket
{
"id": "01a1213c-2e46-7093-abdc-cabdc64db81f",
"code": "OT-2026-00123",
"codeType": "QR",
"name": "Contractor Pérez - WO 123",
"status": "ACTIVE",
"expiresAt": "2026-10-16T04:59:59.000Z",
"isExpired": false,
"allowedDevices": [{ "id": "00000000-0000-7000-8000-e30000000001", "serial": "LK20W000001", "name": "Locker Planta 1" }],
"deliveryTotal": 2,
"deliveryUsed": 0,
"returnTotal": 0,
"returnUsed": 0,
"pendingReturns": 0,
"createdAt": "2026-10-09T15:15:54.524Z",
"updatedAt": "2026-10-09T15:15:54.524Z",
"items": [
{
"id": "01a1213c-2e41-74aa-a9dc-495bc98fb8e6",
"product": { "id": "00000000-0000-7000-8000-e10000000002", "sku": "EPP-CAS", "name": "Casco de seguridad" },
"serialNumber": null,
"isReturn": false,
"isReturnable": true,
"isReusable": true,
"usedAt": null,
"returnedAt": null
},
{
"id": "01a1213c-2e41-74aa-a9dc-53650e2de9f0",
"product": { "id": "00000000-0000-7000-8000-e10000000003", "sku": "EPP-GAF", "name": "Gafas de seguridad" },
"serialNumber": "GAF-MUR8MFR2",
"isReturn": false,
"isReturnable": false,
"isReusable": false,
"usedAt": null,
"returnedAt": null
}
]
}
| Field | Type | Description |
|---|---|---|
id | uuid | |
code | string | Credential the person presents at the device. Unique in the account (no other ticket or user code). Cancelling does not release it; deleting the ticket does. |
codeType | enum | QR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC. |
name | string | null | Free name. |
status | enum | Effective state: ACTIVE, INACTIVE, COMPLETED, EXPIRED, CANCELLED (see state machine). |
expiresAt | ISO 8601 UTC | null | null = never expires. |
isExpired | boolean | expiresAt has passed (regardless of status). |
allowedDevices | object[] | Devices where it can be used: { id, serial, name }. [] = all the account's devices. |
deliveryTotal / deliveryUsed | integer | Withdrawal items / how many were used. |
returnTotal / returnUsed | integer | Return items / how many were used. |
pendingReturns | integer | Returnable withdrawals delivered that have not come back yet. |
items | object[] | Only in the detail and write responses (not in the list). In creation order. |
items[].id | uuid | Item id. |
items[].product | object | Product of the account: { id, sku, name }. |
items[].serialNumber | string | null | Specific unit (serialized product) or null. |
items[].isReturn | boolean | true = return; false = withdrawal. |
items[].isReturnable | boolean | Returnable withdrawal: what is delivered must come back. Always false if isReturn. |
items[].isReusable | boolean | What comes back becomes available to deliver again. Only on returns or returnable withdrawals; otherwise false. |
items[].usedAt | ISO 8601 UTC | null | When the item was used; null = unused. |
items[].returnedAt | ISO 8601 UTC | null | Returnable withdrawal: when it came back; null = not delivered or pending. |
State machine
One of ACTIVE, INACTIVE or CANCELLED is stored. The status the API returns is the
effective one, computed on read with this precedence:
CANCELLED: cancelled (final).COMPLETED: no unused items and no returnable withdrawals left to come back. Decided by usage at the devices; there is no action to reach it.INACTIVE: paused withdeactivate.EXPIRED:expiresAthas passed.ACTIVE: everything else.
| Action | Allowed from (effective) | Result | Blocked (409 tickets.not_editable) |
|---|---|---|---|
POST /:id/activate | ACTIVE, INACTIVE, EXPIRED | Stores ACTIVE. An expired ticket stays EXPIRED: the expiration cannot be changed. | CANCELLED, COMPLETED |
POST /:id/deactivate | ACTIVE, INACTIVE, EXPIRED | Stores INACTIVE. | CANCELLED, COMPLETED |
POST /:id/cancel | ACTIVE, INACTIVE, EXPIRED | Stores CANCELLED. | CANCELLED, COMPLETED |
- An
INACTIVEticket neither picks up nor returns anything, not even pending returnable pick-ups, until it is reactivated. Its pinned units stay held. - An
EXPIREDorCANCELLEDticket only accepts returning what was picked up and must come back. Once it expires, its pinned units become free for another ticket (there is no job: it is computed on the spot). - Activating or deactivating in the same state is idempotent.
- Cancelling keeps the history and keeps the
codereserved.
Item rules
Each entry of items is one unit (two gloves = two entries) and carries exactly
one of sku, productId or serialNumber.
serialNumberidentifies the unit and its product by itself, and cannot be repeated in the ticket.- Withdrawing a serial: the unit cannot be written off (
RETIRED), in the field (OUT) or reserved in an unused withdrawal of another current ticket. - Returning a serial: the unit cannot be loaded in a device (
IN_DEVICE). - Returning by
sku/productIda product with serial numbers: any unit of the product is valid; the one the locker reports on receipt is recorded. isReturnableis ignored withisReturn: true;isReusableis ignored on a non-returnable withdrawal.- What was already used does not change: it is history.
Issue a ticket
POST /api/v1/tickets
Permission: tickets:create.
| Field | Type | Required | Limits |
|---|---|---|---|
code | string | yes | 1–64; unique in the account |
codeType | enum | no (default QR) | QR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC (case-insensitive: qr = QR) |
name | string | null | no (default null) | Max 200; empty = null |
expiresAt | ISO 8601 with offset | null | no (default null = never expires) | Must be in the future |
allowedDeviceIds | string[] | no (default [] = all) | Max 1000, not repeated, devices of the account by id or serial |
items | object[] | yes | 1–1000 |
items[].sku | string | one of the three | Max 64 |
items[].productId | uuid | one of the three | A product of the account |
items[].serialNumber | string | one of the three | Max 64; a unit of the account |
items[].isReturn | boolean | no (default false) | |
items[].isReturnable | boolean | no (default false) | Withdrawals only |
items[].isReusable | boolean | no (default false) | Only what comes back |
{
"code": "OT-2026-00123",
"name": "Contractor Pérez - WO 123",
"expiresAt": "2026-10-15T23:59:59-05:00",
"allowedDeviceIds": [],
"items": [
{ "sku": "GUANTE-NIT-M" },
{ "sku": "GUANTE-NIT-M" },
{ "productId": "00000000-0000-7000-8000-e10000000002", "isReturnable": true, "isReusable": true },
{ "serialNumber": "DW-0001", "isReturn": true }
]
}
Response 201: the ticket with items.
- A repeated
codereturns409: it works as idempotency if you resend the same issue request. - Validation order: items → devices →
code. An identical resend with an already reserved serial first returns409 tickets.serial_unavailable. - Item errors carry
errors[].fieldwith the path (items[2].serialNumber).
Errors
| HTTP | code | When |
|---|---|---|
| 400 | tickets.account_not_eas | The key's account is not EAS. |
| 400 | tickets.expires_in_past | expiresAt is not in the future. |
| 400 | tickets.code_required | code empty after trimming. |
| 400 | tickets.item_identifier | An item with no identifier or with more than one. |
| 400 | tickets.item_product_not_found | sku/productId does not exist in the account. |
| 400 | tickets.serial_not_found | Serial not registered in the account. |
| 400 | tickets.serial_duplicated | Serial repeated in the ticket. |
| 400 | tickets.device_not_in_account | An allowedDeviceIds entry is not a device of the account (neither by id nor by serial). |
| 409 | tickets.code_taken | code already used by a ticket or a user code of the account. |
| 409 | tickets.serial_unavailable | Withdrawal of a unit that is RETIRED, OUT or reserved in another current ticket. |
| 409 | tickets.serial_in_device | Return of a unit loaded in a device. |
| 422 | validation.failed | Invalid body, empty items, repeated allowedDeviceIds, unknown field. |
List tickets
GET /api/v1/tickets
Permission: tickets:read. Returns tickets without items; GET /:id includes them.
| Query | Type | Required | Default | Limits / values |
|---|---|---|---|---|
page | integer | no | 1 | ≥ 1 |
pageSize | integer | no | 50 | 1–200 |
sortBy | enum | no | createdAt | createdAt, updatedAt, expiresAt, name (null values last) |
sortOrder | enum | no | desc | asc, desc |
status | enum | no | — (all) | Effective state: ACTIVE, INACTIVE, COMPLETED, EXPIRED, CANCELLED |
search | string | no | — | Max 100. Case-insensitive "contains" on code or name. |
from | ISO 8601 | no | — | createdAt ≥ from (inclusive). |
to | ISO 8601 | no | — | createdAt before to (exclusive). |
curl 'https://back.inssacs.com/api/v1/tickets?status=ACTIVE&search=OT-2026' \
-H 'x-api-key: ics_a1b2c3d4_e5f6...'
Response 200:
{
"data": [
{
"id": "01a1213c-2e46-7093-abdc-cabdc64db81f",
"code": "OT-2026-00123",
"codeType": "QR",
"name": "Contractor Pérez - WO 123",
"status": "ACTIVE",
"expiresAt": "2026-10-16T04:59:59.000Z",
"isExpired": false,
"allowedDevices": [{ "id": "00000000-0000-7000-8000-e30000000001", "serial": "LK20W000001", "name": "Locker Planta 1" }],
"deliveryTotal": 2,
"deliveryUsed": 0,
"returnTotal": 0,
"returnUsed": 0,
"pendingReturns": 0,
"createdAt": "2026-10-09T15:15:54.524Z",
"updatedAt": "2026-10-09T15:15:54.524Z"
}
],
"pagination": { "page": 1, "pageSize": 50, "total": 1 }
}
If the account is not EAS it returns 403 shared.scope_forbidden.
Get a ticket
GET /api/v1/tickets/:id
Permission: tickets:read.
| Path param | Type | Description |
|---|---|---|
id | string | Ticket id or code. |
Response 200: the ticket with items. Error: 404 tickets.not_found (does not exist,
belongs to another account or the account is not EAS).
Activate, deactivate and cancel
POST /api/v1/tickets/:id/activate
POST /api/v1/tickets/:id/deactivate
POST /api/v1/tickets/:id/cancel
Permission: tickets:update. Path param id (id or code). No body. See the
state machine.
Response 200: the ticket with items.
| HTTP | code | When |
|---|---|---|
| 404 | tickets.not_found | Does not exist or belongs to another account. |
| 409 | tickets.not_editable | Effective state CANCELLED or COMPLETED. |
Errors common to every endpoint: 404 (no ticket with that id or code in the account), 401 http.unauthorized,
403 http.forbidden (missing permission), 429 http.too_many_requests.
Delete a ticket
DELETE /api/v1/tickets/:id
Permission: tickets:delete. Path param id (id or code). Response 204 with no body. Works in any
state.
Deletes the ticket with its items and allowed devices: it no longer shows up in lists or by id
(404), its code becomes free for another ticket and the serialised units it was holding are
released. Deliveries and returns already made with the ticket are kept in
movements.
If the ticket has withdrawn items that must come back and have not (pendingReturns greater than
0), it is not deleted: wait for the return or cancel it.
| HTTP | code | When |
|---|---|---|
| 404 | tickets.not_found | Does not exist, was already deleted or belongs to another account. |
| 409 | tickets.has_pending_returns | It has returnable withdrawals still out. |