API 参考
AgriTrace HTTP API(版本 1)的 419 个操作,由其 OpenAPI 文档生成。
操作和字段说明为英文,与 OpenAPI 文档一致。
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.
下载 OpenAPI 文档(JSON) /developers/openapi.json
身份验证
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.令牌端点:/v1/oauth/token
作用域(scope)
名称 说明 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.
按领域分组的操作
- agronomy 14 个操作
- alarms 5 个操作
- attachments 4 个操作
- audit 2 个操作
- auth 29 个操作
- control 28 个操作
- devices 27 个操作
- envelopes 3 个操作
- ingest 4 个操作
- integrity 5 个操作
- labs 14 个操作
- lots 36 个操作
- ops 5 个操作
- packing 19 个操作
- public 25 个操作
- registry 49 个操作
- reports 3 个操作
- sandbox 1 个操作
- settings 54 个操作
- shipping 9 个操作
- support 4 个操作
- traceability 12 个操作
- webhooks 7 个操作
平台(内部)
用于运行平台本身的操作:所有只有平台管理员可以调用的操作(例如创建租户及其管理员,批准设施、种植区、设备和网关,管理实验室,监控指标),以及 MQTT 代理的授权检查。合作伙伴的集成不会用到这些操作。
- 平台(内部) 60 个操作