Skip to main content

Code Reservation

Code reservation collection manages the batch reservation of unique identifier codes for specific entities, purposes, or export operations, providing tracking and export capabilities for reserved code sets.

The code_reservation Object

Code reservation collection handles the allocation and management of batches of unique codes for specific use cases, supporting various export formats and maintaining reservation status and quantities.

Field NameTypeDescription
iduuidPrimary key. Unique identifier for the code reservation (UUID format).
user_createdobjectUser who created the code reservation. Read-only. Links to directus_users.
date_createddatetimeTimestamp in ISO 8601 when the code reservation was created. Read-only.
user_updatedobjectUser who last updated the code reservation. Read-only. Links to directus_users.
date_updateddatetimeTimestamp in ISO 8601 when the code reservation was last updated. Read-only.
reserved_forobjectOrganisation this set of codes is reserved for. Links to organisation.
code_typestringType of codes being reserved (e.g., "sgtin", "sscc", "grai", "short_code").
quantityintegerNumber of codes requested for reservation.
statusstringCurrent status of the reservation. Default: "new". Values: "new", "in_progress", "complete", "error".
export_typestringFormat for code export. Default: "csv". Values: "csv", "json", "xml", etc.
export_fileobjectGenerated export file containing the reserved codes. Links to directus_files.
url_suffixstringOptional URL suffix to append to generated digital links.
productstringProduct identifier the reserved codes are associated with (primary key from product collection).
quantity_reservedintegerNumber of codes successfully reserved.
error_messagestringError message if the reservation failed during processing.
reference_idstringOptional reference identifier for tracking purposes (e.g., purchase order, batch name).
purchase_orderobjectPurchase order associated with this reservation.
codesarray of objectsUnique codes included in this reservation.

Sub-Objects

User Object (user_created, user_updated)

See Users for the full schema.

Organisation Object (reserved_for)

See Organisation for the full schema.

File Object (export_file)

See Files for the full schema.


List Code Reservations

List existing code reservations.

GET /items/code_reservation

Query Parameters

Supports all global query parameters.

Returns

An array of up to limit code reservation objects. If no items are available, data will be an empty array.


Retrieve a Code Reservation

Retrieve a specific code reservation by ID.

GET /items/code_reservation/:id

Returns

Returns a code reservation object if a valid primary key was provided.


Create a Code Reservation

Create a new code reservation.

POST /items/code_reservation

{
"reserved_for": "/417/9312345000012",
"code_type": "sgtin",
"quantity": 100,
"export_type": "csv",
"product": "/01/19361758000003",
"reference_id": "BATCH-2024-001"
}

Query Parameters

Supports all global query parameters.

Request Body

A partial code reservation object.

Returns

Returns the code reservation object for the created code reservation.


Update a Code Reservation

Update an existing code reservation.

PATCH /items/code_reservation/:id

{
"status": "complete",
"quantity_reserved": 100,
"reference_id": "BATCH-2024-001-UPDATED"
}

Query Parameters

Supports all global query parameters.

Request Body

A partial code reservation object.

Returns

Returns the code reservation object for the updated code reservation.


Delete a Code Reservation

Delete an existing code reservation.

DELETE /items/code_reservation/:id

Returns

Empty body.


Sample Data

IDReserved ForCode TypeQuantityStatusProductReference ID
03343178-982f-4b83-8dcb-916595070e51/417/9312345000012sgtin50complete/01/19361758000003RG-Cot-Cases
35ca5b51-8c2d-42bc-a39a-e8a897dff697/417/9312345000012sgtin100complete/01/09361758000003RG-Cot-Items
6b2f83d7-f200-4d82-a59c-969d05aacd27/417/5555999200016sgtin4complete/01/77777666100048abc-123
aea5a05e-2e12-4c41-b888-b96d34904cab/417/5555999200016sgtin5complete/01/77777666100062PO-567