packing
19 thao tác
GET /v1/lots/{lot}/cartonsA lot's cartonsPOST /v1/lots/{lot}/cartonsAdd a carton to a lotGET /v1/cartons/{code}A carton and its fruitsPUT /v1/cartons/{code}/fruitsSet what a carton holdsPOST /v1/lots/{lot}/sealRecord a seal number (the first one packs the lot)GET /v1/lots/{lot}/packingA lot's packing and mass balanceGET /v1/palletsThe company's palletsPOST /v1/palletsCreate a palletGET /v1/pallets/{sscc}One pallet with its cartonsPUT /v1/pallets/{sscc}/cartonsSet the cartons on a palletGET /v1/growing-areas/{code}/mass-balanceHarvested against shipped kg of a growing areaGET /v1/growing-areas/{code}/harvestsHarvest declarations of a growing areaPOST /v1/growing-areas/{code}/harvestsDeclare a harvest of a growing areaPOST /v1/lots/{lot}/cartons/batchCreate up to 1,000 cartons of a lotPOST /v1/lots/{lot}/carton-contents/batchSet the contents of up to 1,000 cartons of a lotPOST /v1/harvests/batchDeclare up to 1,000 harvestsGET /v1/lots/{lot}/export-labelA lot's export carton and pallet labelsGET /v1/lots/{lot}/gs1A lot's GS1 label dataPOST /v1/lots/{lot}/export-label/printsLog a print of a lot's export labels
GET /v1/lots/{lot}/cartons
A lot's cartons
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_read · listLotCartons
The cartons of the lot by number, with their contents' count and measured weight. Allowed for platform_admin, tenant_admin and auditor (the whole tenant) and for an operator signed in with a session (only the lots of its facilities). Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code (unique within the tenant). |
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 200. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CartonPageapplication/json | One page of cartons. |
| 400 | Errorapplication/json | A bad cursor or limit, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant, or of a facility outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"tenant": "coop-dl",
"code": "C-014-0017",
"lot": "LO-260928-014",
"carton_no": 17,
"public_id": "8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"qr_url": "https://txng.theio.vn/q/8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"net_mass_kg": 8.53,
"fruit_count": 3,
"fruit_mass_kg": 8.89,
"labels_printed_at": 1790000300.5,
"created_by": "packer@coop.example",
"created_at": 1790000300.5,
"updated_at": 1790000310
}
],
"next_cursor": null
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/lots/{lot}/cartons
Add a carton to a lot
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · createCarton
A new empty carton of the lot: the next number, its code, public id and GS1 serial; creation is its label's print time. The lot must be open or closed. Audited (carton.create). Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only within its facilities); auditor and lab are refused.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code (unique within the tenant). |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
CartonCreate (không bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | CartonDetailapplication/json | The new carton. |
| 400 | Errorapplication/json | Invalid JSON, a field in the body, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant, or of a facility outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lot is not open or closed, or already has 9999 cartons. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"tenant": "coop-dl",
"code": "C-014-0017",
"lot": "LO-260928-014",
"carton_no": 17,
"public_id": "8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"qr_url": "https://txng.theio.vn/q/8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"net_mass_kg": null,
"fruit_count": 0,
"fruit_mass_kg": 0,
"labels_printed_at": 1790000300.5,
"created_by": "packer@coop.example",
"created_at": 1790000300.5,
"updated_at": 1790000300.5,
"fruits": []
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · lot_is_draft
{
"error": "lot is draft",
"code": "lot_is_draft"
}Phản hồi 409 · application/json · lot_is_packed
{
"error": "lot is packed",
"code": "lot_is_packed"
}Phản hồi 409 · application/json · too_many_cartons
{
"error": "too many cartons: a lot holds at most 9999",
"code": "too_many_cartons"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/cartons/{code}
A carton and its fruits
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_read · getCarton
The carton with the codes of its fruits. Allowed for platform_admin, tenant_admin and auditor (the whole tenant) and for an operator signed in with a session (only the lots of its facilities). Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Carton code (unique within the tenant). |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CartonDetailapplication/json | The carton. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such carton for this tenant: a carton of another tenant, or of a lot outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"tenant": "coop-dl",
"code": "C-014-0017",
"lot": "LO-260928-014",
"carton_no": 17,
"public_id": "8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"qr_url": "https://txng.theio.vn/q/8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"net_mass_kg": 8.53,
"fruit_count": 3,
"fruit_mass_kg": 8.89,
"labels_printed_at": 1790000300.5,
"created_by": "packer@coop.example",
"created_at": 1790000300.5,
"updated_at": 1790000310,
"fruits": [
"Q-014-0049",
"Q-014-0050",
"Q-014-0052"
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: C-014-0017",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/cartons/{code}/fruits
Set what a carton holds
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · setCartonContents
Replaces the carton's fruits and its weighed net mass. Every fruit must be a fruit of the carton's lot that is packable (status recorded or overridden, grade A or B: a rejected fruit cannot be packed) and in no other carton; the lot must be open or closed. Audited (carton.contents.set). Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only within its facilities); auditor and lab are refused.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Carton code (unique within the tenant). |
Nội dung yêu cầu
CartonContents (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"fruits": [
"Q-014-0049",
"Q-014-0050",
"Q-014-0052"
],
"net_mass_kg": 8.53
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CartonDetailapplication/json | The carton with its new contents. |
| 400 | Errorapplication/json | Invalid JSON, a body that is not exactly fruits and net_mass_kg, bad fruit codes or mass, a code that is not a fruit of the carton's lot, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 404 | Errorapplication/json | No such carton for this tenant: a carton of another tenant, or of a lot outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lot is not open or closed, a fruit is not packable, or a fruit is in another carton. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"tenant": "coop-dl",
"code": "C-014-0017",
"lot": "LO-260928-014",
"carton_no": 17,
"public_id": "8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"qr_url": "https://txng.theio.vn/q/8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"net_mass_kg": 8.53,
"fruit_count": 3,
"fruit_mass_kg": 8.89,
"labels_printed_at": 1790000300.5,
"created_by": "packer@coop.example",
"created_at": 1790000300.5,
"updated_at": 1790000310,
"fruits": [
"Q-014-0049",
"Q-014-0050",
"Q-014-0052"
]
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_body
{
"error": "invalid body: exactly fruits and net_mass_kg",
"code": "invalid_body"
}Phản hồi 400 · application/json · invalid_fruits
{
"error": "invalid fruits: 1 to 32 distinct fruit codes",
"code": "invalid_fruits"
}Phản hồi 400 · application/json · invalid_net_mass_kg
{
"error": "invalid net_mass_kg: a number above 0 and at most 1000",
"code": "invalid_net_mass_kg"
}Phản hồi 400 · application/json · unknown_fruit
{
"error": "unknown fruit: Q-014-0300 is not a fruit of lot LO-260928-014",
"code": "unknown_fruit"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "not found: C-014-0017",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · lot_is_packed
{
"error": "lot is packed",
"code": "lot_is_packed"
}Phản hồi 409 · application/json · fruit_not_packable
{
"error": "fruit not packable: Q-014-0007 is rejected",
"code": "fruit_not_packable"
}Phản hồi 409 · application/json · fruit_already_packed
{
"error": "fruit already packed: Q-014-0049 is in carton C-014-0016",
"code": "fruit_already_packed"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/lots/{lot}/seal
Record a seal number (the first one packs the lot)
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · sealLot
Records a seal number on the lot. The first one is the pack event: the lot must be open or closed and have at least one carton, every carton holding fruit and a net mass with every fruit still packable. An open lot is first closed in the same transaction, as a lot close does (its open or paused measurement sessions are closed and its closed_at set to the pack time; domain model closed(sealed) -> packed); the lot then becomes packed with its packed totals, and its cartons never change again. A later seal number of a packed lot is a seal change (appended). The seal itself is tenant-entered. The packing step is Device-recorded only when a packing station of the lot's facility (profile vn.agritrace.pack-station) signed pack events through ingest before this call that cover every carton with its current fruits and net mass and this seal number, from a key never revoked for compromise; the pack freezes the lot's packing evidence, so a later pack event cannot raise the sealed tier (#136). A pack event of the lot, accepted or held, whose claims name another seal number than this pack seal raises a pack_mismatch alert, and an accepted one goes back to quarantine, so the lot is on hold until a reviewer decides; the seal is still recorded. Otherwise the packing step is Self-declared. #273 (owner decision D5): the pack event is refused (409 address_not_coded, with details naming each record) while the lot's packing house, its growing area or the company profile in Viet Nam has no address picked from the official list of administrative units (a province and a commune; Viet Nam has had no district level since 2025-07-01); a later seal change of a packed lot is not checked. Audited (lot.seal). Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only within its facilities); auditor and lab are refused.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code (unique within the tenant). |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
SealRequest (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"seal_no": "0492117"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | LotPackingapplication/json | The lot's packing after the seal. |
| 400 | Errorapplication/json | Invalid JSON, a body that is not exactly seal_no, a bad seal number, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant, or of a facility outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lot cannot be sealed or packed yet (including |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"lot": "LO-260928-014",
"status": "packed",
"packed_at": 1790003600,
"cartons": 41,
"fruits": 123,
"net_mass_kg": 349.6,
"fruit_mass_kg": 364.2,
"seal_numbers": [
{
"seal_no": "0492117",
"sealed_by": "packer@coop.example",
"sealed_at": 1790003600
}
],
"mass_balance": {
"tolerance": 0.05,
"violation_count": 0,
"violations": [],
"lot": {
"exportable_fruits": 123,
"exportable_kg": 364.2,
"uncartoned_fruits": 0,
"uncartoned_kg": 0,
"violation": null
},
"area": {
"growing_area": "VN-TGOR-0387",
"season": "2026",
"harvested_kg": 1820,
"declared_kg": 1820,
"shipped_kg": 1230,
"packed_lots": 4,
"violation": null
}
}
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_body
{
"error": "invalid body: exactly seal_no",
"code": "invalid_body"
}Phản hồi 400 · application/json · invalid_seal_no
{
"error": "invalid seal_no: 1 to 64 letters, digits, '.', '_' or '-', starting with a letter or digit",
"code": "invalid_seal_no"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · lot_is_draft
{
"error": "lot is draft",
"code": "lot_is_draft"
}Phản hồi 409 · application/json · no_cartons
{
"error": "no cartons: a lot is packed into at least one carton",
"code": "no_cartons"
}Phản hồi 409 · application/json · carton_not_ready
{
"error": "carton not ready: C-014-0003 (carton_empty, carton_unweighed)",
"code": "carton_not_ready"
}Phản hồi 409 · application/json · address_not_coded
{
"error": "address not coded: pick the official province and commune of the lot's packing house VN-TGPH-021, growing area VN-TGOR-0387, company profile before packing it (Viet Nam has no district level since 2025-07-01)",
"code": "address_not_coded",
"details": [
{
"kind": "facility",
"code": "VN-TGPH-021"
},
{
"kind": "growing_area",
"code": "VN-TGOR-0387"
},
{
"kind": "company_profile",
"code": null
}
]
}Phản hồi 409 · application/json · seal_number_already_recorded
{
"error": "seal number already recorded",
"code": "seal_number_already_recorded"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/lots/{lot}/packing
A lot's packing and mass balance
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_read · getLotPacking
Packed totals, seal numbers and the mass balance: per carton (empty, unweighed, a fruit no longer packable, a fruit without a scale weight, a net mass more than 5 % off its fruits' measured weights) and for the lot's growing area and season (harvested against shipped kg, across all tenants). Allowed for platform_admin, tenant_admin and auditor (the whole tenant) and for an operator signed in with a session (only the lots of its facilities). Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code (unique within the tenant). |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LotPackingapplication/json | The lot's packing. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant, or of a facility outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"lot": "LO-260928-014",
"status": "packed",
"packed_at": 1790003600,
"cartons": 41,
"fruits": 123,
"net_mass_kg": 349.6,
"fruit_mass_kg": 364.2,
"seal_numbers": [
{
"seal_no": "0492117",
"sealed_by": "packer@coop.example",
"sealed_at": 1790003600
}
],
"mass_balance": {
"tolerance": 0.05,
"violation_count": 0,
"violations": [],
"lot": {
"exportable_fruits": 123,
"exportable_kg": 364.2,
"uncartoned_fruits": 0,
"uncartoned_kg": 0,
"violation": null
},
"area": {
"growing_area": "VN-TGOR-0387",
"season": "2026",
"harvested_kg": 1820,
"declared_kg": 1820,
"shipped_kg": 1230,
"packed_lots": 4,
"violation": null
}
}
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/pallets
The company's pallets
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_read · listPallets
#161: newest first, one page (limit, default 50, at most 200; cursor), optionally of one facility. Same roles as reading lots; an operator reads its facilities' pallets. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
facilitykhông bắt buộc | query | string | Only this facility's pallets. |
limitkhông bắt buộc | query | integer | 1 to 200 (default 50). |
cursorkhông bắt buộc | query | string | The previous page's |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | PalletPageapplication/json | One page of pallets. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token, OAuth2 access token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"sscc": "095200000000000011",
"facility": "VN-TGPH-021",
"epc": "https://id.gs1.org/00/095200000000000011",
"element_string": "(00)095200000000000011",
"carton_count": 40,
"created_by": "packer@coop.example",
"created_at": 1790000000.5,
"updated_at": 1790000060.5
}
],
"next_cursor": null
}Phản hồi 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/pallets
Create a pallet
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · createPallet
#161: an empty pallet of one of the company's approved facilities, identified by an SSCC: allocated from the platform's GS1 company prefix (409 while none is configured), or one of the company's own GS1 membership. The SSCC is unique within the company (pallets and container loads). Same roles as writing lots; an operator within its facilities. Audited (pallet.create) in the company's activity log. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
PalletCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"facility": "VN-TGPH-021"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | Palletapplication/json | The pallet. |
| 400 | Errorapplication/json | An unknown or malformed field (an unknown facility, an SSCC whose check digit is wrong or that carries the platform's prefix), invalid JSON, a bad X-Request-Id or Idempotency-Key. |
| 401 | Errorapplication/json | No valid session, API token, OAuth2 access token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The facility is a proposal not yet approved, the SSCC is in use by the company, no GS1 company prefix is configured; or the Idempotency-Key's first request is still running. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"sscc": "095200000000000011",
"facility": "VN-TGPH-021",
"epc": "https://id.gs1.org/00/095200000000000011",
"element_string": "(00)095200000000000011",
"cartons": [],
"created_by": "packer@coop.example",
"created_at": 1790000000.5,
"updated_at": 1790000000.5
}Phản hồi 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}Phản hồi 400 · application/json · invalid_sscc
{
"error": "invalid sscc: 18 digits with a valid GS1 check digit",
"code": "invalid_sscc"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}Phản hồi 409 · application/json · sscc
{
"error": "sscc already in use by the company",
"code": "sscc_already_in_use_by_the_company"
}Phản hồi 409 · application/json · prefix
{
"error": "prefix not configured: the platform has no GS1 company prefix yet; enter a number of the company's own GS1 membership",
"code": "prefix_not_configured"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/pallets/{sscc}
One pallet with its cartons
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_read · getPallet
#161: the pallet, its GS1-128 element string and EPC, and the cartons on it. Same roles as reading lots. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
ssccbắt buộc | path | string | The pallet's SSCC (18 digits). |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | Palletapplication/json | The pallet. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token, OAuth2 access token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such pallet for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"sscc": "095200000000000011",
"facility": "VN-TGPH-021",
"epc": "https://id.gs1.org/00/095200000000000011",
"element_string": "(00)095200000000000011",
"cartons": [
{
"code": "C-014-0001",
"lot": "LO-260928-014",
"epc": "https://id.gs1.org/01/09520000000011/21/Xk3pQ9vT2mLr7Wb4Yz1A"
}
],
"created_by": "packer@coop.example",
"created_at": 1790000000.5,
"updated_at": 1790000060.5
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: 095200000000000011",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/pallets/{sscc}/cartons
Set the cartons on a pallet
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · setPalletCartons
#161: replaces what the pallet holds (0 to 200 cartons): cartons of packed lots of the pallet's facility, each on one pallet at most. The lot's EPCIS document then carries the aggregation of its cartons into the pallet. A pallet whose cartons left on a departed shipment never changes. #267: a writer names the cartons it read on the pallet (expected_cartons); the server checks them inside the write, after locking the pallet, and answers 409 pallet_changed when the pallet holds other cartons, so a stale write never overwrites a change made since. Same roles as writing lots. Audited (pallet.cartons.set) in the company's activity log; a refused set writes only its failed row (pallet.cartons.set.failed). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
ssccbắt buộc | path | string | The pallet's SSCC (18 digits). |
Nội dung yêu cầu
PalletCartons (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"cartons": [
"C-014-0001",
"C-014-0002"
],
"expected_cartons": [
"C-014-0001"
]
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | Palletapplication/json | The pallet with its cartons. |
| 400 | Errorapplication/json | A body other than {"cartons": [...], "expected_cartons"?: [...]}, a code that is not a carton of the company at the pallet's facility, invalid JSON or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token, OAuth2 access token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such pallet for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The pallet holds other cartons than |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"sscc": "095200000000000011",
"facility": "VN-TGPH-021",
"epc": "https://id.gs1.org/00/095200000000000011",
"element_string": "(00)095200000000000011",
"cartons": [
{
"code": "C-014-0001",
"lot": "LO-260928-014",
"epc": "https://id.gs1.org/01/09520000000011/21/Xk3pQ9vT2mLr7Wb4Yz1A"
}
],
"created_by": "packer@coop.example",
"created_at": 1790000000.5,
"updated_at": 1790000060.5
}Phản hồi 400 · application/json · invalid_cartons
{
"error": "invalid cartons: at most 200 distinct carton codes",
"code": "invalid_cartons"
}Phản hồi 400 · application/json · invalid_expected_cartons
{
"error": "invalid expected_cartons: at most 200 distinct carton codes",
"code": "invalid_expected_cartons"
}Phản hồi 400 · application/json · unknown_carton
{
"error": "unknown carton: C-014-0003",
"code": "unknown_carton"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: 095200000000000011",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · pallet_changed
{
"error": "pallet changed: it holds other cartons than the ones read; read it again",
"code": "pallet_changed"
}Phản hồi 409 · application/json · lot_not_packed
{
"error": "lot not packed: carton C-014-0003",
"code": "lot_not_packed"
}Phản hồi 409 · application/json · on_another_pallet
{
"error": "carton on another pallet: C-014-0003",
"code": "carton_on_another_pallet"
}Phản hồi 409 · application/json · pallet_departed
{
"error": "pallet departed: its cartons left on a departed shipment",
"code": "pallet_departed"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/growing-areas/{code}/mass-balance
Harvested against shipped kg of a growing area
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: growing_area_read · getGrowingAreaMassBalance
The area's harvested kg of the season (its accepted harvest and receive envelopes, as its volume, plus its self-declared harvest declarations) against the packed net mass of its packed lots of the season, both across all tenants (aggregates only), with the violation stated. The area must be readable by the caller (own or unowned). Allowed for platform_admin, tenant_admin, auditor and operator (operators read tenant-wide: a growing area carries no facility); lab is refused. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Growing area code. |
seasonbắt buộc | query | string | Season label (the calendar year by default). |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | AreaMassBalanceapplication/json | The area's mass balance. |
| 400 | Errorapplication/json | A missing or malformed season, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such growing area for this tenant: another tenant's area answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"growing_area": "VN-TGOR-0387",
"season": "2026",
"harvested_kg": 1820,
"declared_kg": 1820,
"shipped_kg": 1230,
"packed_lots": 4,
"violation": null
}Phản hồi 400 · application/json · season_is_required
{
"error": "season is required",
"code": "season_is_required"
}Phản hồi 400 · application/json · invalid_season
{
"error": "invalid season: 1 to 32 letters, digits, dots, hyphens or underscores",
"code": "invalid_season"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: VN-TGOR-0387",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/growing-areas/{code}/harvests
Harvest declarations of a growing area
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: growing_area_read · listHarvestDeclarations
The caller's tenant's own harvest declarations of the area (another tenant's are never listed; the mass balance counts them only as a sum), newest first with keyset pagination. A declaration is tenant-entered, so its source is self_declared. Allowed for platform_admin, tenant_admin, auditor and operator (operators read tenant-wide: a growing area carries no facility); lab is refused. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Growing area code. |
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 200. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | HarvestDeclarationPageapplication/json | One page of harvest declarations. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit outside 1 to 200, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such growing area for this tenant: another tenant's area answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"id": 7,
"growing_area": "VN-TGOR-0387",
"harvest_date": "2026-09-27",
"season": "2026",
"kg": 1820,
"source": "self_declared",
"declared_by": "admin@coop-dl",
"declared_at": 1790500000
}
],
"next_cursor": null
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: VN-TGOR-0387",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/growing-areas/{code}/harvests
Declare a harvest of a growing area
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: growing_area_edit · declareHarvest
Records that the area harvested kg on harvest_date: tenant-entered, so its source is self_declared (no signed harvest event backs it). Only on an area of the caller's tenant (a platform_admin also on an unowned area); one declaration per area and date, never merged or overwritten; the date may not be later than today. Its season is the ingest policy's season of the harvest date (as a lot's), and the area's mass balance counts it in harvested_kg (and declared_kg). Audited (growing_area.harvest.declare). Allowed for platform_admin and tenant_admin.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Growing area code. |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
HarvestDeclarationCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"harvest_date": "2026-09-27",
"kg": 1820
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | HarvestDeclarationapplication/json | The declaration. |
| 400 | Errorapplication/json | Invalid JSON, a body that is not exactly harvest_date and kg, a bad date (or one later than today), a kg that is not a number above 0 and at most 1,000,000, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 404 | Errorapplication/json | No such growing area for this tenant: another tenant's area answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The area already has a harvest declaration for this date. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": 7,
"growing_area": "VN-TGOR-0387",
"harvest_date": "2026-09-27",
"season": "2026",
"kg": 1820,
"source": "self_declared",
"declared_by": "admin@coop-dl",
"declared_at": 1790500000
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_body
{
"error": "invalid body: exactly harvest_date and kg",
"code": "invalid_body"
}Phản hồi 400 · application/json · invalid_harvest_date
{
"error": "invalid harvest_date: later than today",
"code": "invalid_harvest_date"
}Phản hồi 400 · application/json · invalid_kg
{
"error": "invalid kg: a number above 0 and at most 1000000",
"code": "invalid_kg"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "not found: VN-TGOR-0387",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · harvest_already_declared
{
"error": "harvest already declared: the area has a declaration for this date",
"code": "harvest_already_declared"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/lots/{lot}/cartons/batch
Create up to 1,000 cartons of a lot
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · createCartonBatch
Creates count empty cartons of the lot (the next numbers, codes, public ids and GS1 serials). Audited once (carton.batch_create). Allowed like the single carton. Atomic: the batch commits whole or not at all, in one transaction with its one audit row. Every item is validated first and every invalid item is reported (400 invalid_batch, items by index); then the items are applied in order and the first one the stored state refuses rolls the batch back and is reported (batch_rejected with the item's own status and items naming it). At most 1,000 items and a body within 1 MiB. Rate limited per tenant and caller (bursts of 10 batches, then one every 6 seconds).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code (unique within the tenant). |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
BatchCount (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"count": 40
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | CartonBatchResultapplication/json | The batch, committed. |
| 400 | Errorapplication/json | Invalid JSON, a body of the wrong shape, invalid items ( |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant, or of a facility outside an operator's scope, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lot is not open or closed; a carton past the lot's 9999 ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used before with another request (another method, path, query or body): |
| 429 | Errorapplication/json | Too many batch requests from this caller of this tenant (bursts of 10, then one every 6 seconds); nothing was done; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"batch_id": 12,
"count": 1,
"items": [
{
"tenant": "coop-dl",
"code": "C-014-0017",
"lot": "LO-260928-014",
"carton_no": 17,
"public_id": "8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"qr_url": "https://txng.theio.vn/q/8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"net_mass_kg": 8.53,
"fruit_count": 3,
"fruit_mass_kg": 8.89,
"labels_printed_at": 1790000300.5,
"created_by": "packer@coop.example",
"created_at": 1790000300.5,
"updated_at": 1790000310,
"fruits": [
"Q-014-0049",
"Q-014-0050",
"Q-014-0052"
]
}
]
}Phản hồi 400 · application/json · invalid_batch
{
"error": "invalid batch: 1 of the items failed validation",
"code": "invalid_batch",
"items": [
{
"index": 3,
"status": 400,
"error": "invalid kg: a number above 0 and at most 1000000",
"code": "invalid_kg"
}
]
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · lot_is_packed
{
"error": "lot is packed",
"code": "lot_is_packed"
}Phản hồi 409 · application/json · batch_rejected
{
"error": "batch rejected: item 5 failed",
"code": "batch_rejected",
"items": [
{
"index": 5,
"status": 409,
"error": "too many cartons: a lot holds at most 9999",
"code": "too_many_cartons"
}
]
}Phản hồi 409 · application/json · idempotency_key_already_used
{
"error": "idempotency key already used: batch 12",
"code": "idempotency_key_already_used"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json · idempotency_key_mismatch
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 422 · application/json · idempotency_key_reused_with_a_different_request
{
"error": "idempotency key reused with a different request",
"code": "idempotency_key_reused_with_a_different_request"
}Phản hồi 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/lots/{lot}/carton-contents/batch
Set the contents of up to 1,000 cartons of a lot
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · setCartonContentsBatch
Replaces the fruits and net mass of each listed carton of the lot, in request order (an item may take a fruit an earlier item removed from another carton); a carton at most once per batch. Audited once (carton.contents.batch_set). Allowed like the single contents change. Atomic: the batch commits whole or not at all, in one transaction with its one audit row. Every item is validated first and every invalid item is reported (400 invalid_batch, items by index); then the items are applied in order and the first one the stored state refuses rolls the batch back and is reported (batch_rejected with the item's own status and items naming it). At most 1,000 items and a body within 1 MiB. Rate limited per tenant and caller (bursts of 10 batches, then one every 6 seconds).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code (unique within the tenant). |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
CartonContentsBatch (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"items": [
{
"carton": "C-014-0017",
"fruits": [
"Q-014-0129",
"Q-014-0130"
],
"net_mass_kg": 6.1
}
]
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CartonContentsBatchResultapplication/json | The batch, committed. |
| 400 | Errorapplication/json | Invalid JSON, a body of the wrong shape, invalid items ( |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 404 | Errorapplication/json | No such lot for this tenant (as a missing one), or an item's carton is not one of the lot's ( |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lot is not open or closed; a fruit not packable or in another carton ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used before with another request (another method, path, query or body): |
| 429 | Errorapplication/json | Too many batch requests from this caller of this tenant (bursts of 10, then one every 6 seconds); nothing was done; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"batch_id": 12,
"count": 1,
"items": [
{
"tenant": "coop-dl",
"code": "C-014-0017",
"lot": "LO-260928-014",
"carton_no": 17,
"public_id": "8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"qr_url": "https://txng.theio.vn/q/8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60",
"net_mass_kg": 6.1,
"fruit_count": 2,
"fruit_mass_kg": 6,
"labels_printed_at": 1790000300.5,
"created_by": "packer@coop.example",
"created_at": 1790000300.5,
"updated_at": 1790000310,
"fruits": [
"Q-014-0129",
"Q-014-0130"
]
}
]
}Phản hồi 400 · application/json · invalid_batch
{
"error": "invalid batch: 1 of the items failed validation",
"code": "invalid_batch",
"items": [
{
"index": 3,
"status": 400,
"error": "invalid kg: a number above 0 and at most 1000000",
"code": "invalid_kg"
}
]
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 400 · application/json · batch_rejected
{
"error": "batch rejected: item 2 failed",
"code": "batch_rejected",
"items": [
{
"index": 2,
"status": 400,
"error": "unknown fruit: Q-999-0001 is not a fruit of lot LO-260928-014",
"code": "unknown_fruit"
}
]
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json · not_found
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 404 · application/json · batch_rejected
{
"error": "batch rejected: item 1 failed",
"code": "batch_rejected",
"items": [
{
"index": 1,
"status": 404,
"error": "not found: C-014-0999",
"code": "not_found"
}
]
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · lot_is_packed
{
"error": "lot is packed",
"code": "lot_is_packed"
}Phản hồi 409 · application/json · batch_rejected
{
"error": "batch rejected: item 4 failed",
"code": "batch_rejected",
"items": [
{
"index": 4,
"status": 409,
"error": "fruit not packable: Q-014-0131 is rejected",
"code": "fruit_not_packable"
}
]
}Phản hồi 409 · application/json · idempotency_key_already_used
{
"error": "idempotency key already used: batch 12",
"code": "idempotency_key_already_used"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json · idempotency_key_mismatch
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 422 · application/json · idempotency_key_reused_with_a_different_request
{
"error": "idempotency key reused with a different request",
"code": "idempotency_key_reused_with_a_different_request"
}Phản hồi 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/harvests/batch
Declare up to 1,000 harvests
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: growing_area_edit · declareHarvestBatch
Declares harvests across the growing areas the caller may write (tenant-entered, Self-declared, each checked like the single declaration); an area and date at most once per batch. Audited once (growing_area.harvest.batch_declare). Allowed like the single declaration. Atomic: the batch commits whole or not at all, in one transaction with its one audit row. Every item is validated first and every invalid item is reported (400 invalid_batch, items by index); then the items are applied in order and the first one the stored state refuses rolls the batch back and is reported (batch_rejected with the item's own status and items naming it). At most 1,000 items and a body within 1 MiB. Rate limited per tenant and caller (bursts of 10 batches, then one every 6 seconds).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
HarvestBatch (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"items": [
{
"growing_area": "VN-DL-SR-0123",
"harvest_date": "2026-09-27",
"kg": 1820
}
]
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | HarvestBatchResultapplication/json | The batch, committed. |
| 400 | Errorapplication/json | Invalid JSON, a body of the wrong shape, invalid items ( |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). Also a |
| 404 | Errorapplication/json | An item's area is missing or another tenant's ( |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | An item's area already has a declaration for its date ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used before with another request (another method, path, query or body): |
| 429 | Errorapplication/json | Too many batch requests from this caller of this tenant (bursts of 10, then one every 6 seconds); nothing was done; retry after |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"batch_id": 12,
"count": 1,
"items": [
{
"id": 7,
"growing_area": "VN-TGOR-0387",
"harvest_date": "2026-09-27",
"season": "2026",
"kg": 1820,
"source": "self_declared",
"declared_by": "admin@coop-dl",
"declared_at": 1790500000
}
]
}Phản hồi 400 · application/json · invalid_batch
{
"error": "invalid batch: 1 of the items failed validation",
"code": "invalid_batch",
"items": [
{
"index": 3,
"status": 400,
"error": "invalid kg: a number above 0 and at most 1000000",
"code": "invalid_kg"
}
]
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "batch rejected: item 0 failed",
"code": "batch_rejected",
"items": [
{
"index": 0,
"status": 404,
"error": "not found: VN-DL-SR-0999",
"code": "not_found"
}
]
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · batch_rejected
{
"error": "batch rejected: item 2 failed",
"code": "batch_rejected",
"items": [
{
"index": 2,
"status": 409,
"error": "harvest already declared: the area has a declaration for this date",
"code": "harvest_already_declared"
}
]
}Phản hồi 409 · application/json · idempotency_key_already_used
{
"error": "idempotency key already used: batch 12",
"code": "idempotency_key_already_used"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json · idempotency_key_mismatch
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 422 · application/json · idempotency_key_reused_with_a_different_request
{
"error": "idempotency key reused with a different request",
"code": "idempotency_key_reused_with_a_different_request"
}Phản hồi 429 · application/json
{
"error": "too many requests",
"code": "too_many_requests"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/lots/{lot}/export-label
A lot's export carton and pallet labels
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_read · getLotExportLabel
The fields the destination market's export label prints, from the registry and the packing records (fruit name, origin, export country, orchard and packing house with their registration codes when cross-checked, packing date), a page of the selected cartons with their net mass, count and QR URL, the pallet totals and the lot's public URL, the template in force, and the problems that keep the label from being an export label (ready false). #273: the origin of a growing area coded by official administrative unit codes is its commune and province (Viet Nam has had no district level since 2025-07-01), given only with admin_units=1; an area not coded yet keeps its district and province. The company profile's address must be coded (or abroad) before the next label (address_not_coded). #288: with label_code=1 each carton also has its lookup code (label_code), the 15-character code the label prints under the carton's QR code for a person whose QR code cannot be scanned; the scan page and GET /v1/public/resolve read it. A code that is not cross-checked against the published code lists is never given. Allowed for platform_admin, tenant_admin and auditor (the whole tenant) and for an operator signed in with a session (only the lots of its facilities). Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code (unique within the tenant). |
marketbắt buộc | query | string | Destination market (ISO 3166-1 alpha-2); CN is the only one. |
fromkhông bắt buộc | query | integer | First carton number of the selection (default: the lot's first). |
tokhông bắt buộc | query | integer | Last carton number of the selection (default: the lot's last). |
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 200. |
admin_unitskhông bắt buộc | query | "0" | "1" | #273: |
label_codekhông bắt buộc | query | "0" | "1" | #288: |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | ExportLabelapplication/json | The label of the selection, one page of cartons. |
| 400 | Errorapplication/json | No or an unknown market, a bad carton range, cursor or limit, |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant, or of a facility outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"lot": "LO-260928-014",
"market": "CN",
"lot_status": "packed",
"template_version": 0,
"template": {
"mark": {
"zh": "输往中华人民共和国",
"en": "Exported to the People's Republic of China"
},
"export_country": {
"zh": "越南",
"en": "Vietnam"
},
"products": {
"durian": {
"zh": "榴莲",
"en": "Durian"
}
},
"fields": {
"fruit": {
"zh": "水果名称",
"en": "Fruit",
"required": true
},
"origin": {
"zh": "产地",
"en": "Origin",
"required": true
},
"export_country": {
"zh": "出口国家",
"en": "Country of export",
"required": true
},
"orchard": {
"zh": "果园名称或注册号",
"en": "Orchard name or registration number",
"required": true
},
"packing_house": {
"zh": "包装厂名称或注册号",
"en": "Packing house name or registration number",
"required": true
},
"producer": {
"zh": "生产商",
"en": "Producer",
"required": false
},
"packing_date": {
"zh": "包装日期",
"en": "Packing date",
"required": false
},
"net_mass": {
"zh": "净重",
"en": "Net weight",
"required": false
},
"count": {
"zh": "数量",
"en": "Count",
"required": false
},
"lot": {
"zh": "批号",
"en": "Lot",
"required": false
}
},
"require_cross_checked_codes": true,
"source": "Durian export label clause as published for the Malaysia and Laos protocols with China (same clause family as the Vietnam-China protocol of 2022-07-11; to be confirmed against the Vietnamese text): https://www.doa.gov.my/doa/resources/aktiviti_sumber/sumber_awam/maklumat_biosekuriti/pamplet_prosedur_pengeksportan_durian_segar_ke_china.pdf"
},
"fields": {
"fruit": {
"zh": "榴莲",
"en": "Durian"
},
"origin": {
"province": "Đắk Lắk",
"district": "Krông Pắc"
},
"export_country": {
"zh": "越南",
"en": "Vietnam"
},
"orchard": {
"name": "Vườn Bà Tư",
"code": null,
"check": "no_list",
"cross_checked": false
},
"packing_house": {
"name": "Nhà đóng gói Ea Kly",
"code": null,
"check": "no_list",
"cross_checked": false
},
"producer": {
"legal_name": "Hợp tác xã Sầu riêng Ea Kly",
"address": "Thôn 2, xã Ea Kly",
"district": "Krông Pắc",
"province": "Đắk Lắk",
"country": "VN"
},
"packing_date": "2026-09-30"
},
"pallet": {
"from": 1,
"to": 2,
"cartons": 2,
"fruit_count": 6,
"net_mass_kg": 17.4,
"qr_url": "https://txng.theio.vn/l/5b0e4c2a9d8f4e1a8c7b6a5d4e3f2a1b"
},
"cartons": [
{
"code": "C-014-0001",
"carton_no": 1,
"net_mass_kg": 8.5,
"fruit_count": 3,
"qr_url": "https://txng.theio.vn/q/8c1f0e2d9b7a4c3e8f6a1b2d3c4e5f60"
}
],
"problems": [
"orchard_code_not_cross_checked",
"packing_house_code_not_cross_checked"
],
"ready": false,
"next_cursor": "eyJjYXJ0b25fbm8iOjF9"
}Phản hồi 400 · application/json · market_required
{
"error": "market is required",
"code": "market_is_required"
}Phản hồi 400 · application/json · invalid_market
{
"error": "invalid market: one of CN",
"code": "invalid_market"
}Phản hồi 400 · application/json · invalid_from
{
"error": "invalid from: a carton number from 1 to 9999",
"code": "invalid_from"
}Phản hồi 400 · application/json · invalid_to
{
"error": "invalid to: not below from",
"code": "invalid_to"
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · bad_admin_units
{
"error": "bad admin_units",
"code": "bad_admin_units"
}Phản hồi 400 · application/json · bad_label_code
{
"error": "bad label_code",
"code": "bad_label_code"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/lots/{lot}/gs1
A lot's GS1 label data
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_read · getLotGs1Labels
#161: what the lot's GS1 labels print: the lot's GS1-128 element string (01)(10) and its lot-level Digital Link (resolved once the lot is sealed), a page of its cartons (limit, default 50, at most 200; cursor) with (01)(10)(21) and their Digital Links, and the pallets holding its cartons with (00). Same roles as reading the lot. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code. |
limitkhông bắt buộc | query | integer | 1 to 200 (default 50). |
cursorkhông bắt buộc | query | string | The previous page's |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LotGs1Labelsapplication/json | The lot's GS1 label data. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token, OAuth2 access token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"lot": "LO-260928-014",
"gtin": "09520000000011",
"sealed": true,
"element_string": "(01)09520000000011(10)LO-260928-014",
"digital_link": "https://txng.theio.vn/01/09520000000011/10/LO-260928-014",
"cartons": [
{
"code": "C-014-0001",
"carton_no": 1,
"epc": "https://id.gs1.org/01/09520000000011/21/Xk3pQ9vT2mLr7Wb4Yz1A",
"element_string": "(01)09520000000011(10)LO-260928-014(21)Xk3pQ9vT2mLr7Wb4Yz1A",
"digital_link": "https://txng.theio.vn/01/09520000000011/10/LO-260928-014/21/Xk3pQ9vT2mLr7Wb4Yz1A"
}
],
"pallets": [
{
"sscc": "095200000000000011",
"element_string": "(00)095200000000000011",
"lot_cartons": 40,
"first_carton": 1,
"last_carton": 40,
"cartons": 40
}
],
"next_cursor": null
}Phản hồi 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/lots/{lot}/export-label/prints
Log a print of a lot's export labels
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · recordExportLabelPrint
Records that the carton labels (kind carton) or the pallet label (kind pallet) of the cartons numbered from to to (default: the whole lot) were printed for market, with the template version printed. The body carries the template_version and the carton count (cartons, ExportLabel.pallet.cartons) of the label the console read and prints. Refused (409 label_not_ready, naming the problems) when the label is not ready for export, so the print log holds only export labels, and (409 label_changed) when the template version in force or the selection's carton count differs from what was sent, so the log never names a version or a range that was not printed. Raises no trust tier. Audited (export_label.print, in the same transaction). Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only within its facilities); auditor and lab are refused.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code (unique within the tenant). |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
ExportLabelPrintCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"market": "CN",
"kind": "carton",
"from": 1,
"to": 2,
"template_version": 0,
"cartons": 2
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | ExportLabelPrintapplication/json | The print log entry. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field or a bad value, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant, or of a facility outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The label is not ready for export (label_not_ready: the error names every problem, ExportLabel.problems), or it changed since the console read it (label_changed: the template version in force or the selection's carton count is not the one sent), so nothing is logged. Or the Idempotency-Key's first request is still running ( |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": 7,
"lot": "LO-260928-014",
"market": "CN",
"kind": "carton",
"from": 1,
"to": 2,
"cartons": 2,
"template_version": 0,
"printed_by": "packer@coop.example",
"printed_at": 1790000400.5
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_market
{
"error": "invalid market: one of CN",
"code": "invalid_market"
}Phản hồi 400 · application/json · invalid_kind
{
"error": "invalid kind: carton or pallet",
"code": "invalid_kind"
}Phản hồi 400 · application/json · invalid_to
{
"error": "invalid to: not below from",
"code": "invalid_to"
}Phản hồi 400 · application/json · invalid_template_version
{
"error": "invalid template_version: an integer from 0 to 2147483647, as read from the label",
"code": "invalid_template_version"
}Phản hồi 400 · application/json · invalid_cartons
{
"error": "invalid cartons: an integer from 0 to 9999, as read from the label",
"code": "invalid_cartons"
}Phản hồi 400 · application/json · unknown_fields
{
"error": "unknown fields: copies",
"code": "unknown_fields"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · not_ready
{
"error": "label not ready: orchard_code_not_cross_checked, packing_house_code_not_cross_checked",
"code": "label_not_ready"
}Phản hồi 409 · application/json · label_changed
{
"error": "label changed: template version 1 is in force, not 0",
"code": "label_changed"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}