Skip to main content

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.

EndpointPermission
POST /api/v1/ticketstickets:create
GET /api/v1/ticketstickets:read
GET /api/v1/tickets/:idtickets:read
POST /api/v1/tickets/:id/activate · /deactivate · /canceltickets:update
DELETE /api/v1/tickets/:idtickets: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
}
]
}
FieldTypeDescription
iduuid
codestringCredential 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.
codeTypeenumQR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC.
namestring | nullFree name.
statusenumEffective state: ACTIVE, INACTIVE, COMPLETED, EXPIRED, CANCELLED (see state machine).
expiresAtISO 8601 UTC | nullnull = never expires.
isExpiredbooleanexpiresAt has passed (regardless of status).
allowedDevicesobject[]Devices where it can be used: { id, serial, name }. [] = all the account's devices.
deliveryTotal / deliveryUsedintegerWithdrawal items / how many were used.
returnTotal / returnUsedintegerReturn items / how many were used.
pendingReturnsintegerReturnable withdrawals delivered that have not come back yet.
itemsobject[]Only in the detail and write responses (not in the list). In creation order.
items[].iduuidItem id.
items[].productobjectProduct of the account: { id, sku, name }.
items[].serialNumberstring | nullSpecific unit (serialized product) or null.
items[].isReturnbooleantrue = return; false = withdrawal.
items[].isReturnablebooleanReturnable withdrawal: what is delivered must come back. Always false if isReturn.
items[].isReusablebooleanWhat comes back becomes available to deliver again. Only on returns or returnable withdrawals; otherwise false.
items[].usedAtISO 8601 UTC | nullWhen the item was used; null = unused.
items[].returnedAtISO 8601 UTC | nullReturnable 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:

  1. CANCELLED: cancelled (final).
  2. 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.
  3. INACTIVE: paused with deactivate.
  4. EXPIRED: expiresAt has passed.
  5. ACTIVE: everything else.
ActionAllowed from (effective)ResultBlocked (409 tickets.not_editable)
POST /:id/activateACTIVE, INACTIVE, EXPIREDStores ACTIVE. An expired ticket stays EXPIRED: the expiration cannot be changed.CANCELLED, COMPLETED
POST /:id/deactivateACTIVE, INACTIVE, EXPIREDStores INACTIVE.CANCELLED, COMPLETED
POST /:id/cancelACTIVE, INACTIVE, EXPIREDStores CANCELLED.CANCELLED, COMPLETED
  • An INACTIVE ticket neither picks up nor returns anything, not even pending returnable pick-ups, until it is reactivated. Its pinned units stay held.
  • An EXPIRED or CANCELLED ticket 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 code reserved.

Item rules​

Each entry of items is one unit (two gloves = two entries) and carries exactly one of sku, productId or serialNumber.

  • serialNumber identifies 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/productId a product with serial numbers: any unit of the product is valid; the one the locker reports on receipt is recorded.
  • isReturnable is ignored with isReturn: true; isReusable is 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.

FieldTypeRequiredLimits
codestringyes1–64; unique in the account
codeTypeenumno (default QR)QR, NFC, CODE128, CODE39, PDF417, EAN13, UPCA, MRZ, GENERIC (case-insensitive: qr = QR)
namestring | nullno (default null)Max 200; empty = null
expiresAtISO 8601 with offset | nullno (default null = never expires)Must be in the future
allowedDeviceIdsstring[]no (default [] = all)Max 1000, not repeated, devices of the account by id or serial
itemsobject[]yes1–1000
items[].skustringone of the threeMax 64
items[].productIduuidone of the threeA product of the account
items[].serialNumberstringone of the threeMax 64; a unit of the account
items[].isReturnbooleanno (default false)
items[].isReturnablebooleanno (default false)Withdrawals only
items[].isReusablebooleanno (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 code returns 409: 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 returns 409 tickets.serial_unavailable.
  • Item errors carry errors[].field with the path (items[2].serialNumber).

Errors​

HTTPcodeWhen
400tickets.account_not_easThe key's account is not EAS.
400tickets.expires_in_pastexpiresAt is not in the future.
400tickets.code_requiredcode empty after trimming.
400tickets.item_identifierAn item with no identifier or with more than one.
400tickets.item_product_not_foundsku/productId does not exist in the account.
400tickets.serial_not_foundSerial not registered in the account.
400tickets.serial_duplicatedSerial repeated in the ticket.
400tickets.device_not_in_accountAn allowedDeviceIds entry is not a device of the account (neither by id nor by serial).
409tickets.code_takencode already used by a ticket or a user code of the account.
409tickets.serial_unavailableWithdrawal of a unit that is RETIRED, OUT or reserved in another current ticket.
409tickets.serial_in_deviceReturn of a unit loaded in a device.
422validation.failedInvalid body, empty items, repeated allowedDeviceIds, unknown field.

List tickets​

GET /api/v1/tickets

Permission: tickets:read. Returns tickets without items; GET /:id includes them.

QueryTypeRequiredDefaultLimits / values
pageintegerno1≥ 1
pageSizeintegerno501–200
sortByenumnocreatedAtcreatedAt, updatedAt, expiresAt, name (null values last)
sortOrderenumnodescasc, desc
statusenumno— (all)Effective state: ACTIVE, INACTIVE, COMPLETED, EXPIRED, CANCELLED
searchstringno—Max 100. Case-insensitive "contains" on code or name.
fromISO 8601no—createdAt ≥ from (inclusive).
toISO 8601no—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 paramTypeDescription
idstringTicket 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.

HTTPcodeWhen
404tickets.not_foundDoes not exist or belongs to another account.
409tickets.not_editableEffective 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.

HTTPcodeWhen
404tickets.not_foundDoes not exist, was already deleted or belongs to another account.
409tickets.has_pending_returnsIt has returnable withdrawals still out.