CropPath for developers

API reference

traceability

12 operations

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

NameInTypeDescription
start
optional
querystring (date-time)

Inclusive lower bound, ISO 8601 date-time.

end
optional
querystring (date-time)

Exclusive upper bound, ISO 8601 date-time.

Responses

StatusTypeDescription
200string
text/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.

400Error
application/json

start or end is not a valid ISO 8601 date-time, 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 (interim tenant_admin or platform_admin guard until per-route policies land) 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 · 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

NameInTypeDescription
lot
required
pathstring

Traceability lot code.

version
optional
query"1" | "2" | "3"

The mapping version (#238). 2 appends the daily sensor summaries of the lot's growing area: one ObjectEvent per device and UTC day (action OBSERVE, bizStep sensor_reporting, read point the growing area, no objects, event time the day's last reading) over the 31 UTC days ending with the day of the lot's harvest date (its creation date without one), only days that have ended, from the company's own readings. Its sensor element names the device (deviceID), the day (startTime, endTime) and the mapping (dataProcessingMethod agri:method/daily-summary-v2), and, when the deployment's public origin is configured, links the device's metadata (deviceMetadata, GET /v1/devices/{id}/metadata) and its telemetry envelopes received while the day's readings were (rawData, a GET /v1/envelopes query): staff reads, never public. One sensorReport per numeric capability and depth: minValue, maxValue and meanValue over the readings the quality checks passed or did not evaluate (absent when there is none), uom, agri:depthCm, agri:readingCount, agri:valueCount, agri:qcFlag (the least trusted quality flag among the readings: 4 fail, then 3 suspect, 9 missing, 2 not evaluated, 1 pass) and agri:calibrationId (the calibrations in force). The event carries the location evidence, never a coordinate: agri:geoVerdict (the geofence verdict that weighs most that day), agri:geoDistM (the largest signed distance to the boundary in metres, negative inside), agri:accM (the largest reported accuracy in metres) and agri:osnma (the least assured Galileo OSNMA status the device's positions report). A late reading that changes a day's summary gives the day a new eventID. 3 appends the same daily events, with three differences: each report takes the type and unit of CropPath's export mapping of each capability (a GS1 CBV measurement type as the bare term the GS1 EPCIS 2.0 JSON schema lists, such as VolumeFraction, or a CropPath type URI https://agritrace.vn/voc/<name>; uom the UN/ECE Recommendation 20 code, or, where there is none, the UCUM unit as agri:ucum) and names its capability (agri:capability) and what was measured (agri:feature); the device's own GNSS fixes of the day follow as two reports of type Angle, component latitude and longitude, coordinateReferenceSystem http://www.opengis.net/def/crs/OGC/1.3/CRS84, uom DD, with their minValue, maxValue and meanValue (no mean longitude when the fixes span more than 180 degrees of longitude), so a device with positions only has an event too; and dataProcessingMethod is agri:method/daily-summary-v3, the eventID another than in version 2. Coordinates appear only in this staff document, never in the public one. 2 stays exactly as described above. 1 or none: the document without them, exactly as before; any other value is refused (400 bad version).

Responses

StatusTypeDescription
200EpcisDocument
application/ld+json

EPCIS document.

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 (interim tenant_admin or platform_admin guard until per-route policies land) 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/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

NameInTypeDescription
lot
required
pathstring

Traceability lot code.

Responses

StatusTypeDescription
200array<StoredEnvelope>
application/json

Stored envelopes (an empty array when the lot has none).

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 (interim tenant_admin or platform_admin guard until per-route policies land) 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
[
  {
    "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

NameInTypeDescription
lot
required
pathstring

Traceability lot code.

Responses

StatusTypeDescription
200string
text/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.

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 (interim tenant_admin or platform_admin guard until per-route policies land) 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 · 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

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Responses

StatusTypeDescription
200string
text/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.

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 (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant).

404Error
application/json

No such lot for this tenant: a lot of another tenant 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 · 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

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Responses

StatusTypeDescription
200RecallExport
application/json

The export document (RecallExport).

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 (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant).

404Error
application/json

No such lot for this tenant: a lot of another tenant 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
{
  "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

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
200CapturedEventPage
application/json

One page of the lot's captured events.

400Error
application/json

Bad request id, limit or cursor.

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",
  "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

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

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

StatusTypeDescription
200EpcisCaptureReport
application/json

The capture's per-event report.

400Error
application/json

Bad request id, invalid JSON, or a document refused as a whole; 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 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).

405Error
application/json

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

409Error
application/json

The Idempotency-Key's first request is still running (retry after Retry-After seconds), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The body is over 1 MiB, or the document holds more than 500 events.

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-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-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 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

NameInTypeDescription
start
required
querystring

Inclusive lower bound on the lot's creation time, ISO 8601 date or date-time (+07:00 without an offset).

end
required
querystring

Exclusive upper bound, at most 366 days after start.

cursor
optional
querystring

The previous page's next_cursor (X-Next-Cursor); omitted for the first page.

Responses

StatusTypeDescription
200string
text/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.

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (tenant_admin, platform_admin and auditor only) 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-Next-Cursor200string

The cursor of the next page; absent on the last page.

X-Records-Truncated200"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 truncated true), else "false". The console warns on "true".

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 · 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

NameInTypeDescription
start
required
querystring

Inclusive lower bound on the lot's creation time, ISO 8601 date or date-time (+07:00 without an offset).

end
required
querystring

Exclusive upper bound, at most 366 days after start.

cursor
optional
querystring

The previous page's next_cursor (X-Next-Cursor); omitted for the first page.

Responses

StatusTypeDescription
200RecordsExportRange
application/json

The export document (RecordsExportRange).

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (tenant_admin, platform_admin and auditor only) 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-Records-Truncated200"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 truncated true), else "false". The console warns on "true".

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
{
  "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

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Responses

StatusTypeDescription
200string
text/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.

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 (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant).

404Error
application/json

No such lot for this tenant: a lot of another tenant 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-Records-Truncated200"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 truncated true), else "false". The console warns on "true".

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 · 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

NameInTypeDescription
lot
required
pathstring

Lot code (unique within the tenant).

Responses

StatusTypeDescription
200RecordsExport
application/json

The export document (RecordsExport).

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 (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant).

404Error
application/json

No such lot for this tenant: a lot of another tenant 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-Records-Truncated200"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 truncated true), else "false". The console warns on "true".

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
{
  "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"
}