traceability
12 operations
GET /v1/fsma.csvFSMA 204 sortable spreadsheet for a time rangeGET /v1/lots/{lot}/epcisEPCIS 2.0 document of one lotGET /v1/lots/{lot}/eventsAccepted events of one lotGET /v1/lots/{lot}/fsma.csvFSMA 204 sortable spreadsheet of one lotGET /v1/lots/{lot}/recall-export.csvFSMA-204-style export of a lot's affected records (CSV)GET /v1/lots/{lot}/recall-export.jsonFSMA-204-style export of a lot's affected records (JSON)GET /v1/lots/{lot}/captured-eventsEPCIS events partners captured for a lotPOST /v1/epcis/captureCapture an EPCIS 2.0 document from a partner systemGET /v1/records-export.csvRecords-request export of the tenant's lots in a range (CSV)GET /v1/records-export.jsonRecords-request export of the tenant's lots in a range (JSON)GET /v1/lots/{lot}/records-export.csvRecords-request export of any lot (CSV)GET /v1/lots/{lot}/records-export.jsonRecords-request export of any lot (JSON)
GET /v1/fsma.csv
FSMA 204 sortable spreadsheet for a time range
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: trace_read · getFsmaCsv
Rows for the caller's tenant with start <= event time < end. Both bounds are optional. A value that is not an ISO 8601 date-time answers 400. Each row is a critical tracking event of the caller's tenant (device events, departures and lot merges; see FsmaRow) with the FSMA 204 key data elements (#158).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
startoptional | query | string (date-time) | Inclusive lower bound, ISO 8601 date-time. |
endoptional | query | string (date-time) | Exclusive upper bound, ISO 8601 date-time. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | stringtext/csv | CSV with a header row, then one row per critical tracking event sorted by time; the columns are the FsmaRow schema's, in its order. The same columns as the per-lot export. A text cell starting with =, +, -, @, a tab or a carriage return gets a leading ' so a spreadsheet never runs it as a formula. |
| 400 | Errorapplication/json | start or end is not a valid ISO 8601 date-time, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (interim tenant_admin or platform_admin guard until per-route policies land) or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · text/csv
traceability_lot_code,critical_tracking_event,event_date,event_time,location,quantity,unit_of_measure,growing_area,parcel,producer,device_id,event_id,commodity,variety,field_name,traceability_lot_code_source,traceability_lot_code_source_reference,shipper_location_name,shipper_location_address,shipper_location_gln,recipient_location_name,recipient_location_address,recipient_location_gln,reference_document_type,reference_document_number,container,input_traceability_lot_code,input_quantity
Response 400 · application/json · bad_date
{
"error": "Invalid isoformat string: 'yesterday'",
"code": "invalid_isoformat_string"
}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"
}GET /v1/lots/{lot}/epcis
EPCIS 2.0 document of one lot
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: trace_read · getLotEpcis
An EPCIS 2.0 JSON-LD document built from the lot's accepted events, then the departure of the lot's shipment (#153): a shipping ObjectEvent (disposition in_transit, agri:shipment the shipment code) whose bizTransactionList lists the shipment's document references as urn:agritrace:bt:<type>:<number> with their CBV 2.0 types (inv, bol, desadv, cert, testres; none for a customs declaration or another document). Its eventID is derived from the departure and that list: documents amended after the departure give the event a new eventID that supersedes the earlier one (an EPCIS event is immutable and receivers deduplicate by eventID), and unchanged documents keep it. The consignee is not in it, and the public EPCIS document carries none of this. Its structure is defined by the EPCIS standard, so the schema is open (additionalProperties: true). A lot code that is not one of the tenant's (unknown, or another tenant's) answers 200 with a document without events, never 404. With version=2 the lot's daily sensor summaries follow its other events (see that parameter).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
lotrequired | path | string | Traceability lot code. |
versionoptional | query | "1" | "2" | "3" | The mapping version (#238). |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | EpcisDocumentapplication/ld+json | EPCIS document. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (interim tenant_admin or platform_admin guard until per-route policies land) or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/ld+json
{
"@context": [
"https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld"
],
"type": "EPCISDocument",
"schemaVersion": "2.0",
"epcisBody": {
"eventList": []
}
}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 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}/events
Accepted events of one lot
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: trace_read · listLotEvents
Accepted event envelopes of the caller's tenant for the lot, ordered by event time then sequence. Each item is the stored envelope (envelope version 1, see Envelope) plus _status. A lot code that is not one of the tenant's (unknown, or another tenant's) answers 200 with an empty array, never 404.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
lotrequired | path | string | Traceability lot code. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | array<StoredEnvelope>application/json | Stored envelopes (an empty array when the lot has none). |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (interim tenant_admin or platform_admin guard until per-route policies land) or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
[
{
"spec": "agritrace.iot/1.0",
"id": "3f2b8f0e-6a39-4f7e-9b1e-0d6c1c5e7a11",
"kind": "event",
"eventType": "inspect",
"device": {
"id": "knk-1",
"profile": "vn.agritrace.durian-knocker@1.0.0",
"gateway": "gw-01"
},
"time": "2026-09-30T08:00:00.000+07:00",
"seq": 0,
"context": {
"lot": "LOT-A",
"facility": "66-DL-SR-0001-CHN"
},
"readings": [
{
"capability": "produce.maturity_index",
"value": 82,
"unit": "%"
}
],
"_status": "accepted"
}
]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 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}/fsma.csv
FSMA 204 sortable spreadsheet of one lot
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: trace_read · getLotFsmaCsv
One row per critical tracking event of the lot, sorted by time: its signed device events, the departure of its shipment and the lot merges it took part in, with the FSMA 204 key data elements (#158). The columns are the FsmaRow schema's. A lot code that is not one of the tenant's (unknown, or another tenant's) answers 200 with the header row only, never 404.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
lotrequired | path | string | Traceability lot code. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | stringtext/csv | CSV with a header row, then one row per critical tracking event sorted by time; the columns are the FsmaRow schema's, in its order. A text cell starting with =, +, -, @, a tab or a carriage return gets a leading ' so a spreadsheet never runs it as a formula. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (interim tenant_admin or platform_admin guard until per-route policies land) or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · text/csv
traceability_lot_code,critical_tracking_event,event_date,event_time,location,quantity,unit_of_measure,growing_area,parcel,producer,device_id,event_id,commodity,variety,field_name,traceability_lot_code_source,traceability_lot_code_source_reference,shipper_location_name,shipper_location_address,shipper_location_gln,recipient_location_name,recipient_location_address,recipient_location_gln,reference_document_type,reference_document_number,container,input_traceability_lot_code,input_quantity
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 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}/recall-export.csv
FSMA-204-style export of a lot's affected records (CSV)
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: recall_read · getLotRecallExportCsv
The sortable record of the lot's critical tracking events (P5, #41; RecallExport describes the rows and columns), with the recall kind and reason on every row (empty while the lot is not recalled), so a records request is answered within FSMA 204's 24 hours by one request. Complete and bounded for every lot (at most 9,999 cartons). An audited read (export.recall: the format and the row count), downloaded as an attachment (Content-Disposition), never cached. Allowed for tenant_admin, platform_admin acting for the tenant and auditor; operators and labs are refused; another tenant's lot answers like a missing one.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
lotrequired | path | string | Lot code (unique within the tenant). |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | stringtext/csv | CSV with a header row (CRLF line ends); a cell starting with =, +, -, @, a tab or a carriage return gets a leading ' so a spreadsheet never runs it as a formula. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · text/csv
traceability_lot_code,critical_tracking_event,event_date,event_time,location,location_description,product_description,quantity,unit_of_measure,carton,fruit_count,shipment,container,destination,border_gate,recall_kind,recall_reason
LO-260928-014,harvesting,2026-09-27,06:40:00+07:00,VN-TGOR-0387,Ngũ Hiệp, Cai Lậy, Tiền Giang,durian Ri6,500.0,kg,,,,,,,recall,contamination
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/lots/{lot}/recall-export.json
FSMA-204-style export of a lot's affected records (JSON)
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: recall_read · getLotRecallExportJson
The sortable record of the lot's critical tracking events (P5, #41; RecallExport describes the rows and columns), with the recall kind and reason on every row (empty while the lot is not recalled), so a records request is answered within FSMA 204's 24 hours by one request. Complete and bounded for every lot (at most 9,999 cartons). An audited read (export.recall: the format and the row count), downloaded as an attachment (Content-Disposition), never cached. Allowed for tenant_admin, platform_admin acting for the tenant and auditor; operators and labs are refused; another tenant's lot answers like a missing one.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
lotrequired | path | string | Lot code (unique within the tenant). |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | RecallExportapplication/json | The export document (RecallExport). |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"format": "agritrace-recall-export/1",
"lot": "LO-260928-014",
"generated_at": "2026-10-02T09:00:00+07:00",
"recall": {
"kind": "recall",
"reason": "contamination",
"scope": "consumer",
"recalled_at": "2026-10-01T15:20:00+07:00"
},
"columns": [
"traceability_lot_code",
"critical_tracking_event",
"event_date",
"event_time",
"location",
"location_description",
"product_description",
"quantity",
"unit_of_measure",
"carton",
"fruit_count",
"shipment",
"container",
"destination",
"border_gate",
"recall_kind",
"recall_reason"
],
"rows": [
{
"traceability_lot_code": "LO-260928-014",
"critical_tracking_event": "harvesting",
"event_date": "2026-09-27",
"event_time": "06:40:00+07:00",
"location": "VN-TGOR-0387",
"location_description": "Ngũ Hiệp, Cai Lậy, Tiền Giang",
"product_description": "durian Ri6",
"quantity": 500,
"unit_of_measure": "kg",
"carton": "",
"fruit_count": "",
"shipment": "",
"container": "",
"destination": "",
"border_gate": "",
"recall_kind": "recall",
"recall_reason": "contamination"
},
{
"traceability_lot_code": "LO-260928-014",
"critical_tracking_event": "initial_packing",
"event_date": "2026-09-29",
"event_time": "07:30:00+07:00",
"location": "VN-TGPH-021",
"location_description": "Tân Phú",
"product_description": "durian Ri6",
"quantity": 8.6,
"unit_of_measure": "kg",
"carton": "C-0928014-0001",
"fruit_count": 3,
"shipment": "",
"container": "",
"destination": "",
"border_gate": "",
"recall_kind": "recall",
"recall_reason": "contamination"
},
{
"traceability_lot_code": "LO-260928-014",
"critical_tracking_event": "shipping",
"event_date": "2026-09-30",
"event_time": "06:00:00+07:00",
"location": "VN-TGPH-021",
"location_description": "Tân Phú",
"product_description": "durian Ri6",
"quantity": 8.6,
"unit_of_measure": "kg",
"carton": "C-0928014-0001",
"fruit_count": 3,
"shipment": "SH-260930-01",
"container": "CSQU3054383",
"destination": "CN",
"border_gate": "Hữu Nghị",
"recall_kind": "recall",
"recall_reason": "contamination"
}
]
}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/lots/{lot}/captured-events
EPCIS events partners captured for a lot
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: lot_read · listLotCapturedEvents
The lot's events captured from partner systems (#167, POST /v1/epcis/capture): those naming the lot or one of its cartons, and those naming the shipment that carries it; oldest capture first, one page at a time. Each is the partner's statement (source partner_capture, tier self_declared, ADR 0001) with the step it records, its times and places as sent, who captured it (an opaque operator id: user-<id>, token-<id> or legacy-<hash>) and the lot, carton and shipment codes it names. 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, and only the events whose every lot, carton and shipment is in those facilities: an event that also names a record of another facility is left out). Not audited (a read).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
lotrequired | path | string | Lot code (unique within the tenant). |
cursoroptional | query | string |
|
limitoptional | query | integer | Page size, 1 to 200. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | CapturedEventPageapplication/json | One page of the lot's captured events. |
| 400 | Errorapplication/json | Bad request id, limit or cursor. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant, or of a facility outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"lot": "LO-260928-014",
"items": [
{
"event_id": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000001",
"capture_id": 12,
"event_type": "ObjectEvent",
"biz_step": "commissioning",
"step": "harvest",
"action": "ADD",
"event_time": "2026-09-27T07:30:00.000+07:00",
"event_time_zone_offset": "+07:00",
"read_point": null,
"biz_location": null,
"source": "partner_capture",
"tier": "self_declared",
"captured_by": "token-3",
"captured_at": 1791504000,
"references": [
{
"kind": "lot",
"code": "LO-260928-014"
}
]
}
],
"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 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/epcis/capture
Capture an EPCIS 2.0 document from a partner system
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: epcis_capture · captureEpcis
Takes one GS1 EPCIS 2.0 JSON-LD document (#167; /developers/downloads/epcis-capture.md) from a partner system (an ERP, a packing house, a buyer's EPCIS repository) holding an API token of the tenant, and answers a report with one line per event in document order. The document must be an EPCISDocument naming the EPCIS 2.0 context, schemaVersion 2.x, with at most 500 events in epcisBody.eventList (the body at most 1 MiB); otherwise it is refused as a whole (400, 413) and nothing is written. Each event is checked against the GS1 EPCIS 2.0 JSON schema's rules for the members read and is accepted (stored), a duplicate (the tenant already holds this eventID with the same content: a retry is safe) or rejected with a code: invalid_event (with a detail naming the member), unsupported_event_type (only ObjectEvent, AggregationEvent and TransformationEvent), missing_event_id, unsupported_action (DELETE), unsupported_error_declaration, unsupported_biz_step (only commissioning, the harvest, receiving, packing, shipping and sensor_reporting, as bare CBV terms or https://ref.gs1.org/cbv/BizStep-<term>; sensor_reporting only on an ObjectEvent with action OBSERVE and a sensorElementList), event_too_large (over 32 KiB, or a sensor_reporting event with more than 20 sensor elements or 200 sensor reports), event_id_conflict (the eventID is held with other content), no_reference or unknown_reference (an identifier that is not a lot, carton or shipment of the tenant: lots urn:agritrace:lot:<code> or https://id.gs1.org/01/<gtin>/10/<code> as EPC classes, cartons urn:agritrace:carton:<code> and shipments urn:agritrace:shipment:<code> as EPCs, shipments also as business transactions). A sensor_reporting event (#238) is the partner's sensor data about a lot, carton or shipment it names, its sensor elements checked member by member against the GS1 schema's sensorElement, sensorMetadata and sensorReport (invalid_event naming the member); one that names none of the tenant's records, such as a growing area's daily summary, is no_reference. Nothing is ever created from a capture. Captured events are the partner's statements: source partner_capture, tier self_declared (ADR 0001); they never feed the trust tiers, the sensor readings or the public pages. One audit row per request (epcis.capture: the capture id and the counts). Allowed for tenant_admin and platform_admin acting for the tenant; an operator or auditor token is refused. An OAuth2 access token (#171) needs the dedicated epcis_capture scope, which no other scope implies (403 role not permitted otherwise).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Request body
EpcisDocument (required)
Media type: application/ld+json, application/json
Example request · application/ld+json
{
"@context": [
"https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld"
],
"type": "EPCISDocument",
"schemaVersion": "2.0",
"creationDate": "2026-10-09T08:00:00Z",
"epcisBody": {
"eventList": [
{
"type": "ObjectEvent",
"eventID": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000001",
"eventTime": "2026-09-27T07:30:00.000+07:00",
"eventTimeZoneOffset": "+07:00",
"action": "ADD",
"bizStep": "commissioning",
"quantityList": [
{
"epcClass": "urn:agritrace:lot:LO-260928-014",
"quantity": 500,
"uom": "KGM"
}
]
},
{
"type": "AggregationEvent",
"eventID": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000002",
"eventTime": "2026-09-29T07:30:00.000+07:00",
"eventTimeZoneOffset": "+07:00",
"action": "ADD",
"bizStep": "packing",
"parentID": "urn:agritrace:carton:C-0928014-0001",
"childQuantityList": [
{
"epcClass": "urn:agritrace:lot:LO-260928-014",
"quantity": 8.6,
"uom": "KGM"
}
]
},
{
"type": "ObjectEvent",
"eventID": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000003",
"eventTime": "2026-09-30T07:30:00.000+07:00",
"eventTimeZoneOffset": "+07:00",
"action": "OBSERVE",
"bizStep": "inspecting",
"quantityList": [
{
"epcClass": "urn:agritrace:lot:LO-260928-014"
}
]
}
]
}
}Example request · application/json
{
"@context": [
"https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld"
],
"type": "EPCISDocument",
"schemaVersion": "2.0",
"creationDate": "2026-10-09T08:00:00Z",
"epcisBody": {
"eventList": [
{
"type": "ObjectEvent",
"eventID": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000001",
"eventTime": "2026-09-27T07:30:00.000+07:00",
"eventTimeZoneOffset": "+07:00",
"action": "ADD",
"bizStep": "commissioning",
"quantityList": [
{
"epcClass": "urn:agritrace:lot:LO-260928-014",
"quantity": 500,
"uom": "KGM"
}
]
},
{
"type": "AggregationEvent",
"eventID": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000002",
"eventTime": "2026-09-29T07:30:00.000+07:00",
"eventTimeZoneOffset": "+07:00",
"action": "ADD",
"bizStep": "packing",
"parentID": "urn:agritrace:carton:C-0928014-0001",
"childQuantityList": [
{
"epcClass": "urn:agritrace:lot:LO-260928-014",
"quantity": 8.6,
"uom": "KGM"
}
]
},
{
"type": "ObjectEvent",
"eventID": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000003",
"eventTime": "2026-09-30T07:30:00.000+07:00",
"eventTimeZoneOffset": "+07:00",
"action": "OBSERVE",
"bizStep": "inspecting",
"quantityList": [
{
"epcClass": "urn:agritrace:lot:LO-260928-014"
}
]
}
]
}
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | EpcisCaptureReportapplication/json | The capture's per-event report. |
| 400 | Errorapplication/json | Bad request id, invalid JSON, or a document refused as a whole; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). 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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The Idempotency-Key's first request is still running (retry after |
| 413 | Errorapplication/json | The body is over 1 MiB, or the document holds more than 500 events. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"capture_id": 12,
"events": 3,
"accepted": 2,
"duplicates": 0,
"rejected": 1,
"source": "partner_capture",
"tier": "self_declared",
"results": [
{
"index": 0,
"event_id": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000001",
"status": "accepted",
"step": "harvest",
"references": [
{
"kind": "lot",
"code": "LO-260928-014"
}
]
},
{
"index": 1,
"event_id": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000002",
"status": "accepted",
"step": "pack",
"references": [
{
"kind": "lot",
"code": "LO-260928-014"
},
{
"kind": "carton",
"code": "C-0928014-0001"
}
]
},
{
"index": 2,
"event_id": "urn:uuid:6f1c2a3b-0000-4000-8000-000000000003",
"status": "rejected",
"code": "unsupported_biz_step",
"detail": "bizStep 'inspecting' is not captured"
}
]
}Response 400 · application/json · json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · document
{
"error": "invalid document: @context must name the EPCIS 2.0 context",
"code": "invalid_document"
}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 · 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 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}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 · body
{
"error": "body too large",
"code": "body_too_large"
}Response 413 · application/json · events
{
"error": "too many events: at most 500 per document",
"code": "too_many_events"
}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/records-export.csv
Records-request export of the tenant's lots in a range (CSV)
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: records_export · getRecordsExportCsv
The records of the tenant's lots CREATED in [start, end), one page at a time, the same rows as the per-lot export lot by lot (W1-3, #152). start and end are ISO 8601 dates or date-times (local time, +07:00, without an offset), at most 366 days apart. A page holds at most 50 lots whose cartons together stay within 9,999 (always one lot at least); a lot whose signed device events were cut is flagged by X-Records-Truncated, the CSV's truncation_notice row and the JSON's truncated; the next page's cursor is next_cursor (JSON) or the X-Next-Cursor header (CSV, absent on the last page). An audited read (export.records: the parsed range, the format, the lot and row counts), downloaded as an attachment, never cached. Allowed for tenant_admin, platform_admin acting for the tenant and auditor; operators and labs are refused; another tenant's lots never appear. An OAuth2 access token (#171) needs the dedicated records_export scope, which no other scope implies (403 role not permitted otherwise).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
startrequired | query | string | Inclusive lower bound on the lot's creation time, ISO 8601 date or date-time (+07:00 without an offset). |
endrequired | query | string | Exclusive upper bound, at most 366 days after start. |
cursoroptional | query | string | The previous page's next_cursor (X-Next-Cursor); omitted for the first page. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | stringtext/csv | CSV with a header row (the RecordsExportRow columns, CRLF line ends), then, when a lot's signed device events were cut, one truncation_notice row per cut lot (that record_type, the lot code and device_events_truncated "true", every other cell empty), then the rows; a text cell starting with =, +, -, @, a tab or a carriage return gets a leading ' so a spreadsheet never runs it as a formula. |
| 400 | Errorapplication/json | start or end missing or not an ISO 8601 date or date-time, end not after start, a range over 366 days, a bad cursor, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Next-Cursor | 200 | string | The cursor of the next page; absent on the last page. |
X-Records-Truncated | 200 | "true" | "false" | "true" when a lot's signed device events were cut at 1,000 (the CSV then starts with a truncation_notice row per cut lot, the JSON has |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · text/csv
record_type,traceability_lot_code,critical_tracking_event,event_date,event_time,record_source,event_id,location,location_description,location_address,location_registration,product_description,quantity,unit_of_measure,area_declared_kg,carton,fruit_count,supplier_name,supplier_organisation,supplier_code,supplier_address,supplier_registration,harvest_date,shipment,container,seal_number,destination,border_gate,consignee_name,consignee_address,consignee_country,consignee_gln,consignee_gacc_record,reference_document_type,reference_document_number,lab_key_custody,lab_market,sample,analyte,result_outcome,result_value,result_unit,limit_kind,limit_value,limit_source,verdict,sealed_digest,sealed_basis,recall_kind,recall_reason,recall_scope,hold_kind,hold_status,device_events_truncated
cte,LO-260928-014,initial_packing,2026-09-29,07:30:00+07:00,system_record,,VN-TGPH-021,Tân Phú,"Cai Lậy, Tiền Giang",,durian Ri6,8.6,kg,,C-0928014-0001,3,,,VN-TGOR-0387,"Ngũ Hiệp, Cai Lậy, Tiền Giang",,2026-09-27,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,false
Response 400 · application/json · bad_range
{
"error": "invalid range: at most 366 days",
"code": "invalid_range"
}Response 400 · application/json · bad_start
{
"error": "invalid start: an ISO 8601 date or date-time",
"code": "invalid_start"
}Response 400 · application/json · bad_cursor
{
"error": "invalid cursor",
"code": "invalid_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"
}GET /v1/records-export.json
Records-request export of the tenant's lots in a range (JSON)
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: records_export · getRecordsExportJson
The records of the tenant's lots CREATED in [start, end), one page at a time, the same rows as the per-lot export lot by lot (W1-3, #152). start and end are ISO 8601 dates or date-times (local time, +07:00, without an offset), at most 366 days apart. A page holds at most 50 lots whose cartons together stay within 9,999 (always one lot at least); a lot whose signed device events were cut is flagged by X-Records-Truncated, the CSV's truncation_notice row and the JSON's truncated; the next page's cursor is next_cursor (JSON) or the X-Next-Cursor header (CSV, absent on the last page). An audited read (export.records: the parsed range, the format, the lot and row counts), downloaded as an attachment, never cached. Allowed for tenant_admin, platform_admin acting for the tenant and auditor; operators and labs are refused; another tenant's lots never appear. An OAuth2 access token (#171) needs the dedicated records_export scope, which no other scope implies (403 role not permitted otherwise).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
startrequired | query | string | Inclusive lower bound on the lot's creation time, ISO 8601 date or date-time (+07:00 without an offset). |
endrequired | query | string | Exclusive upper bound, at most 366 days after start. |
cursoroptional | query | string | The previous page's next_cursor (X-Next-Cursor); omitted for the first page. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | RecordsExportRangeapplication/json | The export document (RecordsExportRange). |
| 400 | Errorapplication/json | start or end missing or not an ISO 8601 date or date-time, end not after start, a range over 366 days, a bad cursor, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Records-Truncated | 200 | "true" | "false" | "true" when a lot's signed device events were cut at 1,000 (the CSV then starts with a truncation_notice row per cut lot, the JSON has |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"format": "agritrace-records-export-range/1",
"start": "2026-09-01T00:00:00+07:00",
"end": "2026-10-01T00:00:00+07:00",
"generated_at": "2026-10-02T09:00:00+07:00",
"lots": [
"LO-260928-014"
],
"next_cursor": null,
"truncated": false,
"columns": [
"record_type",
"traceability_lot_code",
"critical_tracking_event",
"event_date",
"event_time",
"record_source",
"event_id",
"location",
"location_description",
"location_address",
"location_registration",
"product_description",
"quantity",
"unit_of_measure",
"area_declared_kg",
"carton",
"fruit_count",
"supplier_name",
"supplier_organisation",
"supplier_code",
"supplier_address",
"supplier_registration",
"harvest_date",
"shipment",
"container",
"seal_number",
"destination",
"border_gate",
"consignee_name",
"consignee_address",
"consignee_country",
"consignee_gln",
"consignee_gacc_record",
"reference_document_type",
"reference_document_number",
"lab_key_custody",
"lab_market",
"sample",
"analyte",
"result_outcome",
"result_value",
"result_unit",
"limit_kind",
"limit_value",
"limit_source",
"verdict",
"sealed_digest",
"sealed_basis",
"recall_kind",
"recall_reason",
"recall_scope",
"hold_kind",
"hold_status",
"device_events_truncated"
],
"rows": [
{
"record_type": "cte",
"traceability_lot_code": "LO-260928-014",
"critical_tracking_event": "initial_packing",
"event_date": "2026-09-29",
"event_time": "07:30:00+07:00",
"record_source": "system_record",
"event_id": "",
"location": "VN-TGPH-021",
"location_description": "Tân Phú",
"location_address": "Cai Lậy, Tiền Giang",
"location_registration": "",
"product_description": "durian Ri6",
"quantity": 8.6,
"unit_of_measure": "kg",
"area_declared_kg": "",
"carton": "C-0928014-0001",
"fruit_count": 3,
"supplier_name": "",
"supplier_organisation": "",
"supplier_code": "VN-TGOR-0387",
"supplier_address": "Ngũ Hiệp, Cai Lậy, Tiền Giang",
"supplier_registration": "",
"harvest_date": "2026-09-27",
"shipment": "",
"container": "",
"seal_number": "",
"destination": "",
"border_gate": "",
"consignee_name": "",
"consignee_address": "",
"consignee_country": "",
"consignee_gln": "",
"consignee_gacc_record": "",
"reference_document_type": "",
"reference_document_number": "",
"lab_key_custody": "",
"lab_market": "",
"sample": "",
"analyte": "",
"result_outcome": "",
"result_value": "",
"result_unit": "",
"limit_kind": "",
"limit_value": "",
"limit_source": "",
"verdict": "",
"sealed_digest": "",
"sealed_basis": "",
"recall_kind": "",
"recall_reason": "",
"recall_scope": "",
"hold_kind": "",
"hold_status": "",
"device_events_truncated": "false"
}
]
}Response 400 · application/json · bad_range
{
"error": "invalid range: at most 366 days",
"code": "invalid_range"
}Response 400 · application/json · bad_start
{
"error": "invalid start: an ISO 8601 date or date-time",
"code": "invalid_start"
}Response 400 · application/json · bad_cursor
{
"error": "invalid cursor",
"code": "invalid_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"
}GET /v1/lots/{lot}/records-export.csv
Records-request export of any lot (CSV)
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: records_export · getLotRecordsExportCsv
The records of any lot of the tenant for an authority or a buyer, answered within 24 hours by one request (W1-3, #152; RecordsExport and RecordsExportRow describe the rows and every column): the critical tracking events, the registry facts frozen at seal, every lab result, the recall when any and the lot's open or escalated holds, with the supplier (one step back) on every row and the shipment (one step forward) on the shipping rows. Bounded (at most 9,999 cartons, 1,000 signed device events, 384 lab results); a cut lot is flagged by X-Records-Truncated, the CSV's truncation_notice row and the JSON's truncated. An audited read (export.records: the format and the row count), downloaded as an attachment (Content-Disposition), never cached. Allowed for tenant_admin, platform_admin acting for the tenant and auditor; operators and labs are refused; another tenant's lot answers like a missing one. An OAuth2 access token (#171) needs the dedicated records_export scope, which no other scope implies (403 role not permitted otherwise).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
lotrequired | path | string | Lot code (unique within the tenant). |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | stringtext/csv | CSV with a header row (the RecordsExportRow columns, CRLF line ends), then, when a lot's signed device events were cut, one truncation_notice row per cut lot (that record_type, the lot code and device_events_truncated "true", every other cell empty), then the rows; a text cell starting with =, +, -, @, a tab or a carriage return gets a leading ' so a spreadsheet never runs it as a formula. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Records-Truncated | 200 | "true" | "false" | "true" when a lot's signed device events were cut at 1,000 (the CSV then starts with a truncation_notice row per cut lot, the JSON has |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · text/csv
record_type,traceability_lot_code,critical_tracking_event,event_date,event_time,record_source,event_id,location,location_description,location_address,location_registration,product_description,quantity,unit_of_measure,area_declared_kg,carton,fruit_count,supplier_name,supplier_organisation,supplier_code,supplier_address,supplier_registration,harvest_date,shipment,container,seal_number,destination,border_gate,consignee_name,consignee_address,consignee_country,consignee_gln,consignee_gacc_record,reference_document_type,reference_document_number,lab_key_custody,lab_market,sample,analyte,result_outcome,result_value,result_unit,limit_kind,limit_value,limit_source,verdict,sealed_digest,sealed_basis,recall_kind,recall_reason,recall_scope,hold_kind,hold_status,device_events_truncated
cte,LO-260928-014,initial_packing,2026-09-29,07:30:00+07:00,system_record,,VN-TGPH-021,Tân Phú,"Cai Lậy, Tiền Giang",,durian Ri6,8.6,kg,,C-0928014-0001,3,,,VN-TGOR-0387,"Ngũ Hiệp, Cai Lậy, Tiền Giang",,2026-09-27,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,false
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/lots/{lot}/records-export.json
Records-request export of any lot (JSON)
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: records_export · getLotRecordsExportJson
The records of any lot of the tenant for an authority or a buyer, answered within 24 hours by one request (W1-3, #152; RecordsExport and RecordsExportRow describe the rows and every column): the critical tracking events, the registry facts frozen at seal, every lab result, the recall when any and the lot's open or escalated holds, with the supplier (one step back) on every row and the shipment (one step forward) on the shipping rows. Bounded (at most 9,999 cartons, 1,000 signed device events, 384 lab results); a cut lot is flagged by X-Records-Truncated, the CSV's truncation_notice row and the JSON's truncated. An audited read (export.records: the format and the row count), downloaded as an attachment (Content-Disposition), never cached. Allowed for tenant_admin, platform_admin acting for the tenant and auditor; operators and labs are refused; another tenant's lot answers like a missing one. An OAuth2 access token (#171) needs the dedicated records_export scope, which no other scope implies (403 role not permitted otherwise).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
lotrequired | path | string | Lot code (unique within the tenant). |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | RecordsExportapplication/json | The export document (RecordsExport). |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Records-Truncated | 200 | "true" | "false" | "true" when a lot's signed device events were cut at 1,000 (the CSV then starts with a truncation_notice row per cut lot, the JSON has |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"format": "agritrace-records-export/1",
"lot": "LO-260928-014",
"status": "packed",
"generated_at": "2026-10-02T09:00:00+07:00",
"truncated": false,
"sealed_record": null,
"columns": [
"record_type",
"traceability_lot_code",
"critical_tracking_event",
"event_date",
"event_time",
"record_source",
"event_id",
"location",
"location_description",
"location_address",
"location_registration",
"product_description",
"quantity",
"unit_of_measure",
"area_declared_kg",
"carton",
"fruit_count",
"supplier_name",
"supplier_organisation",
"supplier_code",
"supplier_address",
"supplier_registration",
"harvest_date",
"shipment",
"container",
"seal_number",
"destination",
"border_gate",
"consignee_name",
"consignee_address",
"consignee_country",
"consignee_gln",
"consignee_gacc_record",
"reference_document_type",
"reference_document_number",
"lab_key_custody",
"lab_market",
"sample",
"analyte",
"result_outcome",
"result_value",
"result_unit",
"limit_kind",
"limit_value",
"limit_source",
"verdict",
"sealed_digest",
"sealed_basis",
"recall_kind",
"recall_reason",
"recall_scope",
"hold_kind",
"hold_status",
"device_events_truncated"
],
"rows": [
{
"record_type": "cte",
"traceability_lot_code": "LO-260928-014",
"critical_tracking_event": "initial_packing",
"event_date": "2026-09-29",
"event_time": "07:30:00+07:00",
"record_source": "system_record",
"event_id": "",
"location": "VN-TGPH-021",
"location_description": "Tân Phú",
"location_address": "Cai Lậy, Tiền Giang",
"location_registration": "",
"product_description": "durian Ri6",
"quantity": 8.6,
"unit_of_measure": "kg",
"area_declared_kg": "",
"carton": "C-0928014-0001",
"fruit_count": 3,
"supplier_name": "",
"supplier_organisation": "",
"supplier_code": "VN-TGOR-0387",
"supplier_address": "Ngũ Hiệp, Cai Lậy, Tiền Giang",
"supplier_registration": "",
"harvest_date": "2026-09-27",
"shipment": "",
"container": "",
"seal_number": "",
"destination": "",
"border_gate": "",
"consignee_name": "",
"consignee_address": "",
"consignee_country": "",
"consignee_gln": "",
"consignee_gacc_record": "",
"reference_document_type": "",
"reference_document_number": "",
"lab_key_custody": "",
"lab_market": "",
"sample": "",
"analyte": "",
"result_outcome": "",
"result_value": "",
"result_unit": "",
"limit_kind": "",
"limit_value": "",
"limit_source": "",
"verdict": "",
"sealed_digest": "",
"sealed_basis": "",
"recall_kind": "",
"recall_reason": "",
"recall_scope": "",
"hold_kind": "",
"hold_status": "",
"device_events_truncated": "false"
}
]
}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"
}