CropPath for developers

API reference

packing

19 operations

GET /v1/lots/{lot}/cartons

A lot's cartons

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).

Parameters

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

cursor
optional
querystring

next_cursor of the previous page.

limit
optional
queryinteger

Page size, 1 to 200.

Responses

StatusTypeDescription
200CartonPage
application/json

One page of cartons.

400Error
application/json

A bad cursor or limit, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
}
Response 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: LO-260928-014",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/lots/{lot}/cartons

Add a carton to a lot

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

CartonCreate (optional)

Media type: application/json

Example request · application/json
{}

Responses

StatusTypeDescription
201CartonDetail
application/json

The new carton.

400Error
application/json

Invalid JSON, a field in the body, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The lot is not open or closed, or already has 9999 cartons. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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": []
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 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"
}
Response 404 · application/json
{
  "error": "not found: LO-260928-014",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · lot_is_draft
{
  "error": "lot is draft",
  "code": "lot_is_draft"
}
Response 409 · application/json · lot_is_packed
{
  "error": "lot is packed",
  "code": "lot_is_packed"
}
Response 409 · application/json · too_many_cartons
{
  "error": "too many cartons: a lot holds at most 9999",
  "code": "too_many_cartons"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/cartons/{code}

A carton and its fruits

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).

Parameters

NameInTypeDescription
code
required
pathstring

Carton code (unique within the tenant).

Responses

StatusTypeDescription
200CartonDetail
application/json

The carton.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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"
  ]
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: C-014-0017",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/cartons/{code}/fruits

Set what a carton holds

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
code
required
pathstring

Carton code (unique within the tenant).

Request body

CartonContents (required)

Media type: application/json

Example request · application/json
{
  "fruits": [
    "Q-014-0049",
    "Q-014-0050",
    "Q-014-0052"
  ],
  "net_mass_kg": 8.53
}

Responses

StatusTypeDescription
200CartonDetail
application/json

The carton with its new contents.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The lot is not open or closed, a fruit is not packable, or a fruit is in another carton.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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"
  ]
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · invalid_body
{
  "error": "invalid body: exactly fruits and net_mass_kg",
  "code": "invalid_body"
}
Response 400 · application/json · invalid_fruits
{
  "error": "invalid fruits: 1 to 32 distinct fruit codes",
  "code": "invalid_fruits"
}
Response 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"
}
Response 400 · application/json · unknown_fruit
{
  "error": "unknown fruit: Q-014-0300 is not a fruit of lot LO-260928-014",
  "code": "unknown_fruit"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 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"
}
Response 404 · application/json
{
  "error": "not found: C-014-0017",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · lot_is_packed
{
  "error": "lot is packed",
  "code": "lot_is_packed"
}
Response 409 · application/json · fruit_not_packable
{
  "error": "fruit not packable: Q-014-0007 is rejected",
  "code": "fruit_not_packable"
}
Response 409 · application/json · fruit_already_packed
{
  "error": "fruit already packed: Q-014-0049 is in carton C-014-0016",
  "code": "fruit_already_packed"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/lots/{lot}/seal

Record a seal number (the first one packs the lot)

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

SealRequest (required)

Media type: application/json

Example request · application/json
{
  "seal_no": "0492117"
}

Responses

StatusTypeDescription
201LotPacking
application/json

The lot's packing after the seal.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The lot cannot be sealed or packed yet (including address_not_coded: an address the pack event would seal is not coded yet, each record in details), or already has this seal number. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
    }
  }
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · invalid_body
{
  "error": "invalid body: exactly seal_no",
  "code": "invalid_body"
}
Response 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"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 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"
}
Response 404 · application/json
{
  "error": "not found: LO-260928-014",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · lot_is_draft
{
  "error": "lot is draft",
  "code": "lot_is_draft"
}
Response 409 · application/json · no_cartons
{
  "error": "no cartons: a lot is packed into at least one carton",
  "code": "no_cartons"
}
Response 409 · application/json · carton_not_ready
{
  "error": "carton not ready: C-014-0003 (carton_empty, carton_unweighed)",
  "code": "carton_not_ready"
}
Response 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
    }
  ]
}
Response 409 · application/json · seal_number_already_recorded
{
  "error": "seal number already recorded",
  "code": "seal_number_already_recorded"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/lots/{lot}/packing

A lot's packing and mass balance

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).

Parameters

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Responses

StatusTypeDescription
200LotPacking
application/json

The lot's packing.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
    }
  }
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: LO-260928-014",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/pallets

The company's pallets

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
facility
optional
querystring

Only this facility's pallets.

limit
optional
queryinteger

1 to 200 (default 50).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200PalletPage
application/json

One page of pallets.

400Error
application/json

A bad limit, cursor or facility, or a bad X-Request-Id.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/pallets

Create a pallet

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

PalletCreate (required)

Media type: application/json

Example request · application/json
{
  "facility": "VN-TGPH-021"
}

Responses

StatusTypeDescription
201Pallet
application/json

The pallet.

400Error
application/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.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/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.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
}
Response 400 · application/json · unknown_facility
{
  "error": "unknown facility",
  "code": "unknown_facility"
}
Response 400 · application/json · invalid_sscc
{
  "error": "invalid sscc: 18 digits with a valid GS1 check digit",
  "code": "invalid_sscc"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · facility_not_approved
{
  "error": "facility not approved",
  "code": "facility_not_approved"
}
Response 409 · application/json · sscc
{
  "error": "sscc already in use by the company",
  "code": "sscc_already_in_use_by_the_company"
}
Response 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"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/pallets/{sscc}

One pallet with its cartons

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
sscc
required
pathstring

The pallet's SSCC (18 digits).

Responses

StatusTypeDescription
200Pallet
application/json

The pallet.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such pallet for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: 095200000000000011",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/pallets/{sscc}/cartons

Set the cartons on a pallet

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
sscc
required
pathstring

The pallet's SSCC (18 digits).

Request body

PalletCartons (required)

Media type: application/json

Example request · application/json
{
  "cartons": [
    "C-014-0001",
    "C-014-0002"
  ],
  "expected_cartons": [
    "C-014-0001"
  ]
}

Responses

StatusTypeDescription
200Pallet
application/json

The pallet with its cartons.

400Error
application/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.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such pallet for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The pallet holds other cartons than expected_cartons (it changed since the writer read it), a carton's lot is not packed, a carton is on another pallet, or the pallet or a carton left on a departed shipment.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
}
Response 400 · application/json · invalid_cartons
{
  "error": "invalid cartons: at most 200 distinct carton codes",
  "code": "invalid_cartons"
}
Response 400 · application/json · invalid_expected_cartons
{
  "error": "invalid expected_cartons: at most 200 distinct carton codes",
  "code": "invalid_expected_cartons"
}
Response 400 · application/json · unknown_carton
{
  "error": "unknown carton: C-014-0003",
  "code": "unknown_carton"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: 095200000000000011",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · pallet_changed
{
  "error": "pallet changed: it holds other cartons than the ones read; read it again",
  "code": "pallet_changed"
}
Response 409 · application/json · lot_not_packed
{
  "error": "lot not packed: carton C-014-0003",
  "code": "lot_not_packed"
}
Response 409 · application/json · on_another_pallet
{
  "error": "carton on another pallet: C-014-0003",
  "code": "carton_on_another_pallet"
}
Response 409 · application/json · pallet_departed
{
  "error": "pallet departed: its cartons left on a departed shipment",
  "code": "pallet_departed"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/mass-balance

Harvested against shipped kg of a growing area

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).

Parameters

NameInTypeDescription
code
required
pathstring

Growing area code.

season
required
querystring

Season label (the calendar year by default).

Responses

StatusTypeDescription
200AreaMassBalance
application/json

The area's mass balance.

400Error
application/json

A missing or malformed season, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "growing_area": "VN-TGOR-0387",
  "season": "2026",
  "harvested_kg": 1820,
  "declared_kg": 1820,
  "shipped_kg": 1230,
  "packed_lots": 4,
  "violation": null
}
Response 400 · application/json · season_is_required
{
  "error": "season is required",
  "code": "season_is_required"
}
Response 400 · application/json · invalid_season
{
  "error": "invalid season: 1 to 32 letters, digits, dots, hyphens or underscores",
  "code": "invalid_season"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/harvests

Harvest declarations of a growing area

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).

Parameters

NameInTypeDescription
code
required
pathstring

Growing area code.

cursor
optional
querystring

next_cursor of the previous page of harvest declarations.

limit
optional
queryinteger

Page size, 1 to 200.

Responses

StatusTypeDescription
200HarvestDeclarationPage
application/json

One page of harvest declarations.

400Error
application/json

A cursor that is not one this API issued, a limit outside 1 to 200, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
}
Response 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growing-areas/{code}/harvests

Declare a harvest of a growing area

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
code
required
pathstring

Growing area code.

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

HarvestDeclarationCreate (required)

Media type: application/json

Example request · application/json
{
  "harvest_date": "2026-09-27",
  "kg": 1820
}

Responses

StatusTypeDescription
201HarvestDeclaration
application/json

The declaration.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The area already has a harvest declaration for this date. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · invalid_body
{
  "error": "invalid body: exactly harvest_date and kg",
  "code": "invalid_body"
}
Response 400 · application/json · invalid_harvest_date
{
  "error": "invalid harvest_date: later than today",
  "code": "invalid_harvest_date"
}
Response 400 · application/json · invalid_kg
{
  "error": "invalid kg: a number above 0 and at most 1000000",
  "code": "invalid_kg"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 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"
}
Response 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · harvest_already_declared
{
  "error": "harvest already declared: the area has a declaration for this date",
  "code": "harvest_already_declared"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/lots/{lot}/cartons/batch

Create up to 1,000 cartons of a lot

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).

Parameters

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

BatchCount (required)

Media type: application/json

Example request · application/json
{
  "count": 40
}

Responses

StatusTypeDescription
201CartonBatchResult
application/json

The batch, committed.

400Error
application/json

Invalid JSON, a body of the wrong shape, invalid items (invalid_batch, each one listed), an item the stored state refuses as invalid (batch_rejected) or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The lot is not open or closed; a carton past the lot's 9999 (batch_rejected, its index); or the Idempotency-Key's batch was applied more than 24 hours ago (its response is no longer stored) for this route, path id and body. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used before with another request (another method, path, query or body): idempotency_key_mismatch within 24 hours, idempotency_key_reused_with_a_different_request for a batch key older than that; nothing was done.

429Error
application/json

Too many batch requests from this caller of this tenant (bursts of 10, then one every 6 seconds); nothing was done; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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"
      ]
    }
  ]
}
Response 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"
    }
  ]
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 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"
}
Response 404 · application/json
{
  "error": "not found: LO-260928-014",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · lot_is_packed
{
  "error": "lot is packed",
  "code": "lot_is_packed"
}
Response 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"
    }
  ]
}
Response 409 · application/json · idempotency_key_already_used
{
  "error": "idempotency key already used: batch 12",
  "code": "idempotency_key_already_used"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json · idempotency_key_mismatch
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 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"
}
Response 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Response 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

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).

Parameters

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

CartonContentsBatch (required)

Media type: application/json

Example request · application/json
{
  "items": [
    {
      "carton": "C-014-0017",
      "fruits": [
        "Q-014-0129",
        "Q-014-0130"
      ],
      "net_mass_kg": 6.1
    }
  ]
}

Responses

StatusTypeDescription
200CartonContentsBatchResult
application/json

The batch, committed.

400Error
application/json

Invalid JSON, a body of the wrong shape, invalid items (invalid_batch, each one listed), an item the stored state refuses as invalid (batch_rejected) or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/json

No such lot for this tenant (as a missing one), or an item's carton is not one of the lot's (batch_rejected, its index).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The lot is not open or closed; a fruit not packable or in another carton (batch_rejected, its index); or the Idempotency-Key's batch was applied more than 24 hours ago (its response is no longer stored) for this route, path id and body. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used before with another request (another method, path, query or body): idempotency_key_mismatch within 24 hours, idempotency_key_reused_with_a_different_request for a batch key older than that; nothing was done.

429Error
application/json

Too many batch requests from this caller of this tenant (bursts of 10, then one every 6 seconds); nothing was done; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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"
      ]
    }
  ]
}
Response 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"
    }
  ]
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 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"
    }
  ]
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 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"
}
Response 404 · application/json · not_found
{
  "error": "not found: LO-260928-014",
  "code": "not_found"
}
Response 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"
    }
  ]
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · lot_is_packed
{
  "error": "lot is packed",
  "code": "lot_is_packed"
}
Response 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"
    }
  ]
}
Response 409 · application/json · idempotency_key_already_used
{
  "error": "idempotency key already used: batch 12",
  "code": "idempotency_key_already_used"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json · idempotency_key_mismatch
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 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"
}
Response 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/harvests/batch

Declare up to 1,000 harvests

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

HarvestBatch (required)

Media type: application/json

Example request · application/json
{
  "items": [
    {
      "growing_area": "VN-DL-SR-0123",
      "harvest_date": "2026-09-27",
      "kg": 1820
    }
  ]
}

Responses

StatusTypeDescription
201HarvestBatchResult
application/json

The batch, committed.

400Error
application/json

Invalid JSON, a body of the wrong shape, invalid items (invalid_batch, each one listed), an item the stored state refuses as invalid (batch_rejected) or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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 batch_rejected naming an item whose area is an unowned, seeded one and the caller no platform admin. 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).

404Error
application/json

An item's area is missing or another tenant's (batch_rejected, its index).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

An item's area already has a declaration for its date (batch_rejected, its index); or the Idempotency-Key's batch was applied more than 24 hours ago (its response is no longer stored) for this route, path id and body. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used before with another request (another method, path, query or body): idempotency_key_mismatch within 24 hours, idempotency_key_reused_with_a_different_request for a batch key older than that; nothing was done.

429Error
application/json

Too many batch requests from this caller of this tenant (bursts of 10, then one every 6 seconds); nothing was done; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
    }
  ]
}
Response 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"
    }
  ]
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 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"
}
Response 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"
    }
  ]
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 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"
    }
  ]
}
Response 409 · application/json · idempotency_key_already_used
{
  "error": "idempotency key already used: batch 12",
  "code": "idempotency_key_already_used"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json · idempotency_key_mismatch
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 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"
}
Response 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/lots/{lot}/export-label

A lot's export carton and pallet labels

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).

Parameters

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

market
required
querystring

Destination market (ISO 3166-1 alpha-2); CN is the only one.

from
optional
queryinteger

First carton number of the selection (default: the lot's first).

to
optional
queryinteger

Last carton number of the selection (default: the lot's last).

cursor
optional
querystring

next_cursor of the previous page.

limit
optional
queryinteger

Page size, 1 to 200.

admin_units
optional
query"0" | "1"

#273: 1 gives the origin as {province, commune, district} (the commune and province of a growing area coded by official administrative unit codes, district null; an area not coded yet keeps its district) and adds the producer's commune; 0 or none answers exactly as before, where a coded area's origin is null (the closed {province, district} has no commune); any other value is refused (400 bad admin_units).

label_code
optional
query"0" | "1"

#288: 1 adds each carton's lookup code (cartons[].label_code); 0 or none leaves it out and answers exactly as before; any other value is refused (400 bad label_code).

Responses

StatusTypeDescription
200ExportLabel
application/json

The label of the selection, one page of cartons.

400Error
application/json

No or an unknown market, a bad carton range, cursor or limit, admin_units or label_code not 0 or 1, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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"
}
Response 400 · application/json · market_required
{
  "error": "market is required",
  "code": "market_is_required"
}
Response 400 · application/json · invalid_market
{
  "error": "invalid market: one of CN",
  "code": "invalid_market"
}
Response 400 · application/json · invalid_from
{
  "error": "invalid from: a carton number from 1 to 9999",
  "code": "invalid_from"
}
Response 400 · application/json · invalid_to
{
  "error": "invalid to: not below from",
  "code": "invalid_to"
}
Response 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · bad_admin_units
{
  "error": "bad admin_units",
  "code": "bad_admin_units"
}
Response 400 · application/json · bad_label_code
{
  "error": "bad label_code",
  "code": "bad_label_code"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: LO-260928-014",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/lots/{lot}/gs1

A lot's GS1 label data

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
lot
required
pathstring

Lot code.

limit
optional
queryinteger

1 to 200 (default 50).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200LotGs1Labels
application/json

The lot's GS1 label data.

400Error
application/json

A bad limit or cursor, or a bad X-Request-Id.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such lot for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: LO-260928-014",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 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

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.

Parameters

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

ExportLabelPrintCreate (required)

Media type: application/json

Example request · application/json
{
  "market": "CN",
  "kind": "carton",
  "from": 1,
  "to": 2,
  "template_version": 0,
  "cartons": 2
}

Responses

StatusTypeDescription
201ExportLabelPrint
application/json

The print log entry.

400Error
application/json

Invalid JSON, an unknown field or a bad value, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/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 (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 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
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · invalid_market
{
  "error": "invalid market: one of CN",
  "code": "invalid_market"
}
Response 400 · application/json · invalid_kind
{
  "error": "invalid kind: carton or pallet",
  "code": "invalid_kind"
}
Response 400 · application/json · invalid_to
{
  "error": "invalid to: not below from",
  "code": "invalid_to"
}
Response 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"
}
Response 400 · application/json · invalid_cartons
{
  "error": "invalid cartons: an integer from 0 to 9999, as read from the label",
  "code": "invalid_cartons"
}
Response 400 · application/json · unknown_fields
{
  "error": "unknown fields: copies",
  "code": "unknown_fields"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 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"
}
Response 404 · application/json
{
  "error": "not found: LO-260928-014",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · not_ready
{
  "error": "label not ready: orchard_code_not_cross_checked, packing_house_code_not_cross_checked",
  "code": "label_not_ready"
}
Response 409 · application/json · label_changed
{
  "error": "label changed: template version 1 is in force, not 0",
  "code": "label_changed"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}