API reference
419 operations of AgriTrace HTTP API, version 1, generated from its OpenAPI document.
Operation and field descriptions are in English, as written in the OpenAPI document.
The CropPath HTTP API, version 1, at https://txng.theio.vn. It covers a company's traceability records (growing areas, lots, packing, shipping and exports), devices and their signed messages, laboratories, the public lot and fruit pages behind the QR codes, and webhooks. Guides, examples and this reference: https://txng.theio.vn/en/developers.
Each operation's security lists the credentials it accepts. bearer: an API token (agt_..., role tenant_admin, operator or auditor) or the access token of an OAuth2 API client (ago_...), sent as Authorization: Bearer; an API client also needs the scope the operation lists under oauth2. cookie: a person signed in to the CropPath console. An operation with no security is anonymous. deviceMtls: a device or gateway with its client certificate.
x-session-only: true marks an operation for people signed in to the console only (account, team, credentials, company settings and support): it lists the session cookie as its only security. An API token or API client calling one is refused: 401 not_authenticated for the signed-in user's own operations under /v1/auth/... and for GET /v1/help, which read only the session cookie, and 403 role_not_permitted for the others. Operations for CropPath's platform admins and for lab users need a role that no API client and no API token a company creates can hold, so they answer 403 to a company's integrations as well.
An error answers with a stable code in its JSON body (an Error; device ingest answers an IngestResult, and the OAuth2 endpoints the RFC 6749 error with the code beside it). An operation that lists the Idempotency-Key header can be retried safely with the same key.
Per-company quotas (#134): every call made with a company's API tokens or API clients counts toward that company's quotas, on top of the per-client limits an operation lists: calls per minute and calls per UTC day (the company admin's usage page and getCompanyUsage show both). Over either, any such operation answers 429 too_many_requests with Retry-After (for the daily quota, the seconds until the next UTC midnight), right after the credential is checked and before anything else is checked or changed.
Download the OpenAPI document (JSON) /developers/openapi.json
Authentication
cookie(apiKey cookie)Server session cookie. In the plain-HTTP insecure dev mode the cookie is named
agt_sid. Unsafe methods (POST, PUT, PATCH, DELETE) also need anX-CSRF-Tokenheader equal to the session's csrf_token and an allowed Origin.bearer(http bearer)A hashed API token (
agt_...), an OAuth2 access token from POST /v1/oauth/token (ago_..., limited to its scopes), or a legacy AGRITRACE_API_TOKENS principal (role tenant_admin). Exempt from CSRF.oauth2(oauth2)OAuth2 client credentials (RFC 6749 §4.4, #171): a tenant admin registers an API client (POST /v1/oauth-clients) with a role and scopes; the client exchanges its id and secret at POST /v1/oauth/token for a 15-minute access token (
ago_...), sent asAuthorization: Bearer. A token opens an operation only when the operation lists the token's scope here, and its client's role allows it; otherwise 403role not permitted. A scope is the name of one route permission and implies no other:epcis_captureandrecords_exportin particular are granted only by name.Token endpoint: /v1/oauth/token
Scopes
Name Description aggregate_readThe aggregate_readpermission. Operations: GET /v1/volumes/{growing_area}/{season}.attachment_readThe attachment_readpermission. Operations: GET /v1/attachments/{sha256}, GET /v1/attachments/{sha256}/peaks.attachment_uploadThe attachment_uploadpermission. Operations: PUT /v1/attachments/{sha256}.command_readThe command_readpermission. Operations: GET /v1/commands/{id}, GET /v1/devices/{id}/commands.device_adminThe device_adminpermission. Operations: PATCH /v1/devices/{id}, POST /v1/devices, POST /v1/gateways, POST /v1/harvest-keys/{kid}/approve, POST /v1/harvest-keys/{kid}/reject, POST /v1/keys, POST /v1/keys/{kid}/revoke.device_commandThe device_commandpermission. Operations: POST /v1/devices/{id}/commands.device_readThe device_readpermission. Operations: GET /v1/devices, GET /v1/devices/{id}.envelope_readThe envelope_readpermission. Operations: GET /v1/envelopes, GET /v1/envelopes/stream, GET /v1/envelopes/{id}.epcis_captureCapture of partner EPCIS 2.0 documents (#167). A dedicated scope: no other scope implies it. Operations: POST /v1/epcis/capture. facility_editThe facility_editpermission. Operations: PATCH /v1/facilities/{code}.facility_readThe facility_readpermission. Operations: GET /v1/facilities, GET /v1/facilities/{code}, GET /v1/facilities/{code}/issuer-keys.fruit_actionThe fruit_actionpermission. Operations: POST /v1/fruits/{code}/actions.grading_rule_readThe grading_rule_readpermission. Operations: GET /v1/grading-rules, GET /v1/grading-rules/{variety}/history.grading_rule_writeThe grading_rule_writepermission. Operations: PUT /v1/grading-rules/{variety}.growing_area_editThe growing_area_editpermission. Operations: PATCH /v1/growers/{id}, PATCH /v1/growing-areas/{code}, POST /v1/growers, POST /v1/growers/batch, POST /v1/growing-areas, POST /v1/growing-areas/{code}/certifications, POST /v1/growing-areas/{code}/harvests, POST /v1/growing-areas/{code}/satellite-checks, POST /v1/growing-areas/{code}/sprays, POST /v1/harvests/batch.growing_area_readThe growing_area_readpermission. Operations: GET /v1/growers, GET /v1/growers/{id}, GET /v1/growing-areas, GET /v1/growing-areas/{code}, GET /v1/growing-areas/{code}/certifications, GET /v1/growing-areas/{code}/harvests, GET /v1/growing-areas/{code}/mass-balance, GET /v1/growing-areas/{code}/satellite-checks, GET /v1/growing-areas/{code}/sprays, GET /v1/growing-areas/{code}/volume.issuer_key_adminThe issuer_key_adminpermission. Operations: POST /v1/facilities/{code}/issuer-keys, POST /v1/facilities/{code}/issuer-keys/{key}/revoke.lot_readThe lot_readpermission. Operations: GET /v1/cartons/{code}, GET /v1/fruits/{code}, GET /v1/lots, GET /v1/lots/{lot}, GET /v1/lots/{lot}/captured-events, GET /v1/lots/{lot}/cartons, GET /v1/lots/{lot}/close-check, GET /v1/lots/{lot}/export-label, GET /v1/lots/{lot}/fruits, GET /v1/lots/{lot}/manifest, GET /v1/lots/{lot}/packing, GET /v1/lots/{lot}/samples, GET /v1/lots/{lot}/sessions, GET /v1/lots/{lot}/summary, GET /v1/lots/{lot}/trust, GET /v1/sessions/{id}, GET /v1/sessions/{id}/feed, GET /v1/sessions/{id}/fruits, GET /v1/sessions/{id}/stream, GET /v1/shipments/{code}.lot_recallThe lot_recallpermission. Operations: POST /v1/lots/{lot}/recall.lot_writeThe lot_writepermission. Operations: PATCH /v1/lots/{lot}, POST /v1/lots, POST /v1/lots/{lot}/carton-contents/batch, POST /v1/lots/{lot}/cartons, POST /v1/lots/{lot}/cartons/batch, POST /v1/lots/{lot}/close, POST /v1/lots/{lot}/export-label/prints, POST /v1/lots/{lot}/samples, POST /v1/lots/{lot}/seal, POST /v1/lots/{lot}/sessions, POST /v1/sessions/{id}/close, POST /v1/sessions/{id}/fruits, POST /v1/sessions/{id}/fruits/batch, POST /v1/sessions/{id}/pause, POST /v1/sessions/{id}/resume, POST /v1/shipments, POST /v1/shipments/{code}/depart, POST /v1/shipments/{code}/logger-readings, POST /v1/shipments/{code}/lots, PUT /v1/cartons/{code}/fruits, PUT /v1/shipments/{code}/consignee, PUT /v1/shipments/{code}/documents.market_limit_readThe market_limit_readpermission. Operations: GET /v1/market-limits.recall_readThe recall_readpermission. Operations: GET /v1/lots/{lot}/recall-export.csv, GET /v1/lots/{lot}/recall-export.json, GET /v1/lots/{lot}/trace.records_exportThe records-request exports of a lot or of a date range (#152). A dedicated scope: no other scope implies it. Operations: GET /v1/lots/{lot}/records-export.csv, GET /v1/lots/{lot}/records-export.json, GET /v1/records-export.csv, GET /v1/records-export.json. report_triageThe report_triagepermission. Operations: GET /v1/reports, GET /v1/reports/{id}, POST /v1/reports/{id}/resolve.reviewThe reviewpermission. Operations: POST /v1/envelopes/{id}/review.tenant_readThe tenant_readpermission. Operations: GET /v1/alerts, GET /v1/audit, GET /v1/gateways, GET /v1/keys, GET /v1/quarantine.trace_readThe trace_readpermission. Operations: GET /v1/fsma.csv, GET /v1/lots/{lot}/epcis, GET /v1/lots/{lot}/events, GET /v1/lots/{lot}/fsma.csv.webhook_adminThe webhook_adminpermission. Operations: GET /v1/webhooks, GET /v1/webhooks/{id}, GET /v1/webhooks/{id}/deliveries, PATCH /v1/webhooks/{id}, POST /v1/webhooks, POST /v1/webhooks/{id}/deliveries/{delivery}/redeliver, POST /v1/webhooks/{id}/rotate-secret.broker(http bearer)The EMQX shared broker secret.
deviceMtls(mutualTLS)Device or gateway client certificate. Ingest additionally requires a signed envelope.
Operations by area
- agronomy 14 operations
- alarms 5 operations
- attachments 4 operations
- audit 2 operations
- auth 29 operations
- control 28 operations
- devices 27 operations
- envelopes 3 operations
- ingest 4 operations
- integrity 5 operations
- labs 14 operations
- lots 36 operations
- ops 5 operations
- packing 19 operations
- public 25 operations
- registry 49 operations
- reports 3 operations
- sandbox 1 operation
- settings 54 operations
- shipping 9 operations
- support 4 operations
- traceability 12 operations
- webhooks 7 operations
Platform (internal)
Operations that run the platform itself: every operation only a platform administrator may call (for example creating tenants and their administrators, approving facilities, growing areas, devices and gateways, managing labs, the monitoring metrics) and the MQTT broker's authorization check. A partner integration does not use them.
- Platform (internal) 60 operations