Nền tảng (nội bộ)
60 thao tác
Các thao tác dùng để vận hành chính nền tảng: mọi thao tác chỉ quản trị viên nền tảng gọi được (ví dụ tạo đơn vị và quản trị viên của đơn vị, duyệt cơ sở, vùng trồng, thiết bị và gateway, quản lý phòng kiểm nghiệm, số liệu giám sát) và lệnh kiểm tra quyền của broker MQTT. Tích hợp của đối tác không dùng đến các thao tác này.
POST /v1/broker/authzEMQX HTTP authorization callbackPOST /v1/facilitiesRegister a facilityPOST /v1/facilities/{code}/approveApprove a facilityGET /v1/facility-proposalsThe platform's facility proposal queuePOST /v1/facility-proposals/{code}/approveApprove a company's facility proposal (platform)POST /v1/facility-proposals/{code}/rejectReject a company's facility proposal (platform)GET /v1/polygon-proposalsCompanies' growing-area boundary proposals (platform)POST /v1/polygon-proposals/{code}/approveApprove a company's growing-area boundary proposal (platform)POST /v1/polygon-proposals/{code}/rejectReject a company's growing-area boundary proposal (platform)POST /v1/growing-areas/{code}/approveApprove a growing areaGET /v1/tenantsEvery tenantPOST /v1/tenantsRegister a tenantGET /v1/tenants/{id}/adminsA company's adminsPOST /v1/tenants/{id}/admin-invitationsInvite a company's first admin (link shown once)POST /v1/tenants/{id}/admins/{user_id}/recovery-linkLet a company admin set a new password (link shown once)GET /v1/cropsList the crop registryPOST /v1/cropsAdd a crop to the registryGET /v1/crops/{code}Get a crop with its rulesPATCH /v1/crops/{code}Edit a cropPUT /v1/crops/{code}/markets/{market}Set a crop's rules for a destination marketPUT /v1/crops/{code}/grading-rulesSet a crop's grading rulesPOST /v1/labsRegister a lab partnerPATCH /v1/labs/{code}Edit or suspend a lab partnerGET /v1/labs/{code}/loginsA lab's logins and pending invitationsPOST /v1/labs/{code}/invitationsInvite a lab analyst (link shown once)POST /v1/labs/{code}/invitations/{id}/revokeRevoke a lab's pending invitationPOST /v1/market-limitsRecord a market limit entryGET /v1/healthOperational status for the admin health pagePOST /v1/labs/{code}/portal-keyGenerate a lab's server-held portal keyGET /v1/metricsRequest, database and scan metrics in the Prometheus text formatGET /v1/registry-listsImported growing-area and packing-house code listsPOST /v1/registry-listsImport a published code listGET /v1/registry-lists/{id}One imported code listPOST /v1/registry-lists/{id}/retireRetire an imported code listGET /v1/registry-lists/{id}/entriesThe entries of an imported code listGET /v1/registry-lists/{id}/fileThe stored file of an imported code listGET /v1/registry-lists/{id}/sourceThe authority's original file of an imported code listGET /v1/registry-matchesRegistered codes checked against the current code listsPUT /v1/registry-sources/{sha256}Upload the authority's original file of a code listPOST /v1/labs/{code}/approvalsRecord a lab's market approvalPATCH /v1/labs/{code}/approvals/{id}Correct or withdraw a lab's market approvalGET /v1/labs/{code}/companiesThe companies a lab servesPUT /v1/labs/{code}/companies/{tenant}Let a lab serve a companyDELETE /v1/labs/{code}/companies/{tenant}Stop a lab serving a companyGET /v1/export-label-templatesThe export label templatesPUT /v1/export-label-templates/{market}Edit a market's export label templateGET /v1/device-approvalsThe platform's device approval queuePOST /v1/devices/{id}/approveApprove a device (platform)POST /v1/devices/{id}/rejectReject a device (platform)POST /v1/devices/{id}/placementsRecord a device placement (platform)POST /v1/gateways/{id}/approveApprove a gateway (platform)POST /v1/gateways/{id}/rejectReject a gateway (platform)GET /v1/platform/support-requestsList every company's support requests (the platform's queue)PATCH /v1/platform/support-requests/{id}Change a support request's status or replyGET /v1/platform/announcementsList the platform announcementsPOST /v1/platform/announcementsPost a platform announcement for the staff shellPOST /v1/platform/announcements/{id}/expireEnd a platform announcement nowGET /v1/platform/overviewRead the platform overviewPOST /v1/tenants/{id}/offboardingMark a company as leaving CropPathPOST /v1/tenants/{id}/offboarding/cancelCancel a company's departure during its window
POST /v1/broker/authz
EMQX HTTP authorization callback
Xác thực: broker · authorizeBrokerAction
Called by the MQTT broker, not by browsers. Authenticated with the shared broker secret as a bearer token. Answers 404 when the backend runs without a broker secret.
Nội dung yêu cầu
BrokerAuthzRequest (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"username": "knk-1",
"action": "publish",
"topic": "agritrace/v1/coop-dl/ph1/knk-1/event"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | BrokerAuthzResultapplication/json | The decision. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | The broker secret is wrong or missing. |
| 404 | Errorapplication/json | No broker secret is configured, so the route does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"result": "allow"
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "invalid broker token",
"code": "invalid_broker_token"
}Phản hồi 404 · application/json
{
"error": "no such route",
"code": "no_such_route"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/facilities
Register a facility
Xác thực: cookie, bearer · createFacility
Creates an unapproved facility (source manual) owned by the tenant the platform admin acts for (X-Tenant); the body cannot name another tenant. The code is unique across all tenants and cannot be changed later. The slug defaults to the lower-cased code. Audited (facility.create). Allowed for platform_admin only. #273: the address in Viet Nam is given by official code, province_code and commune_code from getAdminUnits; the server writes the official names (district null). The text fields province and district are deprecated (sunset 1 May 2027): a text-only address is still accepted, stores the record as not yet coded and answers with the Deprecation, Sunset and Link headers.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
FacilityCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"code": "VN-TGPH-021",
"name": "Tan Phu packing house",
"address": "Ấp 3, Ngũ Hiệp",
"province_code": "82",
"commune_code": "28516",
"gacc_phc_code": "VNPH-TG-021",
"lines": [
"L1",
"L2"
]
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | Facilityapplication/json | The new facility. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a code that does not look like VN-TGPH-021, a missing name, a value out of bounds, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header. #273: also a code that is not in the administrative units list in force ( |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The code or slug is taken, or the acting tenant is not registered. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
| 503 | Errorapplication/json | #273: |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
Deprecation | 201 | string | #273: sent only when the request gave the address in Viet Nam as text only ( |
Sunset | 201 | string | #273: sent only when the request gave the address in Viet Nam as text only ( |
Link | 201 | string | #273: sent only when the request gave the address in Viet Nam as text only ( |
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 |
X-Request-Id | 503 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"code": "VN-TGPH-021",
"tenant": "coop-dl",
"name": "Tan Phu packing house",
"address": "Ấp 3, Ngũ Hiệp",
"province": "Tỉnh Đồng Tháp",
"district": null,
"gacc_phc_code": "VNPH-TG-021",
"lines": [
"L1",
"L2"
],
"source": "manual",
"approved_at": null,
"slug": "vn-tgph-021",
"created_at": 1790000000.5,
"updated_at": 1790000000.5,
"proposed_at": null
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_code
{
"error": "invalid code: must look like VN-TGPH-021",
"code": "invalid_code"
}Phản hồi 400 · application/json · invalid_name
{
"error": "invalid name: a string of at most 200 characters, not empty",
"code": "invalid_name"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 400 · application/json · admin_unit_unknown
{
"error": "admin unit unknown: commune 99999 is not in the official list vn-2026-10-17",
"code": "admin_unit_unknown"
}Phản hồi 400 · application/json · commune_not_in_province
{
"error": "commune not in province: commune 00004 (Phường Ba Đình) is in province 01 (Thành phố Hà Nội), not in 82 (Tỉnh Đồng Tháp)",
"code": "commune_not_in_province"
}Phản hồi 400 · application/json · district_with_codes
{
"error": "district with codes: Viet Nam has no district level since 2025-07-01; send it null",
"code": "district_with_codes"
}Phản hồi 400 · application/json · invalid_province
{
"error": "invalid province: absent or null with the codes, the server writes the official name",
"code": "invalid_province"
}Phản hồi 400 · application/json · invalid_province_code
{
"error": "invalid province_code: the official code, 2 digits as a string, sent with commune_code",
"code": "invalid_province_code"
}Phản hồi 400 · application/json · invalid_commune_code
{
"error": "invalid commune_code: the official code, 5 digits as a string, sent with province_code",
"code": "invalid_commune_code"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · code_taken
{
"error": "facility code already exists",
"code": "facility_code_already_exists"
}Phản hồi 409 · application/json · slug_taken
{
"error": "slug already in use",
"code": "slug_already_in_use"
}Phản hồi 409 · application/json · tenant
{
"error": "tenant not registered",
"code": "tenant_not_registered"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Phản hồi 503 · application/json
{
"error": "administrative units catalog unavailable",
"code": "administrative_units_catalog_unavailable"
}POST /v1/facilities/{code}/approve
Approve a facility
Xác thực: cookie, bearer · approveFacility
Sets approved_at. Idempotent: approving an approved facility keeps the first approved_at. No request body. Audited (facility.approve). Allowed for platform_admin only, in the tenant it acts for.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Facility code. |
Idempotency-Keykhông bắt buộc | 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 |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | Facilityapplication/json | The approved facility. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 404 | Errorapplication/json | No such facility for this tenant: a facility of another tenant, or outside an operator's facilities, answers exactly like a missing one. |
| 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 |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"code": "VN-TGPH-021",
"tenant": "coop-dl",
"name": "Tan Phu packing house",
"address": "Cai Lay, Tien Giang",
"province": "Tien Giang",
"district": "Cai Lay",
"gacc_phc_code": "VNPH-TG-021",
"lines": [
"L1",
"L2"
],
"source": "manual",
"approved_at": 1790000100,
"slug": "vn-tgph-021",
"created_at": 1790000000.5,
"updated_at": 1790000100,
"proposed_at": null
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: VN-TGPH-021",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/facility-proposals
The platform's facility proposal queue
Xác thực: cookie, bearer · listFacilityProposals
SELF-2-8 (#197): every company's facility proposals waiting for CropPath, ordered by code, with keyset pagination, each with its company and who proposed it when. Allowed for platform_admin only (never an OAuth client).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 200. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | FacilityProposalPageapplication/json | One page of the queue. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit outside 1 to 200, 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 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"code": "VN-TGPH-044",
"tenant": "coop-dl",
"tenant_name": "Coop DL",
"name": "Hoa Hung packing house",
"address": "Cai Be, Tien Giang",
"province": "Tien Giang",
"district": "Cai Be",
"lines": [
"A1"
],
"slug": "vn-tgph-044",
"proposed_at": 1790000000.5,
"proposed_by": "admin@coop.example"
}
],
"next_cursor": null
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/facility-proposals/{code}/approve
Approve a company's facility proposal (platform)
Xác thực: cookie, bearer · approveFacilityProposal
SELF-2-8 (#197): a platform admin approves a facility proposal of any company, setting its slug and GACC PHC code in the same change when given. 409 when the facility is not a company's proposal (approve it with POST /v1/facilities/{code}/approve), is already approved, or the slug is taken. Audited (facility.proposal.approve) in the proposing company's activity log. Allowed for platform_admin only (never an OAuth client).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Facility code. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
FacilityProposalApproval (không bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"slug": "hoahung",
"gacc_phc_code": "VNPH-TG-044"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | Facilityapplication/json | The approved facility. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a bad slug or GACC PHC code, or a bad X-Request-Id; 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, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the proposing company is leaving CropPath or has left, whatever company the platform admin acts for; nothing changes. |
| 404 | Errorapplication/json | No facility has this code. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | Not a company's proposal, already approved, or the slug is taken. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"code": "VN-TGPH-044",
"tenant": "coop-dl",
"name": "Hoa Hung packing house",
"address": "Cai Be, Tien Giang",
"province": "Tien Giang",
"district": "Cai Be",
"gacc_phc_code": "VNPH-TG-044",
"lines": [
"A1"
],
"source": "manual",
"approved_at": 1790000300,
"slug": "hoahung",
"created_at": 1790000000.5,
"updated_at": 1790000300,
"proposed_at": 1790000000.5
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_slug
{
"error": "invalid slug: lower-case letters and digits joined by single hyphens, at most 64 characters",
"code": "invalid_slug"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: VN-TGPH-044",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · not_a_proposal
{
"error": "facility is not a proposal",
"code": "facility_is_not_a_proposal"
}Phản hồi 409 · application/json · already_approved
{
"error": "facility already approved",
"code": "facility_already_approved"
}Phản hồi 409 · application/json · slug_taken
{
"error": "slug already in use",
"code": "slug_already_in_use"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/facility-proposals/{code}/reject
Reject a company's facility proposal (platform)
Xác thực: cookie, bearer · rejectFacilityProposal
SELF-2-8 (#197): a platform admin rejects a facility proposal of any company with a reason the company reads in its activity log. The proposal is deleted, so its code is free again (nothing can name a proposal). 409 when the facility is not a company's proposal or is already approved. Audited (facility.proposal.reject) in the proposing company's activity log. Allowed for platform_admin only (never an OAuth client).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Facility code. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
FacilityProposalRejection (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"reason": "This code belongs to another company's packing house."
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | FacilityProposalRejectedapplication/json | What was rejected. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a missing or too long reason, or a bad X-Request-Id; 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, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the proposing company is leaving CropPath or has left, whatever company the platform admin acts for; nothing changes. |
| 404 | Errorapplication/json | No facility has this code. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | Not a company's proposal, or already approved. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"code": "VN-TGPH-044",
"tenant": "coop-dl",
"name": "Hoa Hung packing house",
"reason": "This code belongs to another company's packing house."
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_reason
{
"error": "invalid reason: a string of 1 to 500 characters",
"code": "invalid_reason"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: VN-TGPH-044",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · not_a_proposal
{
"error": "facility is not a proposal",
"code": "facility_is_not_a_proposal"
}Phản hồi 409 · application/json · already_approved
{
"error": "facility already approved",
"code": "facility_already_approved"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/polygon-proposals
Companies' growing-area boundary proposals (platform)
Xác thực: cookie, bearer · listPolygonProposals
SENS-A1 (#224): every company's growing-area boundary changes waiting for CropPath, ordered by area code, with keyset pagination, each with its company, the proposed boundary and its SHA-256, who proposed it when, and the version in force. Allowed for platform_admin only (never an OAuth client). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 200. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | PolygonProposalPageapplication/json | One page of the queue. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit outside 1 to 200, 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 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"code": "VN-TGOR-0387",
"tenant": "coop-dl",
"tenant_name": "Coop DL",
"name": "Orchard 387",
"polygon": {
"type": "Polygon",
"coordinates": [
[
[
106.1,
10.4
],
[
106.2,
10.4
],
[
106.2,
10.5
],
[
106.1,
10.5
],
[
106.1,
10.4
]
]
]
},
"polygon_sha256": "9c419c419c419c419c419c419c419c419c419c419c419c419c419c419c419c41",
"proposed_at": 1790007200.5,
"proposed_by": "admin@coop.example",
"current_version": 2,
"current_polygon_sha256": "3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a",
"current_polygon": {
"type": "Polygon",
"coordinates": [
[
[
106.1,
10.4
],
[
106.15,
10.4
],
[
106.15,
10.5
],
[
106.1,
10.5
],
[
106.1,
10.4
]
]
]
}
}
],
"next_cursor": null
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/polygon-proposals/{code}/approve
Approve a company's growing-area boundary proposal (platform)
Xác thực: cookie, bearer · approvePolygonProposal
SENS-A1 (#224): a platform admin approves the boundary change waiting on a growing area of any company, naming the SHA-256 of the proposal they reviewed. The proposal becomes the area's boundary and a new version, in force from now; earlier versions stay as they were. 409 when the area has no proposal waiting or the proposal is not the one reviewed (the company replaced it meanwhile). Audited (growing_area.polygon.approve, the version's number and SHA-256, never coordinates; the proposal's own row names who proposed it) in the area's company's activity log. Allowed for platform_admin only (never an OAuth client). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Growing area code. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
PolygonProposalApproval (không bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"polygon_sha256": "9c419c419c419c419c419c419c419c419c419c419c419c419c419c419c419c41"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | PolygonVersionapplication/json | The new boundary version. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a missing or malformed polygon_sha256, or a bad X-Request-Id; 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, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the proposing company is leaving CropPath or has left, whatever company the platform admin acts for; nothing changes. |
| 404 | Errorapplication/json | No growing area has this code. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | No boundary proposal is waiting, or the proposal is not the one reviewed. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"growing_area": "VN-TGOR-0387",
"version": 2,
"polygon_sha256": "3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a3f5a",
"valid_from": 1790003600,
"origin": "proposal",
"polygon": {
"type": "Polygon",
"coordinates": [
[
[
106.1,
10.4
],
[
106.2,
10.4
],
[
106.2,
10.5
],
[
106.1,
10.5
],
[
106.1,
10.4
]
]
]
},
"proposed_at": 1790000000.5,
"proposed_by": "admin@coop.example",
"approved_by": "root@croppath.example"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · polygon_sha256_is_required
{
"error": "polygon_sha256 is required: the SHA-256 of the proposal reviewed, or null for a removal",
"code": "polygon_sha256_is_required"
}Phản hồi 400 · application/json · invalid_polygon_sha256
{
"error": "invalid polygon_sha256: 64 lower-case hex characters, or null",
"code": "invalid_polygon_sha256"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: VN-TGOR-0387",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · no_polygon_proposal
{
"error": "no polygon proposal: the area has no boundary change waiting for approval",
"code": "no_polygon_proposal"
}Phản hồi 409 · application/json · polygon_proposal_changed
{
"error": "polygon proposal changed: it is not the one reviewed; review it again",
"code": "polygon_proposal_changed"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/polygon-proposals/{code}/reject
Reject a company's growing-area boundary proposal (platform)
Xác thực: cookie, bearer · rejectPolygonProposal
SENS-A1 (#224): a platform admin rejects the boundary change waiting on a growing area of any company, with a reason the company reads in its activity log; the boundary in force stays. 409 when no proposal is waiting. Audited (growing_area.polygon.reject) in the area's company's activity log. Allowed for platform_admin only (never an OAuth client). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Growing area code. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
PolygonProposalRejection (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"reason": "The new boundary covers the neighbour's plot."
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | PolygonProposalRejectedapplication/json | What was rejected. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a missing or too long reason, or a bad X-Request-Id; 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, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the proposing company is leaving CropPath or has left, whatever company the platform admin acts for; nothing changes. |
| 404 | Errorapplication/json | No growing area has this code. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | No boundary proposal is waiting. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"code": "VN-TGOR-0387",
"tenant": "coop-dl",
"polygon_sha256": "9c419c419c419c419c419c419c419c419c419c419c419c419c419c419c419c41",
"proposed_at": 1790007200.5,
"proposed_by": "admin@coop.example",
"reason": "The new boundary covers the neighbour's plot."
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_reason
{
"error": "invalid reason: a string of 1 to 500 characters",
"code": "invalid_reason"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: VN-TGOR-0387",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · no_polygon_proposal
{
"error": "no polygon proposal: the area has no boundary change waiting for approval",
"code": "no_polygon_proposal"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/growing-areas/{code}/approve
Approve a growing area
Xác thực: cookie, bearer · approveGrowingArea
Marks the area approved; idempotent (approved_at is kept), except that an approval older than the last change of the area's crop or variety is stale and is replaced (already_approved false in the audit). Audited (growing_area.approve). Allowed for platform_admin only.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Growing area code. |
Idempotency-Keykhông bắt buộc | 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 |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | GrowingAreaapplication/json | The approved growing area. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 404 | Errorapplication/json | No such growing area for this tenant: another tenant's area answers exactly like a missing one. |
| 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 |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"code": "VN-TGOR-0387",
"tenant": "coop-dl",
"name": "Orchard 387",
"crop": "durian",
"variety": "Ri6",
"province": "Tien Giang",
"district": "Cai Lay",
"commune": "Ngu Hiep",
"area_ha": 2,
"yield_kg_per_ha": 10000,
"trees": 240,
"planted_year": 2015,
"grower_id": 12,
"gacc_puc_code": "VNPUC-TG-0387",
"source": "manual",
"approved_at": 1790000100,
"created_at": 1790000000.5,
"updated_at": 1790000000.5,
"registry_changed_at": null,
"cap_kg": 20000,
"approval_current": true,
"grower": {
"id": 12,
"tenant": "coop-dl",
"display_name": "Co-op member #12",
"cooperative": "HTX Ngu Hiep",
"public_consent": false,
"consent_at": null,
"consent_date": null,
"consent_scope": null,
"created_at": 1790000000.5,
"updated_at": 1790000000.5,
"name": "Nguyen Van An"
},
"polygon": {
"type": "Polygon",
"coordinates": [
[
[
106.1,
10.4
],
[
106.2,
10.4
],
[
106.2,
10.5
],
[
106.1,
10.5
],
[
106.1,
10.4
]
]
]
}
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: VN-TGOR-0387",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/tenants
Every tenant
Xác thực: cookie, bearer · listTenants
All tenants ordered by id, with keyset pagination. Allowed for platform_admin only.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 200. |
platformkhông bắt buộc | query | "0" | "1" |
|
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | TenantPageapplication/json | One page of tenants. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit outside 1 to 200, 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 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"id": "coop-dl",
"name": "Dak Lak durian co-op",
"source": "manual",
"created_at": 1790000000.5,
"members": 12,
"admins": 2,
"offboarding": {
"status": "active",
"retention_years": null,
"started_at": null,
"window_ends_at": null,
"left_at": null,
"retention_ends_at": null,
"steps_done": 0
}
}
],
"next_cursor": null
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/tenants
Register a tenant
Xác thực: cookie, bearer · createTenant
Audited (tenant.create). Allowed for platform_admin only. Tenants cannot be renamed or deleted through the API.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
TenantCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"id": "coop-dl",
"name": "Dak Lak durian co-op"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | Tenantapplication/json | The new tenant. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a malformed id or name, or a bad X-Request-Id; 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, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The id is taken. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": "coop-dl",
"name": "Dak Lak durian co-op",
"source": "manual",
"created_at": 1790000000.5,
"members": 12,
"admins": 2,
"offboarding": {
"status": "active",
"retention_years": null,
"started_at": null,
"window_ends_at": null,
"left_at": null,
"retention_ends_at": null,
"steps_done": 0
}
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_id
{
"error": "invalid id: 2 to 64 lower-case letters, digits or hyphens, not starting with a hyphen",
"code": "invalid_id"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · tenant_already_exists
{
"error": "tenant already exists",
"code": "tenant_already_exists"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/tenants/{id}/admins
A company's admins
Xác thực: cookie · listTenantAdmins
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-1-3 (#184). The company admins of a company that the platform's admin recovery can reset (never an account that is also a platform admin or a lab user): id, email, name and account status, never a password or a link. Allowed for platform_admin through a signed-in session only. An unknown company is a 404.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The company (tenant id). |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | TenantAdminListapplication/json | The company's admins, by email. |
| 400 | Errorapplication/json | 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 (platform_admin only, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"user_id": 4,
"email": "boss@coop-new.example",
"display_name": "Chi Lan",
"status": "active"
}
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: coop-new",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/tenants/{id}/admin-invitations
Invite a company's first admin (link shown once)
Xác thực: cookie · createAdminInvitation
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-1-3 (#184). Creates a one-time link that lets the person with email choose a password and join the company as tenant_admin (or, when the email has an account, sign in and join). The link is returned once (no-store) and works once, for 72 hours, unless revoked; only the SHA-256 of its token is stored, so no read ever returns it. With an active company admin (an active membership and account) in place, a further invitation is the platform's admin recovery and needs a reason. Audited (account_link.create, in the same transaction, in the company's own log: purpose, role, reason, expiry; never the link). Allowed for platform_admin through a signed-in session only; the session must have confirmed its password within the last 10 minutes (SELF-1-2), else 401 reauthentication_required before anything is done.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The company (tenant id). |
Nội dung yêu cầu
AdminInvitationCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"email": "first.admin@coop-new.example",
"display_name": "Chi Lan"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | AccountLinkCreatedapplication/json | The link, shown this once. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a bad email, display name or reason, a missing reason when the company already has an admin, or a bad X-Request-Id; or an Idempotency-Key header, which this operation refuses: its response holds the link, whose token is never stored. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (platform_admin only, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | A company cap is reached: at most 50 pending links, and 30 new links an hour. SELF-2-4 (#193): or the company has left CropPath ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Cache-Control | 201 | string |
|
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 | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": 12,
"link": "https://txng.theio.vn/login#invite=agi_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGxl",
"expires_at": 1790259200.5,
"emailed": true
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · email
{
"error": "invalid email",
"code": "invalid_email"
}Phản hồi 400 · application/json · reason_required
{
"error": "reason is required: the company already has an admin",
"code": "reason_is_required"
}Phản hồi 400 · application/json · unknown
{
"error": "unknown fields: role",
"code": "unknown_fields"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · idempotency_key_not_supported
{
"error": "idempotency key not supported",
"code": "idempotency_key_not_supported"
}Phản hồi 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: coop-new",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · pending
{
"error": "too many pending links: at most 50 per company",
"code": "too_many_pending_links"
}Phản hồi 409 · application/json · hourly
{
"error": "too many links: at most 30 per company per hour",
"code": "too_many_links"
}Phản hồi 409 · application/json · company_left
{
"error": "company left: the company has left CropPath; nobody can join it or be let back in",
"code": "company_left"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/tenants/{id}/admins/{user_id}/recovery-link
Let a company admin set a new password (link shown once)
Xác thực: cookie · createAdminRecoveryLink
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-1-3 (#184). The platform's admin recovery: a one-time link that lets a company admin of the company choose a new password; accepting it ends every session of that account. Returned once (no-store); works once, for 24 hours, unless revoked; only the SHA-256 of its token is stored. A reason is required. Audited (account_link.create, in the same transaction, in the company's own log, so the company sees it: purpose, role, reason, expiry; never the link). Someone who is not an admin of this company, an account that is also a platform admin or a lab user (no link resets one; a link made before the account gained such a role stops working), or no such account, is a 404. Allowed for platform_admin through a signed-in session only, with a password confirmed within the last 10 minutes (SELF-1-2).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The company (tenant id). |
user_idbắt buộc | path | string | The company admin's account id (from listTenantAdmins). |
Nội dung yêu cầu
RecoveryLinkCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"reason": "Lost phone, cannot sign in"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | AccountLinkCreatedapplication/json | The link, shown this once. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a missing or bad reason, or a bad X-Request-Id; or an Idempotency-Key header, which this operation refuses: its response holds the link, whose token is never stored. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (platform_admin only, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such company, or no admin of it with that id. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | A company cap is reached: at most 50 pending links, and 30 new links an hour. SELF-2-4 (#193): or the company has left CropPath ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Cache-Control | 201 | string |
|
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 | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": 12,
"link": "https://txng.theio.vn/login#reset=agr_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGxl",
"expires_at": 1790086400.5,
"emailed": true
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · reason_required
{
"error": "reason is required",
"code": "reason_is_required"
}Phản hồi 400 · application/json · reason
{
"error": "invalid reason: 1 to 200 characters on one line",
"code": "invalid_reason"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · idempotency_key_not_supported
{
"error": "idempotency key not supported",
"code": "idempotency_key_not_supported"
}Phản hồi 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: 4",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · pending
{
"error": "too many pending links: at most 50 per company",
"code": "too_many_pending_links"
}Phản hồi 409 · application/json · hourly
{
"error": "too many links: at most 30 per company per hour",
"code": "too_many_links"
}Phản hồi 409 · application/json · company_left
{
"error": "company left: the company has left CropPath; nobody can join it or be let back in",
"code": "company_left"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/crops
List the crop registry
Xác thực: cookie, bearer · listCrops
Every crop of the registry by code, and the configured crops without a registry entry. The crop registry: a lot's product and a growing area's crop must name a crop of the registry or one of the deployment's configured crops. Durian is the crop the platform started with; other crops' rules are added here once their published source is known. Allowed for platform_admin only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CropListapplication/json | The registry. |
| 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 not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"code": "durian",
"names": {
"vi": "Sầu riêng",
"en": "Durian",
"zh-Hans": "榴莲"
},
"ripeness_scale": "levels_1_to_4",
"created_at": 0,
"updated_at": 0
}
],
"configured": [
"coconut",
"dragon_fruit",
"jackfruit",
"mango"
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/crops
Add a crop to the registry
Xác thực: cookie, bearer · createCrop
A platform admin adds a crop: its code, its names in Vietnamese, English and Simplified Chinese and its ripeness scale (null when it has none). A crop is never deleted. Audited (crop.create, in the same transaction). Allowed for platform_admin only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
CropCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"code": "longan",
"names": {
"vi": "Nhãn",
"en": "Longan",
"zh-Hans": "龙眼"
},
"ripeness_scale": null
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | Cropapplication/json | The crop added. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a bad code, names or ripeness scale, 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 not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The crop code is taken, or the registry holds 200 crops. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"code": "longan",
"names": {
"vi": "Nhãn",
"en": "Longan",
"zh-Hans": "龙眼"
},
"ripeness_scale": null,
"created_at": 1790000000.5,
"updated_at": 1790000000.5
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field: hs_code",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_code
{
"error": "invalid code: 1 to 64 lower-case letters, digits or '_', starting with a letter",
"code": "invalid_code"
}Phản hồi 400 · application/json · invalid_names
{
"error": "invalid names: an object with the crop's name in vi, en and zh-Hans",
"code": "invalid_names"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · crop_code_taken
{
"error": "crop code taken",
"code": "crop_code_taken"
}Phản hồi 409 · application/json · too_many_crops
{
"error": "too many crops: the registry holds at most 200",
"code": "too_many_crops"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/crops/{code}
Get a crop with its rules
Xác thực: cookie, bearer · getCrop
A crop of the registry with its rules per destination market (registration protocol and sampling rule) and its grading rules. Allowed for platform_admin only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Crop code. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CropDetailapplication/json | The crop and its rules. |
| 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 not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such crop in the registry. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"code": "durian",
"names": {
"vi": "Sầu riêng",
"en": "Durian",
"zh-Hans": "榴莲"
},
"ripeness_scale": "levels_1_to_4",
"created_at": 0,
"updated_at": 0,
"markets": [
{
"crop": "durian",
"market": "CN",
"registration_protocol": true,
"sampling": {
"rule": "cn-durian-protocol-2022",
"rule_source": "https://trungtamwto.vn/thi-truong-duc/21143-sau-rieng-viet-nam-xuat-khau-chinh-ngach-sang-trung-quoc",
"base_rate": 0.02,
"clean_rate": 0.01,
"clean_days": 730,
"analytes": [
"cadmium",
"auramine_o"
],
"analytes_source": "https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports"
},
"created_at": 0,
"updated_at": 0
}
],
"grading_rules": [
{
"crop": "durian",
"variety": null,
"rules": {
"a_levels": [
2,
3
],
"reject_levels": [
1,
4
],
"a_weight_kg": [
[
2,
5
]
],
"a_min_confidence": 0.8,
"eating_window": [
{
"band": "ambient",
"end_days": 7,
"level": 1,
"max_days": 30,
"min_days": 0,
"start_days": 5,
"warning": "immature"
},
{
"band": "ambient",
"end_days": 6,
"level": 2,
"max_days": 1,
"min_days": 0,
"start_days": 4,
"warning": null
},
{
"band": "ambient",
"end_days": 4,
"level": 2,
"max_days": 3,
"min_days": 2,
"start_days": 3,
"warning": null
},
{
"band": "ambient",
"end_days": 2,
"level": 2,
"max_days": 30,
"min_days": 4,
"start_days": 1,
"warning": "eat_soon"
},
{
"band": "ambient",
"end_days": 4,
"level": 3,
"max_days": 1,
"min_days": 0,
"start_days": 3,
"warning": null
},
{
"band": "ambient",
"end_days": 3,
"level": 3,
"max_days": 3,
"min_days": 2,
"start_days": 2,
"warning": null
},
{
"band": "ambient",
"end_days": 1,
"level": 3,
"max_days": 30,
"min_days": 4,
"start_days": 0,
"warning": "eat_soon"
},
{
"band": "ambient",
"end_days": 1,
"level": 4,
"max_days": 30,
"min_days": 0,
"start_days": 0,
"warning": "overripe"
},
{
"band": "14-18C",
"end_days": 10,
"level": 1,
"max_days": 30,
"min_days": 0,
"start_days": 7,
"warning": "immature"
},
{
"band": "14-18C",
"end_days": 8,
"level": 2,
"max_days": 30,
"min_days": 0,
"start_days": 5,
"warning": null
},
{
"band": "14-18C",
"end_days": 6,
"level": 3,
"max_days": 30,
"min_days": 0,
"start_days": 4,
"warning": null
},
{
"band": "14-18C",
"end_days": 2,
"level": 4,
"max_days": 30,
"min_days": 0,
"start_days": 0,
"warning": "overripe"
},
{
"band": "10-13C",
"end_days": 12,
"level": 1,
"max_days": 30,
"min_days": 0,
"start_days": 9,
"warning": "immature"
},
{
"band": "10-13C",
"end_days": 10,
"level": 2,
"max_days": 30,
"min_days": 0,
"start_days": 7,
"warning": null
},
{
"band": "10-13C",
"end_days": 8,
"level": 3,
"max_days": 30,
"min_days": 0,
"start_days": 5,
"warning": null
},
{
"band": "10-13C",
"end_days": 2,
"level": 4,
"max_days": 30,
"min_days": 0,
"start_days": 0,
"warning": "overripe"
}
]
},
"created_at": 0,
"updated_at": 0
}
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json · not_found
{
"error": "not found: crops",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PATCH /v1/crops/{code}
Edit a crop
Xác thực: cookie, bearer · updateCrop
A platform admin changes a crop's names or ripeness scale (its code never changes). Audited (crop.update, in the same transaction). Allowed for platform_admin only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Crop code. |
Nội dung yêu cầu
CropUpdate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"ripeness_scale": "levels_1_to_4"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | Cropapplication/json | The crop after the change. |
| 400 | Errorapplication/json | Invalid JSON, nothing to update, an unknown field, a bad value, 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 not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such crop in the registry. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"code": "longan",
"names": {
"vi": "Nhãn",
"en": "Longan",
"zh-Hans": "龙眼"
},
"ripeness_scale": "levels_1_to_4",
"created_at": 1790000000.5,
"updated_at": 1790000060.5
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · nothing_to_update
{
"error": "nothing to update",
"code": "nothing_to_update"
}Phản hồi 400 · application/json · invalid_ripeness_scale
{
"error": "invalid ripeness_scale: levels_1_to_4 or null (the crop has no ripeness scale)",
"code": "invalid_ripeness_scale"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json · not_found
{
"error": "not found: crops",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/crops/{code}/markets/{market}
Set a crop's rules for a destination market
Xác thực: cookie, bearer · putCropMarketRule
A platform admin sets, for one crop and destination market, whether the market's registration protocol applies to the crop and the market's sampling rule (null: none). A lot is sampled under its crop's rule for its destination market (or the crop's only rule when the lot names no market); a crop without a rule is not sampled. The rule id is unique across crops and markets, and the id of a rule lots were sampled under cannot be replaced (its numbers can, for later samplings). Audited (crop_market_rule.put, in the same transaction). Allowed for platform_admin only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Crop code. |
marketbắt buộc | path | string | Destination market (ISO 3166-1 alpha-2). |
Nội dung yêu cầu
CropMarketRulePut (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"registration_protocol": true,
"sampling": {
"rule": "cn-durian-protocol-2022",
"rule_source": "https://trungtamwto.vn/thi-truong-duc/21143-sau-rieng-viet-nam-xuat-khau-chinh-ngach-sang-trung-quoc",
"base_rate": 0.02,
"clean_rate": 0.01,
"clean_days": 730,
"analytes": [
"cadmium",
"auramine_o"
],
"analytes_source": "https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports"
}
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CropMarketRuleapplication/json | The crop's rules for the market. |
| 400 | Errorapplication/json | Invalid JSON, an unknown market, an unknown or missing field, a bad value, 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 not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such crop in the registry. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | Another crop or market uses the rule id, or lots were sampled under the rule id this would replace. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"crop": "durian",
"market": "CN",
"registration_protocol": true,
"sampling": {
"rule": "cn-durian-protocol-2022",
"rule_source": "https://trungtamwto.vn/thi-truong-duc/21143-sau-rieng-viet-nam-xuat-khau-chinh-ngach-sang-trung-quoc",
"base_rate": 0.02,
"clean_rate": 0.01,
"clean_days": 730,
"analytes": [
"cadmium",
"auramine_o"
],
"analytes_source": "https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports"
},
"created_at": 0,
"updated_at": 0
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_market
{
"error": "invalid market: one of CN",
"code": "invalid_market"
}Phản hồi 400 · application/json · missing_field
{
"error": "missing field: sampling.clean_days",
"code": "missing_field"
}Phản hồi 400 · application/json · invalid_base_rate
{
"error": "invalid sampling.base_rate: a share above 0 and at most 1 (0.02 is 2%)",
"code": "invalid_sampling_base_rate"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json · not_found
{
"error": "not found: crops",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · taken
{
"error": "sampling rule id taken: another crop or market uses it",
"code": "sampling_rule_id_taken"
}Phản hồi 409 · application/json · recorded
{
"error": "sampling rule recorded: lots were sampled under this rule id; keep the id to edit it",
"code": "sampling_rule_recorded"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/crops/{code}/grading-rules
Set a crop's grading rules
Xác thực: cookie, bearer · putCropGradingRule
A platform admin sets the platform's grading rules for one variety of a crop, or for every variety of it (variety null). A lot is graded by its company's rules for its variety when the company has some, else by these (the variety's, else the crop's), else by the platform default. Audited (crop_grading_rule.put, in the same transaction). Allowed for platform_admin only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Crop code. |
Nội dung yêu cầu
CropGradingRulePut (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"variety": null,
"rules": {
"a_levels": [
2,
3
],
"reject_levels": [
1,
4
],
"a_weight_kg": [
[
2,
5
]
],
"a_min_confidence": 0.8,
"eating_window": [
{
"band": "ambient",
"end_days": 7,
"level": 1,
"max_days": 30,
"min_days": 0,
"start_days": 5,
"warning": "immature"
},
{
"band": "ambient",
"end_days": 6,
"level": 2,
"max_days": 1,
"min_days": 0,
"start_days": 4,
"warning": null
},
{
"band": "ambient",
"end_days": 4,
"level": 2,
"max_days": 3,
"min_days": 2,
"start_days": 3,
"warning": null
},
{
"band": "ambient",
"end_days": 2,
"level": 2,
"max_days": 30,
"min_days": 4,
"start_days": 1,
"warning": "eat_soon"
},
{
"band": "ambient",
"end_days": 4,
"level": 3,
"max_days": 1,
"min_days": 0,
"start_days": 3,
"warning": null
},
{
"band": "ambient",
"end_days": 3,
"level": 3,
"max_days": 3,
"min_days": 2,
"start_days": 2,
"warning": null
},
{
"band": "ambient",
"end_days": 1,
"level": 3,
"max_days": 30,
"min_days": 4,
"start_days": 0,
"warning": "eat_soon"
},
{
"band": "ambient",
"end_days": 1,
"level": 4,
"max_days": 30,
"min_days": 0,
"start_days": 0,
"warning": "overripe"
},
{
"band": "14-18C",
"end_days": 10,
"level": 1,
"max_days": 30,
"min_days": 0,
"start_days": 7,
"warning": "immature"
},
{
"band": "14-18C",
"end_days": 8,
"level": 2,
"max_days": 30,
"min_days": 0,
"start_days": 5,
"warning": null
},
{
"band": "14-18C",
"end_days": 6,
"level": 3,
"max_days": 30,
"min_days": 0,
"start_days": 4,
"warning": null
},
{
"band": "14-18C",
"end_days": 2,
"level": 4,
"max_days": 30,
"min_days": 0,
"start_days": 0,
"warning": "overripe"
},
{
"band": "10-13C",
"end_days": 12,
"level": 1,
"max_days": 30,
"min_days": 0,
"start_days": 9,
"warning": "immature"
},
{
"band": "10-13C",
"end_days": 10,
"level": 2,
"max_days": 30,
"min_days": 0,
"start_days": 7,
"warning": null
},
{
"band": "10-13C",
"end_days": 8,
"level": 3,
"max_days": 30,
"min_days": 0,
"start_days": 5,
"warning": null
},
{
"band": "10-13C",
"end_days": 2,
"level": 4,
"max_days": 30,
"min_days": 0,
"start_days": 0,
"warning": "overripe"
}
]
}
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CropGradingRuleapplication/json | The grading rules stored. |
| 400 | Errorapplication/json | Invalid JSON, an unknown or missing field, invalid rules, a bad variety, 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 not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such crop in the registry. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The crop already holds 50 other grading rules. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"crop": "durian",
"variety": null,
"rules": {
"a_levels": [
2,
3
],
"reject_levels": [
1,
4
],
"a_weight_kg": [
[
2,
5
]
],
"a_min_confidence": 0.8,
"eating_window": [
{
"band": "ambient",
"end_days": 7,
"level": 1,
"max_days": 30,
"min_days": 0,
"start_days": 5,
"warning": "immature"
},
{
"band": "ambient",
"end_days": 6,
"level": 2,
"max_days": 1,
"min_days": 0,
"start_days": 4,
"warning": null
},
{
"band": "ambient",
"end_days": 4,
"level": 2,
"max_days": 3,
"min_days": 2,
"start_days": 3,
"warning": null
},
{
"band": "ambient",
"end_days": 2,
"level": 2,
"max_days": 30,
"min_days": 4,
"start_days": 1,
"warning": "eat_soon"
},
{
"band": "ambient",
"end_days": 4,
"level": 3,
"max_days": 1,
"min_days": 0,
"start_days": 3,
"warning": null
},
{
"band": "ambient",
"end_days": 3,
"level": 3,
"max_days": 3,
"min_days": 2,
"start_days": 2,
"warning": null
},
{
"band": "ambient",
"end_days": 1,
"level": 3,
"max_days": 30,
"min_days": 4,
"start_days": 0,
"warning": "eat_soon"
},
{
"band": "ambient",
"end_days": 1,
"level": 4,
"max_days": 30,
"min_days": 0,
"start_days": 0,
"warning": "overripe"
},
{
"band": "14-18C",
"end_days": 10,
"level": 1,
"max_days": 30,
"min_days": 0,
"start_days": 7,
"warning": "immature"
},
{
"band": "14-18C",
"end_days": 8,
"level": 2,
"max_days": 30,
"min_days": 0,
"start_days": 5,
"warning": null
},
{
"band": "14-18C",
"end_days": 6,
"level": 3,
"max_days": 30,
"min_days": 0,
"start_days": 4,
"warning": null
},
{
"band": "14-18C",
"end_days": 2,
"level": 4,
"max_days": 30,
"min_days": 0,
"start_days": 0,
"warning": "overripe"
},
{
"band": "10-13C",
"end_days": 12,
"level": 1,
"max_days": 30,
"min_days": 0,
"start_days": 9,
"warning": "immature"
},
{
"band": "10-13C",
"end_days": 10,
"level": 2,
"max_days": 30,
"min_days": 0,
"start_days": 7,
"warning": null
},
{
"band": "10-13C",
"end_days": 8,
"level": 3,
"max_days": 30,
"min_days": 0,
"start_days": 5,
"warning": null
},
{
"band": "10-13C",
"end_days": 2,
"level": 4,
"max_days": 30,
"min_days": 0,
"start_days": 0,
"warning": "overripe"
}
]
},
"created_at": 0,
"updated_at": 0
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_rules
{
"error": "invalid rules: a_weight_kg bands must not overlap",
"code": "invalid_rules"
}Phản hồi 400 · application/json · invalid_variety
{
"error": "invalid variety: a string of 1 to 64 characters",
"code": "invalid_variety"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json · not_found
{
"error": "not found: crops",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · too_many
{
"error": "too many grading rules: a crop holds at most 50",
"code": "too_many_grading_rules"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/labs
Register a lab partner
Xác thực: cookie, bearer · createLab
Registers an accredited lab (status active). A taken code is 409. Audited (lab.create). Allowed for platform_admin.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
LabCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"code": "LAB-VN-118",
"name": "Phòng thử nghiệm mẫu",
"accreditation": "VILAS 118 (ISO/IEC 17025)",
"valid_to": "2027-12-31"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | Labapplication/json | The new lab. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a bad code, name, accreditation or valid_to, or a bad X-Request-Id; 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, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lab code is taken. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"code": "LAB-VN-118",
"name": "Phòng thử nghiệm mẫu",
"accreditation": "VILAS 118 (ISO/IEC 17025)",
"valid_to": "2027-12-31",
"status": "active",
"created_at": 1790000000.5,
"updated_at": 1790000000.5,
"in_force": true,
"accreditation_body": "BoA (VILAS)",
"accreditation_number": "VILAS 118",
"accreditation_scope": "Cadmium (ICP-MS) and auramine O (LC-MS/MS) in fresh fruit"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_code
{
"error": "invalid code: LAB-<country>-<id>, e.g. LAB-VN-118",
"code": "invalid_code"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · lab_code_taken
{
"error": "lab code taken",
"code": "lab_code_taken"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PATCH /v1/labs/{code}
Edit or suspend a lab partner
Xác thực: cookie, bearer · updateLab
Changes name, accreditation, valid_to or status (active or suspended; a suspended lab is not assigned samples). Audited (lab.update). Allowed for platform_admin.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
Nội dung yêu cầu
LabUpdate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"status": "suspended"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | Labapplication/json | The lab after the change. |
| 400 | Errorapplication/json | Invalid JSON, nothing to update, an unknown field, a bad value, 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 not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such lab, or a lab outside the caller's scope (a lab user's other labs). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"code": "LAB-VN-118",
"name": "Phòng thử nghiệm mẫu",
"accreditation": "VILAS 118 (ISO/IEC 17025)",
"valid_to": "2027-12-31",
"status": "suspended",
"created_at": 1790000000.5,
"updated_at": 1790000000.5,
"in_force": false,
"accreditation_body": "BoA (VILAS)",
"accreditation_number": "VILAS 118",
"accreditation_scope": "Cadmium (ICP-MS) and auramine O (LC-MS/MS) in fresh fruit"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_status
{
"error": "invalid status: active or suspended",
"code": "invalid_status"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-118",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/labs/{code}/logins
A lab's logins and pending invitations
Xác thực: cookie · listLabLogins
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
#283. The people who sign in for the lab on the lab portal and the lab's pending invitations; never a link or its token (no-store). Not audited (a read). Allowed for platform_admin through a signed-in session only: a lab login sees every sampling assigned to its lab, for every company, so a company admin never lists or makes one. Not part of the partner SDK clients (x-not-in-sdk): an operation of the platform admin console's lab page.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabLoginsapplication/json | The lab's logins. |
| 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 (platform_admin only, through a signed-in session: an API token, an API client or the legacy token is refused; a company admin never manages a lab's logins), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such lab. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"members": [
{
"email": "analyst@lab-vn-118.example",
"display_name": "Chi Hoa",
"status": "active",
"since": 1790000000.5
}
],
"invitations": [
{
"id": 31,
"email": "second@lab-vn-118.example",
"display_name": null,
"created_at": 1790100000.5,
"created_by": "ops@croppath.example",
"expires_at": 1790359200.5
}
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-404",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/labs/{code}/invitations
Invite a lab analyst (link shown once)
Xác thực: cookie · createLabInvitation
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
#283. Creates a one-time link that lets the person with email choose a password and sign in for the lab on the lab portal (or, when the email has an account that is already this lab's login, only confirm it). The link is returned once (no-store) and works once, for 72 hours, unless revoked; only the SHA-256 of its token is stored. The login belongs to the company record kept only for lab logins (croppath-labs, created with the first invitation), never to a customer company: an email whose account holds any other membership is refused 409 lab_account_must_be_separate, and a company's invitation never reaches a lab login made this way. The lab must exist and be active, when the link is made and when it is accepted. Audited (account_link.create, in the same transaction, in the lab logins' company's log: purpose, role, lab, expiry; never the link). Allowed for platform_admin through a signed-in session only; the session must have confirmed its password within the last 10 minutes (SELF-1-2), else 401 reauthentication_required before anything is done. Not part of the partner SDK clients (x-not-in-sdk): an operation of the platform admin console's lab page.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
Nội dung yêu cầu
LabInvitationCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"email": "analyst@lab-vn-118.example",
"display_name": "Chi Hoa"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | AccountLinkCreatedapplication/json | The link, shown this once. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a bad email or display name, or a bad X-Request-Id; or an Idempotency-Key header, which this operation refuses: its response holds the link, whose token is never stored. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (platform_admin only, through a signed-in session: an API token, an API client or the legacy token is refused; a company admin never manages a lab's logins), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such lab. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lab is suspended; the email's account holds another membership (a company's member, a platform admin or another lab's login), already signs in for this lab, or its login for this lab was turned off by CropPath support (who turns it back on); or a cap of this lab's links is reached: at most 50 pending links, and 30 new links an hour, counted for each lab on its own (another lab's links never count). |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Cache-Control | 201 | string |
|
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 | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": 31,
"link": "https://txng.theio.vn/login#invite=agi_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGxl",
"expires_at": 1790359200.5,
"emailed": false
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · email
{
"error": "invalid email",
"code": "invalid_email"
}Phản hồi 400 · application/json · unknown
{
"error": "unknown fields: role",
"code": "unknown_fields"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · idempotency_key_not_supported
{
"error": "idempotency key not supported",
"code": "idempotency_key_not_supported"
}Phản hồi 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-404",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · suspended
{
"error": "lab suspended: turn the lab back on before inviting anyone",
"code": "lab_suspended"
}Phản hồi 409 · application/json · separate
{
"error": "lab account must be separate: a lab login signs in for one lab and for no company",
"code": "lab_account_must_be_separate"
}Phản hồi 409 · application/json · member
{
"error": "already a member: this person already signs in for this lab",
"code": "already_a_member"
}Phản hồi 409 · application/json · turned_off
{
"error": "lab login turned off: CropPath support turns it back on",
"code": "lab_login_turned_off"
}Phản hồi 409 · application/json · pending
{
"error": "too many pending links: at most 50 per lab",
"code": "too_many_pending_links"
}Phản hồi 409 · application/json · hourly
{
"error": "too many links: at most 30 per lab per hour",
"code": "too_many_links"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/labs/{code}/invitations/{id}/revoke
Revoke a lab's pending invitation
Xác thực: cookie · revokeLabInvitation
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
#283. The lab's invitation stops working at once. Audited (account_link.revoke, in the same transaction, in the lab logins' company's log, with the link's purpose and lab). Turning a lab login off stays with CropPath support. Allowed for platform_admin through a signed-in session only: an API token, an API client or the legacy token is refused (403). Not part of the partner SDK clients (x-not-in-sdk): an operation of the platform admin console's lab page.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
idbắt buộc | path | string | The invitation's id (from listLabLogins). |
Idempotency-Keykhông bắt buộc | 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 |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | InvitationRevokedapplication/json | The invitation, revoked. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (platform_admin only, through a signed-in session: an API token, an API client or the legacy token is refused; a company admin never manages a lab's logins), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No pending invitation of this lab with this id (used, revoked, expired, another lab's or no lab invitation), or no such lab. |
| 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 |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"id": 12,
"status": "revoked"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: 31",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/market-limits
Record a market limit entry
Xác thực: cookie, bearer · createMarketLimit
Appends an entry; it applies from valid_from and supersedes the earlier entry of the same market, product and analyte from that date. Lab reports signed from that date are judged with it; stored results keep the limit they were judged with, and no trust tier is raised without a signed, passing lab report. Audited (market_limit.create, in the same transaction). Allowed for platform_admin only. Step-up (#87): a signed-in session of an account with two-step sign-in must have confirmed a code from its authenticator app (or a backup code) within the last 5 minutes and its password within the last 10 minutes, else 401 mfa_step_up_required before anything is done (no audit row): confirm both with POST /v1/auth/reauth, then repeat the request. A session of an account without two-step sign-in, API tokens and API clients are served as before.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
MarketLimitCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"market": "CN",
"product": "durian",
"analyte": "cadmium",
"kind": "max",
"value": 0.03,
"valid_from": "2026-10-15",
"source": "GB 2762-2026, 4.2 cadmium, fresh fruit 0.03 mg/kg"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | MarketLimitapplication/json | The entry. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field ( |
| 401 | Errorapplication/json | No valid session, API token or legacy token. Or a session of an account with two-step sign-in whose code was last confirmed more than 5 minutes ago, or its password more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | An entry for the same market, product, analyte and date exists. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": 3,
"market": "CN",
"product": "durian",
"analyte": "cadmium",
"kind": "max",
"value": 0.03,
"valid_from": "2026-10-15",
"source": "GB 2762-2026, 4.2 cadmium, fresh fruit 0.03 mg/kg",
"unit": "mg/kg",
"created_at": 1790000000.5,
"created_by": "platform@croppath.example",
"status": "scheduled"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · market
{
"error": "invalid market: an ISO 3166-1 alpha-2 code in capitals, e.g. CN",
"code": "invalid_market"
}Phản hồi 400 · application/json · valid_from
{
"error": "invalid valid_from: from today (2026-09-30) to 10 years ahead",
"code": "invalid_valid_from"
}Phản hồi 400 · application/json · value
{
"error": "invalid value: a ban has no value",
"code": "invalid_value"
}Phản hồi 400 · application/json · source
{
"error": "invalid source: the regulation that sets the limit, 1 to 1000 characters",
"code": "invalid_source"
}Phản hồi 400 · application/json · unknown
{
"error": "unknown fields: unit",
"code": "unknown_fields"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · limit_exists
{
"error": "limit exists: the market already has a limit for this analyte from that date",
"code": "limit_exists"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/health
Operational status for the admin health page
Xác thực: cookie, bearer · getAdminHealth
The body of /healthz (outbound backlog, watched certificates with their expiry, MQTT, read-only mode, warnings) plus the database (dialect, schema version, a round trip), the external timestamp authority (mode, host, backlog) and whether the issuer key store is available. Allowed for platform_admin only. Not audited (a read). no-store.
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | AdminHealthapplication/json | The status. |
| 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 (only platform_admin), 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"ok": true,
"outbound_backlog": {
"national": 0
},
"certificates": [
{
"path": "/certs/gw-01.pem",
"subject": "gw-01",
"not_after": "2027-01-01T00:00:00+00:00",
"remaining_s": 7776000,
"remaining_fraction": 0.5,
"expired": false
}
],
"mqtt": {
"broker": "emqx:8883",
"connected": true
},
"db": {
"dialect": "postgresql",
"schema_version": 30,
"expected_schema_version": 30,
"round_trip_ms": 0.8
},
"tsa": {
"mode": "on",
"host": "freetsa.org",
"pending": 1,
"failing": 1,
"verified": 42
},
"issuer_keys": {
"available": true
}
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/labs/{code}/portal-key
Generate a lab's server-held portal key
Xác thực: cookie, bearer · generateLabPortalKey
A7 (#73): generates an EC P-256 key pair for the lab whose private key the platform keeps (custody server: encrypted under the deployment's key-encryption key, never returned, logged or audited) to sign the results the lab's portal users enter. A lab holds at most one active server-held key: revoke it (POST /v1/labs/{code}/keys/{kid}/revoke, which also deletes the private key) before generating another. Key ids share one namespace with device, gateway and lab keys. Audited (lab_key.generate). Allowed for platform_admin only: holding a lab's key is the platform's custody decision.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
LabPortalKeyCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"kid": "LAB-VN-118.portal"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | LabKeyapplication/json | The new key. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field (the server generates the pair; give only its kid), a bad kid, or a bad X-Request-Id; 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, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such lab. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The key id is taken (by any key) or reserved, or the lab already holds an active server-held key. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
| 503 | Errorapplication/json | No key-encryption key is configured (AGRITRACE_ISSUER_KEK), or the store cannot be used; nothing changed. Retry after |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 | 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 | 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 |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"kid": "LAB-VN-118.portal",
"lab": "LAB-VN-118",
"status": "active",
"created_at": 1790000000.5,
"revoked_at": null,
"revoke_reason": null,
"revoked_by": null,
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"custody": "server"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field: the server generates the key pair; give only its kid",
"code": "unknown_field"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-118",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · kid_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Phản hồi 409 · application/json · portal_key_exists
{
"error": "portal key exists: revoke the lab's active server-held key first",
"code": "portal_key_exists"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Phản hồi 503 · application/json
{
"error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
"code": "issuer_keys_unavailable"
}GET /v1/metrics
Request, database and scan metrics in the Prometheus text format
Xác thực: cookie, bearer · getMetrics
This process's metrics in the Prometheus text exposition format (version 0.0.4), for a platform admin's signed-in session, or for a scraper holding a platform_admin API token, which only CropPath's operators create (on the server, never from the console or the API): per-route request latency histograms (agritrace_http_request_duration_seconds), SQL statements per request (agritrace_http_request_db_statements) and the time a request waited for the database (agritrace_http_request_db_wait_seconds: the SQLite connection lock, or a free pooled PostgreSQL connection), each by method, route pattern (or unmatched) and status; and public scans logged and deduplicated (agritrace_scans_total, scans per second is its rate). #81: also the ingest outcomes of this process (agritrace_ingest_messages_total by result: accepted, quarantined, duplicate, rejected; agritrace_ingest_reasons_total by result and reason code, one per reason of a quarantined or rejected message), the server-sent event streams open on this server and its cap (agritrace_sse_streams_open, agritrace_sse_streams_max), the accepted events not yet delivered per outbound target (agritrace_outbound_backlog, read from the database, so every process reports the same number; 0 for a configured target with nothing waiting), and what the sampled browsers reported to postUiTelemetry (agritrace_ui_lcp_seconds, agritrace_ui_inp_seconds and agritrace_ui_cls histograms, agritrace_ui_beacons_total and agritrace_ui_errors_total, by page kind). #134: also the companies' quotas and their use: agritrace_tenant_quota by company (* for the default of every company not named in AGRITRACE_TENANT_QUOTAS) and quota (api_per_minute, api_per_day, ingest_per_second, ingest_burst), agritrace_tenant_api_calls_today and agritrace_tenant_api_refused_total (by quota: per_minute, per_day) per company, and per company the messages waiting in the ingest backlog (agritrace_tenant_ingest_backlog), kept there (agritrace_tenant_ingest_deferred_total), stored from it (agritrace_tenant_ingest_drained_total), kept while the backlog was over its company's disk budget (agritrace_tenant_ingest_backlog_full_total; such messages are still kept and stored at the quota) and refused over HTTP (agritrace_tenant_ingest_refused_total), the backlog's bytes (agritrace_tenant_ingest_backlog_bytes), and the HTTP messages without a client certificate, or with one of no registered device or gateway, refused by their client address's bucket (agritrace_ingest_unidentified_refused_total, no company label); the company label is a company id, bounded by the number of companies. Public latency is agritrace_http_request_duration_seconds of the /v1/public/... routes. Label values are bounded (no record IDs, addresses or tokens). Allowed for platform_admin only. Not audited (a read). no-store.
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | stringtext/plain; version=0.0.4; charset=utf-8 | The metrics. |
| 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 (only platform_admin), 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
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 |
Ví dụ phản hồi
Phản hồi 200 · text/plain; version=0.0.4; charset=utf-8
# HELP agritrace_http_request_duration_seconds Time from the parsed request to the response sent, by route.
# TYPE agritrace_http_request_duration_seconds histogram
agritrace_http_request_duration_seconds_bucket{method="GET",route="/v1/public/fruits/{publicId}",status="200",le="0.025"} 41
agritrace_http_request_duration_seconds_bucket{method="GET",route="/v1/public/fruits/{publicId}",status="200",le="+Inf"} 42
agritrace_http_request_duration_seconds_sum{method="GET",route="/v1/public/fruits/{publicId}",status="200"} 0.61
agritrace_http_request_duration_seconds_count{method="GET",route="/v1/public/fruits/{publicId}",status="200"} 42
# HELP agritrace_scans_total Public fruit scans the web server's reads logged (new) or found again within the dedupe window (deduplicated); rate() gives scans per second.
# TYPE agritrace_scans_total counter
agritrace_scans_total{result="deduplicated"} 3
agritrace_scans_total{result="logged"} 39
Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/registry-lists
Imported growing-area and packing-house code lists
Xác thực: cookie, bearer · listRegistryLists
Every import of a published PUC/PHC code list (#150), newest first, one page (limit, default 50, at most 200; cursor). current: not superseded by a later import of the same kind, market and crop; stale: current and older than max_age_days (AGRITRACE_REGISTRY_LIST_MAX_AGE_DAYS, default 30), so no registration step is Cross-checked against it; crops: the crops an import may name (AGRITRACE_REGISTRY_CROPS, by default the D7 crops). Platform data, read across tenants. Allowed for platform_admin only. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
limitkhông bắt buộc | query | integer | 1 to 200 (default 50). |
cursorkhông bắt buộc | query | string | The previous page's |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | RegistryListPageapplication/json | One page of imports. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin), 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"id": 3,
"kind": "puc",
"market": "CN",
"crop": "durian",
"source_url": "https://www.ppd.gov.vn/tin-moi-nhat/danh-sach-vung-trong-va-co-so-dong-goi-sau-rieng-duoc-trung-quoc-phe-duyet.html",
"source_sha256": "4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d",
"source_media_type": "application/pdf",
"published_on": "2026-09-25",
"file_name": "puc-sau-rieng-cn-2026-09-25.csv",
"file_sha256": "9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f",
"file_size": 48213,
"entry_count": 812,
"imported_at": 1790000000.5,
"imported_by": "admin@croppath.example",
"superseded_by": null,
"superseded_at": null,
"retired_by": null,
"retire_reason": null,
"current": true,
"stale": false
}
],
"max_age_days": 30,
"crops": [
"coconut",
"dragon_fruit",
"durian",
"jackfruit",
"mango"
],
"next_cursor": null
}Phản hồi 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/registry-lists
Import a published code list
Xác thực: cookie, bearer · importRegistryList
A platform admin imports the PUC (growing areas) or PHC (packing houses) code list the authority published for a destination market and crop, converted to CSV (UTF-8; columns code (required), status (active, suspended or revoked; empty: active), holder, province, district, commune, crop, area_ha, valid_from, valid_to (YYYY-MM-DD or DD/MM/YYYY); at most 737,280 bytes and 20,000 rows), sent as base64. The file is stored byte for byte with its SHA-256 as evidence, beside the file the authority published (source_sha256, required: the SHA-256 of an original uploaded first with PUT /v1/registry-sources/{sha256}), and the import supersedes the current list of the same kind, market and crop. The crop must be one of the platform's crops, and an import that would make more than 200 lists current is refused (400) rather than letting the oldest drop out of the check. A bad file is refused whole with the first bad rows named. Audited (registry_list.import, in the same transaction); the audit queues every lot whose growing area or facility carries a code for a trust recompute (the registration step). Allowed for platform_admin only.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
RegistryListImport (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"kind": "puc",
"market": "CN",
"crop": "durian",
"source_url": "https://www.ppd.gov.vn/tin-moi-nhat/danh-sach-vung-trong-va-co-so-dong-goi-sau-rieng-duoc-trung-quoc-phe-duyet.html",
"source_sha256": "4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d",
"published_on": "2026-09-25",
"file_name": "puc-sau-rieng-cn-2026-09-25.csv",
"file_base64": "Y29kZSxzdGF0dXMKVk4tRExPUi0wMTAxLGFjdGl2ZQo="
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | RegistryListapplication/json | The import, now the current list of its kind, market and crop. |
| 400 | Errorapplication/json | A bad file or detail, or a bad X-Request-Id; 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 (only platform_admin), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 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 request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": 3,
"kind": "puc",
"market": "CN",
"crop": "durian",
"source_url": "https://www.ppd.gov.vn/tin-moi-nhat/danh-sach-vung-trong-va-co-so-dong-goi-sau-rieng-duoc-trung-quoc-phe-duyet.html",
"source_sha256": "4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d",
"source_media_type": "application/pdf",
"published_on": "2026-09-25",
"file_name": "puc-sau-rieng-cn-2026-09-25.csv",
"file_sha256": "9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f",
"file_size": 48213,
"entry_count": 812,
"imported_at": 1790000000.5,
"imported_by": "admin@croppath.example",
"superseded_by": null,
"superseded_at": null,
"retired_by": null,
"retire_reason": null,
"current": true,
"stale": false,
"superseded": 2
}Phản hồi 400 · application/json · file
{
"error": "invalid file: row 12: invalid status: active, suspended, revoked",
"code": "invalid_file"
}Phản hồi 400 · application/json · base64
{
"error": "invalid file_base64: the list file, base64-encoded",
"code": "invalid_file_base64"
}Phản hồi 400 · application/json · kind
{
"error": "invalid kind: puc (growing areas) or phc (packing houses)",
"code": "invalid_kind"
}Phản hồi 400 · application/json · source
{
"error": "invalid source_sha256: no stored original file has this SHA-256; upload the file the authority published first (PUT /v1/registry-sources/{sha256})",
"code": "invalid_source_sha256"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/registry-lists/{id}
One imported code list
Xác thực: cookie, bearer · getRegistryList
One import with its entry counts by status. Platform data, read across tenants. Allowed for platform_admin only. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The import's id. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | RegistryListDetailapplication/json | The import. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin), tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such import (anything that is not an id answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | 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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"id": 3,
"kind": "puc",
"market": "CN",
"crop": "durian",
"source_url": "https://www.ppd.gov.vn/tin-moi-nhat/danh-sach-vung-trong-va-co-so-dong-goi-sau-rieng-duoc-trung-quoc-phe-duyet.html",
"source_sha256": "4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d",
"source_media_type": "application/pdf",
"published_on": "2026-09-25",
"file_name": "puc-sau-rieng-cn-2026-09-25.csv",
"file_sha256": "9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f",
"file_size": 48213,
"entry_count": 812,
"imported_at": 1790000000.5,
"imported_by": "admin@croppath.example",
"superseded_by": null,
"superseded_at": null,
"retired_by": null,
"retire_reason": null,
"current": true,
"stale": false,
"status_counts": {
"active": 805,
"suspended": 6,
"revoked": 1
},
"max_age_days": 30
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: registry_lists",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/registry-lists/{id}/retire
Retire an imported code list
Xác thực: cookie, bearer · retireRegistryList
#150 re-review (MO decision 3): a platform admin retires a current code list, for example one imported for the wrong kind, market or crop, with a reason. It stops being current at once: its codes match nothing, it leaves the current-list cap, and no successor is named (superseded_at set, superseded_by null). The list, its stored file and the authority's original file stay as evidence (no DELETE). Audited (registry_list.retire, in the same transaction, with the reason); the audit queues every lot whose growing area or facility carries a code for a trust recompute. Allowed for platform_admin only.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The import's id. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
RegistryListRetire (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"reason": "imported for the wrong crop"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | RegistryListapplication/json | The list, retired. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field or a missing, blank, multi-line or longer than 200 characters reason, or a bad X-Request-Id; 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 (only platform_admin), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such import (anything that is not an id answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The list is not current: a later import superseded it, or it was retired already. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"id": 3,
"kind": "puc",
"market": "CN",
"crop": "durian",
"source_url": "https://www.ppd.gov.vn/tin-moi-nhat/danh-sach-vung-trong-va-co-so-dong-goi-sau-rieng-duoc-trung-quoc-phe-duyet.html",
"source_sha256": "4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d",
"source_media_type": "application/pdf",
"published_on": "2026-09-25",
"file_name": "puc-sau-rieng-cn-2026-09-25.csv",
"file_sha256": "9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f9c2f",
"file_size": 48213,
"entry_count": 812,
"imported_at": 1790000000.5,
"imported_by": "admin@croppath.example",
"superseded_by": null,
"superseded_at": 1790003600.5,
"retired_by": "admin@croppath.example",
"retire_reason": "imported for the wrong crop",
"current": false,
"stale": false
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · reason
{
"error": "invalid reason: 1 to 200 characters on one line",
"code": "invalid_reason"
}Phản hồi 400 · application/json · unknown
{
"error": "unknown fields: kind",
"code": "unknown_fields"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: registry_lists",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · list_is_not_current
{
"error": "list is not current: superseded or retired already",
"code": "list_is_not_current"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/registry-lists/{id}/entries
The entries of an imported code list
Xác thực: cookie, bearer · listRegistryListEntries
One page of the import's entries by normalised code (limit, default 50, at most 200; cursor). Platform data, read across tenants. Allowed for platform_admin only. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The import's id. |
limitkhông bắt buộc | query | integer | 1 to 200 (default 50). |
cursorkhông bắt buộc | query | string | The previous page's |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | RegistryListEntryPageapplication/json | One page of entries. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin), tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such import (anything that is not an id answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"code": "VN-DLOR-0101",
"code_raw": "VN-DLOR-0101",
"status": "active",
"holder": "HTX Krông Pắc",
"province": "Đắk Lắk",
"district": "Krông Pắc",
"commune": "Ea Kly",
"area_ha": 12.5,
"valid_from": null,
"valid_to": null
}
],
"next_cursor": "eyJhZnRlciI6IlZOLURMT1ItMDEwMSJ9"
}Phản hồi 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: registry_lists",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/registry-lists/{id}/file
The stored file of an imported code list
Xác thực: cookie, bearer · getRegistryListFile
The file as imported, byte for byte: its SHA-256 is the import's file_sha256. A download (registry-list-<id>.csv), Cache-Control: no-store. Platform data, read across tenants. Allowed for platform_admin only. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The import's id. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | stringtext/csv | The CSV file. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin), tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such import (anything that is not an id answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Content-Disposition | 200 | string |
|
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 |
Ví dụ phản hồi
Phản hồi 200 · text/csv
code,status
VN-DLOR-0101,active
Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: registry_lists",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/registry-lists/{id}/source
The authority's original file of an imported code list
Xác thực: cookie, bearer · getRegistryListSource
The file the authority published, as the platform admin uploaded it before the import (#150 re-review), byte for byte: its SHA-256 is the import's source_sha256. Served with its stored media type (PDF, XLSX, XLS or CSV) as a download (registry-source-<id>.<pdf|xlsx|xls|csv>), Cache-Control: no-store, X-Content-Type-Options: nosniff and a sandboxing Content-Security-Policy. Platform data, read across tenants. Allowed for platform_admin only. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The import's id. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | stringapplication/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/csv | The original file. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin), tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such import, or its original file is missing from the store (anything that is not an id answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Content-Disposition | 200 | string |
|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/pdf
%PDF-1.7 ... (binary PDF bytes)Phản hồi 200 · application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
(binary XLSX bytes, starting 50 4B 03 04)Phản hồi 200 · application/vnd.ms-excel
(binary XLS bytes, starting D0 CF 11 E0 A1 B1 1A E1)Phản hồi 200 · text/csv
Mã số,Tên chủ sở hữu
VN-DLOR-0101,HTX Krông Pắc
Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: registry_lists",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/registry-matches
Registered codes checked against the current code lists
Xác thực: cookie, bearer · listRegistryMatches
The growing areas' PUC (kind=puc) or the facilities' PHC (kind=phc) codes of every tenant, one page by area or facility code (limit, default 50, at most 200; cursor), each with its check against the current lists of the kind (any market): matched (on the list of its crop, active and within its dates; for a facility, any crop's list), suspended, revoked, expired, mismatch (only on another crop's list), not_found, no_list (no current list of its crop) or no_code; stale when the list is older than max_age_days. Platform data, read across tenants. Allowed for platform_admin only. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
kindbắt buộc | query | "puc" | "phc" | puc or phc. |
limitkhông bắt buộc | query | integer | 1 to 200 (default 50). |
cursorkhông bắt buộc | query | string | The previous page's |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | RegistryMatchPageapplication/json | One page of registered codes. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin), 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"code": "VN-TGOR-0387",
"tenant": "coop-dl",
"name": "Vườn Ngũ Hiệp",
"crop": "durian",
"registered_code": "VN-TGOR-0387-PUC",
"normalized_code": "VN-TGOR-0387-PUC",
"result": "matched",
"stale": false,
"list_id": 3,
"list_crop": "durian"
}
],
"max_age_days": 30,
"next_cursor": null
}Phản hồi 400 · application/json · kind
{
"error": "invalid kind: puc or phc",
"code": "invalid_kind"
}Phản hồi 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/registry-sources/{sha256}
Upload the authority's original file of a code list
Xác thực: cookie, bearer · uploadRegistrySource
#150 re-review (MO decision 2): before importing a published code list, a platform admin uploads the file the authority published (its PDF, XLSX, XLS or CSV) as it was downloaded. The body must hash to sha256 (the server computes it; a mismatch is 422 and nothing is stored), be at most 1 MiB, have one of these Content-Types (parameters ignored) and that type's signature (a CSV: no NUL byte). The file is kept in the content-addressed blob store for platform admins only (GET /v1/registry-lists/{id}/source); an import then cites it as source_sha256. An original already stored: 200 without reading the body. Audited (registry_source.upload: the hash, media type and size, never the bytes). Allowed for platform_admin only.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
sha256bắt buộc | path | string | SHA-256 of the original file: exactly 64 lowercase hex characters (anything else is 400 before any lookup). |
Nội dung yêu cầu
string (bắt buộc)
Kiểu nội dung: application/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/csv
Ví dụ yêu cầu · application/pdf
%PDF-1.7 ... (binary PDF bytes)Ví dụ yêu cầu · application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
(binary XLSX bytes, starting 50 4B 03 04)Ví dụ yêu cầu · application/vnd.ms-excel
(binary XLS bytes, starting D0 CF 11 E0 A1 B1 1A E1)Ví dụ yêu cầu · text/csv
Mã số,Tên chủ sở hữu
VN-DLOR-0101,HTX Krông Pắc
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | RegistrySourceStoredapplication/json | This original is already stored; nothing changed. |
| 201 | RegistrySourceStoredapplication/json | Stored; an import may now cite it. |
| 400 | Errorapplication/json | Malformed sha256 in the path, a missing or malformed Content-Length, 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 (only platform_admin), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 415 | Errorapplication/json | Media type outside the allowlist (application/pdf, the XLSX and XLS spreadsheet types, text/csv), or bytes that do not carry that type's signature. |
| 422 | Errorapplication/json | The body does not hash to |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 201 | 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 | 413 | string | Request id: the caller's |
X-Request-Id | 415 | 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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"sha256": "4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d",
"media_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"size": 182044
}Phản hồi 201 · application/json
{
"sha256": "4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d4b1d",
"media_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"size": 182044
}Phản hồi 400 · application/json · invalid_hash
{
"error": "invalid hash",
"code": "invalid_hash"
}Phản hồi 400 · application/json · bad_content_length
{
"error": "bad content length",
"code": "bad_content_length"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf_token_missing_or_invalid
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin_not_allowed
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 415 · application/json · unsupported_media_type
{
"error": "unsupported media type",
"code": "unsupported_media_type"
}Phản hồi 415 · application/json · content_does_not_match_the_media_type
{
"error": "content does not match the media type",
"code": "content_does_not_match_the_media_type"
}Phản hồi 422 · application/json
{
"error": "hash mismatch",
"code": "hash_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/labs/{code}/approvals
Record a lab's market approval
Xác thực: cookie, bearer · createLabApproval
#154: records an active approval of the lab for a destination market (approving body, reference, analytes covered, validity, optional source URL and evidence SHA-256). Every lot the lab reported on is queued for a trust recompute in the same transaction: a result counts toward Lab-verified for the report's market only when an approval valid on the signed date lists the analyte. Audited (lab_approval.create). Allowed for platform_admin.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
LabApprovalCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"market": "CN",
"approving_body": "Plant Protection Department (MAE)",
"reference": "List of approved labs, 2026-08-07, No. 17",
"analytes": [
"auramine_o",
"cadmium"
],
"valid_from": "2026-08-07",
"valid_to": "2027-08-06",
"source_url": "https://example.org/approved-labs-2026",
"evidence_sha256": "9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | LabApprovalapplication/json | The approval recorded. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a bad value, or a bad X-Request-Id; 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). |
| 404 | Errorapplication/json | No such lab, or a lab outside the caller's scope (a lab user's other labs). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lab holds the maximum number of approvals (100). Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 | 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 | 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 |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": 7,
"lab": "LAB-VN-118",
"market": "CN",
"approving_body": "Plant Protection Department (MAE)",
"reference": "List of approved labs, 2026-08-07, No. 17",
"analytes": [
"auramine_o",
"cadmium"
],
"valid_from": "2026-08-07",
"valid_to": "2027-08-06",
"source_url": "https://example.org/approved-labs-2026",
"evidence_sha256": "9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f",
"status": "active",
"in_force": true,
"created_at": 1790000000.5,
"created_by": "admin@platform.example",
"updated_at": 1790000000.5,
"updated_by": "admin@platform.example"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field: status",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_analytes
{
"error": "invalid analytes: 1 to 32 distinct analyte codes (a lower-case letter, then lower-case letters, digits or '_'), e.g. cadmium",
"code": "invalid_analytes"
}Phản hồi 400 · application/json · invalid_valid_to
{
"error": "invalid valid_to: on or after valid_from",
"code": "invalid_valid_to"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-118",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · too_many_approvals
{
"error": "too many approvals: a lab holds at most 100",
"code": "too_many_approvals"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PATCH /v1/labs/{code}/approvals/{id}
Correct or withdraw a lab's market approval
Xác thực: cookie, bearer · updateLabApproval
#154: changes any editable field of an approval of the lab (not its market); status withdrawn withdraws it (nothing is deleted). Every lot the lab reported on is queued for a trust recompute in the same transaction. Audited (lab_approval.update, with the prior state). Allowed for platform_admin.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
idbắt buộc | path | string | Approval id. |
Nội dung yêu cầu
LabApprovalUpdate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"status": "withdrawn"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabApprovalapplication/json | The approval after the change. |
| 400 | Errorapplication/json | Invalid JSON, nothing to update, an unknown field, a bad value, 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 or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lab or approval, an approval of another lab, or a lab outside the caller's scope. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"id": 7,
"lab": "LAB-VN-118",
"market": "CN",
"approving_body": "Plant Protection Department (MAE)",
"reference": "List of approved labs, 2026-08-07, No. 17",
"analytes": [
"auramine_o",
"cadmium"
],
"valid_from": "2026-08-07",
"valid_to": "2027-08-06",
"source_url": "https://example.org/approved-labs-2026",
"evidence_sha256": "9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f",
"status": "withdrawn",
"in_force": false,
"created_at": 1790000000.5,
"created_by": "admin@platform.example",
"updated_at": 1790000000.5,
"updated_by": "admin@platform.example"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · nothing_to_update
{
"error": "nothing to update",
"code": "nothing_to_update"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field: market",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_status
{
"error": "invalid status: active or withdrawn",
"code": "invalid_status"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/labs/{code}/companies
The companies a lab serves
Xác thực: cookie, bearer · listLabCompanies
#278. The companies whose lots a sampling may draw the lab for (at most 500, by company id): a lot's lab is drawn only among the labs in force, with an active key, that serve the lot's company. A lab no company is linked to serves none. Not audited (a read). Allowed for platform_admin only: no company and no lab user reads which companies a lab serves. Not part of the partner SDK clients (x-not-in-sdk): an operation of the platform admin console's lab page.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabCompanyListapplication/json | The companies the lab serves. |
| 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 (platform_admin only: no company role and no lab user reads which companies a lab serves) or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lab. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"lab": "LAB-VN-118",
"tenant": "coop-dl",
"name": "HTX Nông nghiệp Đồng Lợi",
"linked_at": 1790000000.5
}
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: labs",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/labs/{code}/companies/{tenant}
Let a lab serve a company
Xác thực: cookie, bearer · linkLabCompany
#278. From now on the company's lots may be drawn the lab (when it is in force with an active key and, for a market whose approved-lab list is imported, approved for it). Takes no body. Linking a company the lab already serves changes nothing (200). The company record of the lab logins (croppath-labs) has no lots and is refused (409 lab_logins_company); a lab serves at most 500 companies (409 too_many_companies). Audited (lab_company.link, entity <lab>/<company>, with linked new or already). Allowed for platform_admin only. Not part of the partner SDK clients (x-not-in-sdk): an operation of the platform admin console's lab page.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
tenantbắt buộc | path | string | Company id (tenant), e.g. coop-dl. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabCompanyapplication/json | The lab already served the company; nothing changed. |
| 201 | LabCompanyapplication/json | The new link. |
| 400 | Errorapplication/json | A body (linking takes no input) 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 (platform_admin only), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such lab or company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lab logins' company record, or the lab serves the maximum number of companies (500). |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 201 | 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 | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"lab": "LAB-VN-118",
"tenant": "coop-dl",
"name": "HTX Nông nghiệp Đồng Lợi",
"linked_at": 1790000000.5
}Phản hồi 201 · application/json
{
"lab": "LAB-VN-118",
"tenant": "coop-dl",
"name": "HTX Nông nghiệp Đồng Lợi",
"linked_at": 1790000000.5
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field: linking takes no input",
"code": "unknown_field"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json · lab
{
"error": "not found: labs",
"code": "not_found"
}Phản hồi 404 · application/json · company
{
"error": "not found: tenants",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · lab_logins_company
{
"error": "lab logins company: it holds the labs' logins and has no lots to sample",
"code": "lab_logins_company"
}Phản hồi 409 · application/json · too_many_companies
{
"error": "too many companies: a lab serves at most 500",
"code": "too_many_companies"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}DELETE /v1/labs/{code}/companies/{tenant}
Stop a lab serving a company
Xác thực: cookie, bearer · unlinkLabCompany
#278. The company's later lots are never drawn the lab; the samplings already assigned to it stay as they are. A sampling of the company in progress commits first (the link is read FOR SHARE). Audited (lab_company.unlink, entity <lab>/<company>, with the prior link). Allowed for platform_admin only. Not part of the partner SDK clients (x-not-in-sdk): an operation of the platform admin console's lab page.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
tenantbắt buộc | path | string | Company id (tenant), e.g. coop-dl. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 204 | Removed. | |
| 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 (platform_admin only), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such lab, or the lab does not serve the company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 204 | 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 |
Ví dụ phản hồi
Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json · lab
{
"error": "not found: labs",
"code": "not_found"
}Phản hồi 404 · application/json · link
{
"error": "not found: lab_companies",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/export-label-templates
The export label templates
Xác thực: cookie, bearer · listExportLabelTemplates
The label template in force of every destination market (version 0: the built-in default). Allowed for platform_admin only. Not audited (a read).
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | ExportLabelTemplateListapplication/json | Every market's template. |
| 400 | Errorapplication/json | 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 (a principal without a role), 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"market": "CN",
"version": 0,
"template": {
"mark": {
"zh": "输往中华人民共和国",
"en": "Exported to the People's Republic of China"
},
"export_country": {
"zh": "越南",
"en": "Vietnam"
},
"products": {
"durian": {
"zh": "榴莲",
"en": "Durian"
}
},
"fields": {
"fruit": {
"zh": "水果名称",
"en": "Fruit",
"required": true
},
"origin": {
"zh": "产地",
"en": "Origin",
"required": true
},
"export_country": {
"zh": "出口国家",
"en": "Country of export",
"required": true
},
"orchard": {
"zh": "果园名称或注册号",
"en": "Orchard name or registration number",
"required": true
},
"packing_house": {
"zh": "包装厂名称或注册号",
"en": "Packing house name or registration number",
"required": true
},
"producer": {
"zh": "生产商",
"en": "Producer",
"required": false
},
"packing_date": {
"zh": "包装日期",
"en": "Packing date",
"required": false
},
"net_mass": {
"zh": "净重",
"en": "Net weight",
"required": false
},
"count": {
"zh": "数量",
"en": "Count",
"required": false
},
"lot": {
"zh": "批号",
"en": "Lot",
"required": false
}
},
"require_cross_checked_codes": true,
"source": "Durian export label clause as published for the Malaysia and Laos protocols with China (same clause family as the Vietnam-China protocol of 2022-07-11; to be confirmed against the Vietnamese text): https://www.doa.gov.my/doa/resources/aktiviti_sumber/sumber_awam/maklumat_biosekuriti/pamplet_prosedur_pengeksportan_durian_segar_ke_china.pdf"
},
"updated_at": null,
"updated_by": null
}
]
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/export-label-templates/{market}
Edit a market's export label template
Xác thực: cookie, bearer · putExportLabelTemplate
Appends the market's next template version, which every later label prints (text only: captions, the mark, fruit names, which fields are required and whether codes must be cross-checked). Earlier versions are kept; a print log entry names the version it printed. Audited (export_label_template.put, in the same transaction). Allowed for platform_admin only.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
marketbắt buộc | path | string | Destination market (ISO 3166-1 alpha-2). |
Nội dung yêu cầu
ExportLabelTemplate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"mark": {
"zh": "输往中华人民共和国",
"en": "Exported to the People's Republic of China"
},
"export_country": {
"zh": "越南",
"en": "Vietnam"
},
"products": {
"durian": {
"zh": "榴莲",
"en": "Durian"
}
},
"fields": {
"fruit": {
"zh": "水果名称",
"en": "Fruit",
"required": true
},
"origin": {
"zh": "产地",
"en": "Origin",
"required": true
},
"export_country": {
"zh": "出口国家",
"en": "Country of export",
"required": true
},
"orchard": {
"zh": "果园名称或注册号",
"en": "Orchard name or registration number",
"required": true
},
"packing_house": {
"zh": "包装厂名称或注册号",
"en": "Packing house name or registration number",
"required": true
},
"producer": {
"zh": "生产商",
"en": "Producer",
"required": false
},
"packing_date": {
"zh": "包装日期",
"en": "Packing date",
"required": false
},
"net_mass": {
"zh": "净重",
"en": "Net weight",
"required": false
},
"count": {
"zh": "数量",
"en": "Count",
"required": false
},
"lot": {
"zh": "批号",
"en": "Lot",
"required": false
}
},
"require_cross_checked_codes": true,
"source": "Durian export label clause as published for the Malaysia and Laos protocols with China (same clause family as the Vietnam-China protocol of 2022-07-11; to be confirmed against the Vietnamese text): https://www.doa.gov.my/doa/resources/aktiviti_sumber/sumber_awam/maklumat_biosekuriti/pamplet_prosedur_pengeksportan_durian_segar_ke_china.pdf"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | ExportLabelTemplateViewapplication/json | The new version. |
| 400 | Errorapplication/json | Invalid JSON, an unknown market, an unknown field or a bad text, 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 (only platform_admin), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"market": "CN",
"version": 1,
"template": {
"mark": {
"zh": "输往中华人民共和国",
"en": "Exported to the People's Republic of China"
},
"export_country": {
"zh": "越南",
"en": "Vietnam"
},
"products": {
"durian": {
"zh": "榴莲",
"en": "Durian"
}
},
"fields": {
"fruit": {
"zh": "水果名称",
"en": "Fruit",
"required": true
},
"origin": {
"zh": "产地",
"en": "Origin",
"required": true
},
"export_country": {
"zh": "出口国家",
"en": "Country of export",
"required": true
},
"orchard": {
"zh": "果园名称或注册号",
"en": "Orchard name or registration number",
"required": true
},
"packing_house": {
"zh": "包装厂名称或注册号",
"en": "Packing house name or registration number",
"required": true
},
"producer": {
"zh": "生产商",
"en": "Producer",
"required": false
},
"packing_date": {
"zh": "包装日期",
"en": "Packing date",
"required": false
},
"net_mass": {
"zh": "净重",
"en": "Net weight",
"required": false
},
"count": {
"zh": "数量",
"en": "Count",
"required": false
},
"lot": {
"zh": "批号",
"en": "Lot",
"required": false
}
},
"require_cross_checked_codes": true,
"source": "Durian export label clause as published for the Malaysia and Laos protocols with China (same clause family as the Vietnam-China protocol of 2022-07-11; to be confirmed against the Vietnamese text): https://www.doa.gov.my/doa/resources/aktiviti_sumber/sumber_awam/maklumat_biosekuriti/pamplet_prosedur_pengeksportan_durian_segar_ke_china.pdf"
},
"updated_at": 1790000500,
"updated_by": "platform@croppath.example"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_market
{
"error": "invalid market: one of CN",
"code": "invalid_market"
}Phản hồi 400 · application/json · invalid_template
{
"error": "invalid template: mark needs zh and en",
"code": "invalid_template"
}Phản hồi 400 · application/json · unknown_fields
{
"error": "unknown fields: script",
"code": "unknown_fields"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/device-approvals
The platform's device approval queue
Xác thực: cookie, bearer · listDeviceApprovals
#201: every company's devices and gateways with the given approval (default pending; the pending queue also lists an approved one with an active key no platform admin approved yet), ordered by id (devices and gateways share one id namespace), with keyset pagination (at most 100 per page), each with its company, facility, profile, active key fingerprints and approvals, who registered it and when. Allowed for platform_admin only (never an OAuth client).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
approvalkhông bắt buộc | query | "pending" | "approved" | "rejected" | The approval to list. |
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 100. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | DeviceApprovalPageapplication/json | One page of the queue. |
| 400 | Errorapplication/json | An unknown approval, a cursor that is not one this API issued, a limit out of range, 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 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"kind": "device",
"id": "knk-7",
"tenant": "coop-dl",
"tenant_name": "Coop DL",
"site": "ph1",
"facility": "VN-TGPH-021",
"profile": "vn.agritrace.durian-knocker",
"display_name": "Line A2 knocker",
"registered_by": "admin@coop.example",
"registered_at": 1790000000.5,
"approval": "pending",
"approval_reason": null,
"approval_at": null,
"approval_by": null,
"keys": [
{
"kid": "knk-7-k1",
"fingerprint": "3f9a…c21e",
"fingerprint_sha256": "3f9a00000000000000000000000000000000000000000000000000000000c21e",
"approval": "pending"
}
]
}
],
"next_cursor": null
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_approval
{
"error": "invalid approval: pending, approved or rejected",
"code": "invalid_approval"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices/{id}/approve
Approve a device (platform)
Xác thực: cookie, bearer · approveDevice
#201: a platform admin approves a device of any company, so evidence from it counts as Device-recorded or above. Idempotent: an approved one keeps its first approval. The body lists the waiting keys the platform admin saw in the queue: exactly those are approved with it (the audit row names them, approved_keys); a key the company registered since stays pending, so its evidence stays Self-declared and the device is listed in the queue again. 409, and nothing changes, when a listed key is no longer waiting (revoked, approved meanwhile, or not this device's). Audited (device.approve) in the device's company's activity log. Allowed for platform_admin only (never an OAuth client).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The device id. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
DeviceApproval (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"keys": [
"knk-7-k2"
]
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | DeviceApprovalItemapplication/json | The device with its approval. |
| 400 | Errorapplication/json | An unknown field, a missing or malformed keys list, a bad X-Request-Id or Idempotency-Key. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the device's company is leaving CropPath or has left, whatever company the platform admin acts for; nothing changes. |
| 404 | Errorapplication/json | No such device in any company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | A listed key is no longer waiting for approval (revoked, approved meanwhile, or not this device's): reload the queue. Or the Idempotency-Key's first request is still running ( |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"kind": "device",
"id": "knk-7",
"tenant": "coop-dl",
"tenant_name": "Coop DL",
"site": "ph1",
"facility": "VN-TGPH-021",
"profile": "vn.agritrace.durian-knocker",
"display_name": "Line A2 knocker",
"registered_by": "admin@coop.example",
"registered_at": 1790000000.5,
"approval": "approved",
"approval_reason": null,
"approval_at": 1790000200,
"approval_by": "support@croppath.example",
"keys": [
{
"kid": "knk-7-k1",
"fingerprint": "3f9a…c21e",
"fingerprint_sha256": "3f9a00000000000000000000000000000000000000000000000000000000c21e",
"approval": "approved"
}
]
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_keys
{
"error": "invalid keys: a list of up to 100 distinct key ids",
"code": "invalid_keys"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: knk-7",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · key_not_waiting_for_approval
{
"error": "key not waiting for approval",
"code": "key_not_waiting_for_approval"
}Phản hồi 409 · application/json · placement_required SENS-A2 (#225): the device has no placement in force; record one (POST /v1/devices/{id}/placements) first
{
"error": "placement required: record where the device is installed before approving it",
"code": "placement_required"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices/{id}/reject
Reject a device (platform)
Xác thực: cookie, bearer · rejectDevice
#201: a platform admin rejects a device of any company, pending or approved (withdrawing its approval), with a reason shown to the company. Evidence from it then counts as Self-declared: open lots are lowered at their recompute, a sealed lot's tier can only be lowered. 409 when it is already rejected. Audited (device.reject) in the device's company's activity log. Allowed for platform_admin only (never an OAuth client).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The device id. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
DeviceRejection (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"reason": "Serial number does not match the scale's calibration certificate."
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | DeviceApprovalItemapplication/json | The device with its approval. |
| 400 | Errorapplication/json | An unknown field ( |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the device's company is leaving CropPath or has left, whatever company the platform admin acts for; nothing changes. |
| 404 | Errorapplication/json | No such device in any company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The device is already rejected. Or the Idempotency-Key's first request is still running ( |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"kind": "device",
"id": "knk-7",
"tenant": "coop-dl",
"tenant_name": "Coop DL",
"site": "ph1",
"facility": "VN-TGPH-021",
"profile": "vn.agritrace.durian-knocker",
"display_name": "Line A2 knocker",
"registered_by": "admin@coop.example",
"registered_at": 1790000000.5,
"approval": "rejected",
"approval_reason": "Serial number does not match.",
"approval_at": 1790000200,
"approval_by": "support@croppath.example",
"keys": [
{
"kid": "knk-7-k1",
"fingerprint": "3f9a…c21e",
"fingerprint_sha256": "3f9a00000000000000000000000000000000000000000000000000000000c21e",
"approval": "approved"
}
]
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_reason
{
"error": "invalid reason: a string of 1 to 500 characters",
"code": "invalid_reason"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: knk-7",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · device_already_rejected
{
"error": "device already rejected",
"code": "device_already_rejected"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices/{id}/placements
Record a device placement (platform)
Xác thực: cookie, bearer · recordDevicePlacement
SENS-A2 (#225): a platform admin, acting for the device's company (X-Tenant), records a new placement version: when approving the device (#201; a device is approved only while its current version is an installation, else the approval answers 409 placement_required), whenever it is moved, and when it is taken out. The prior version is kept; nothing is ever overwritten. A fixed placement binds the device to one growing area of the company and records the surveyed install point and the commissioning record (the installer's photo, uploaded first with PUT /v1/attachments/{sha256}, the GPS fix time, the install time and the installer). A body with removed_at (a DevicePlacementRemoval) records that the device was taken out: the new version ends the binding of the installation before it and keeps its mobility, key_protection and gnss. Audited (device.placement) in the company's activity log. Allowed for platform_admin only (never an OAuth client). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Device id. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
DevicePlacementCreate | DevicePlacementRemoval (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json · installation A fixed device installed (or moved)
{
"mobility": "fixed",
"key_protection": "hardware",
"growing_area": "VN-TG-CL-0042",
"lat": 10.3512345,
"lon": 106.1234567,
"accuracy_m": 3.5,
"fix_at": 1790100000,
"installed_at": 1790100600,
"installer": "Nguyen Van A",
"photo_sha256": "9b2f00000000000000000000000000000000000000000000000000000000a17c",
"depth_cm": 30,
"sensor_serial": "RS485-4IN1-00172",
"note": "Moved to block B after replanting"
}Ví dụ yêu cầu · application/json · removal The device taken out
{
"removed_at": 1790200000,
"note": "Taken out for repair"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | DevicePlacementapplication/json | The new placement version. |
| 400 | Errorapplication/json | An unknown or malformed field (a time before 2020 or more than 300 s ahead included; a GPS fix more than 7 days before the install or after it), a removal with any field but |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), or company read-only (the company is leaving CropPath or has left; nothing changes). |
| 404 | Errorapplication/json | No such device for this company: a device of another company, or outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The new version would start ( |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 | 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 | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"device_id": "soil-07",
"version": 2,
"mobility": "fixed",
"key_protection": "hardware",
"gnss": false,
"growing_area": "VN-TG-CL-0042",
"lat": 10.3512345,
"lon": 106.1234567,
"accuracy_m": 3.5,
"fix_at": 1790100000,
"installed_at": 1790100600,
"installer": "Nguyen Van A",
"photo_sha256": "9b2f00000000000000000000000000000000000000000000000000000000a17c",
"depth_cm": 30,
"sensor_serial": "RS485-4IN1-00172",
"note": "Moved to block B after replanting",
"removed_at": null,
"recorded_at": 1790101000,
"valid_until": null,
"recorded_by": "support@croppath.example"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · fixed_incomplete
{
"error": "fixed placement incomplete: needs growing_area, photo_sha256",
"code": "fixed_placement_incomplete"
}Phản hồi 400 · application/json · unknown_growing_area
{
"error": "unknown growing_area",
"code": "unknown_growing_area"
}Phản hồi 400 · application/json · unknown_photo
{
"error": "unknown photo_sha256: upload the photo (JPEG or PNG) first",
"code": "unknown_photo_sha256"
}Phản hồi 400 · application/json · install_point
{
"error": "invalid install point: lat, lon and accuracy_m together",
"code": "invalid_install_point"
}Phản hồi 400 · application/json · fix_time
{
"error": "invalid fix_at: at most 7 days before installed_at and never after it",
"code": "invalid_fix_at"
}Phản hồi 400 · application/json · removal_fields
{
"error": "invalid removal: removed_at and note only",
"code": "invalid_removal"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · out_of_order
{
"error": "placement out of order: it starts before the current placement",
"code": "placement_out_of_order"
}Phản hồi 409 · application/json · nothing_to_remove
{
"error": "no placement to remove: the device has no installation in force",
"code": "no_placement_to_remove"
}Phản hồi 409 · application/json · idempotency_in_progress
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/gateways/{id}/approve
Approve a gateway (platform)
Xác thực: cookie, bearer · approveGateway
#201: a platform admin approves a gateway of any company, so evidence from it counts as Device-recorded or above. Idempotent: an approved one keeps its first approval. The body lists the waiting keys the platform admin saw in the queue: exactly those are approved with it (the audit row names them, approved_keys); a key the company registered since stays pending, so its evidence stays Self-declared and the gateway is listed in the queue again. 409, and nothing changes, when a listed key is no longer waiting (revoked, approved meanwhile, or not this gateway's). Audited (gateway.approve) in the gateway's company's activity log. Allowed for platform_admin only (never an OAuth client).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The gateway id. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
DeviceApproval (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"keys": [
"gw-7-k1"
]
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | DeviceApprovalItemapplication/json | The gateway with its approval. |
| 400 | Errorapplication/json | An unknown field, a missing or malformed keys list, a bad X-Request-Id or Idempotency-Key. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the gateway's company is leaving CropPath or has left, whatever company the platform admin acts for; nothing changes. |
| 404 | Errorapplication/json | No such gateway in any company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | A listed key is no longer waiting for approval (revoked, approved meanwhile, or not this gateway's): reload the queue. Or the Idempotency-Key's first request is still running ( |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"kind": "gateway",
"id": "gw-7",
"tenant": "coop-dl",
"tenant_name": "Coop DL",
"site": "ph1",
"facility": "VN-TGPH-021",
"profile": null,
"display_name": "Packing hall gateway",
"registered_by": "admin@coop.example",
"registered_at": 1790000000.5,
"approval": "approved",
"approval_reason": null,
"approval_at": 1790000200,
"approval_by": "support@croppath.example",
"keys": []
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_keys
{
"error": "invalid keys: a list of up to 100 distinct key ids",
"code": "invalid_keys"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: knk-7",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · key_not_waiting_for_approval
{
"error": "key not waiting for approval",
"code": "key_not_waiting_for_approval"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/gateways/{id}/reject
Reject a gateway (platform)
Xác thực: cookie, bearer · rejectGateway
#201: a platform admin rejects a gateway of any company, pending or approved (withdrawing its approval), with a reason shown to the company. Evidence from it then counts as Self-declared: open lots are lowered at their recompute, a sealed lot's tier can only be lowered. 409 when it is already rejected. Audited (gateway.reject) in the gateway's company's activity log. Allowed for platform_admin only (never an OAuth client).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The gateway id. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
DeviceRejection (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"reason": "The gateway is not installed at the registered packing house."
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | DeviceApprovalItemapplication/json | The gateway with its approval. |
| 400 | Errorapplication/json | An unknown field ( |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the gateway's company is leaving CropPath or has left, whatever company the platform admin acts for; nothing changes. |
| 404 | Errorapplication/json | No such gateway in any company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The gateway is already rejected. Or the Idempotency-Key's first request is still running ( |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 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 | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"kind": "gateway",
"id": "gw-7",
"tenant": "coop-dl",
"tenant_name": "Coop DL",
"site": "ph1",
"facility": "VN-TGPH-021",
"profile": null,
"display_name": "Packing hall gateway",
"registered_by": "admin@coop.example",
"registered_at": 1790000000.5,
"approval": "rejected",
"approval_reason": "Serial number does not match.",
"approval_at": 1790000200,
"approval_by": "support@croppath.example",
"keys": []
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_reason
{
"error": "invalid reason: a string of 1 to 500 characters",
"code": "invalid_reason"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: knk-7",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · gateway_already_rejected
{
"error": "gateway already rejected",
"code": "gateway_already_rejected"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/platform/support-requests
List every company's support requests (the platform's queue)
Xác thực: cookie · listPlatformSupportRequests
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-2-7 (#196). Every company's support requests, newest first; status and tenant narrow the queue. Allowed for only platform_admin, through a signed-in session: an API token or the legacy token is refused (403).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
statuskhông bắt buộc | query | "open" | "in_progress" | "answered" | "closed" | Only requests in this status. |
tenantkhông bắt buộc | query | string | Only this company's requests. |
limitkhông bắt buộc | query | integer | 1 to 200 (default 50). |
cursorkhông bắt buộc | query | string | The previous page's |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | PlatformSupportRequestPageapplication/json | One page of the queue. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin, through a signed-in session: an API token or the legacy token is refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"id": 12,
"tenant": "coop-dl",
"user": {
"id": 7,
"email": "op@coop.example",
"display_name": "Lan"
},
"subject": "Scale at line A1 shows no weight",
"body": "Since this morning the scale at line A1 shows 0 kg for every fruit.",
"record_id": "LOT-2026-001",
"status": "answered",
"reply": "Please restart the scale; it reconnects in a minute.",
"created_at": 1790000000.5,
"updated_at": 1790003600.5,
"updated_by": "support@croppath.example"
}
],
"next_cursor": null
}Phản hồi 400 · application/json · status
{
"error": "invalid status: one of open, in_progress, answered, closed",
"code": "invalid_status"
}Phản hồi 400 · application/json · tenant
{
"error": "invalid tenant",
"code": "invalid_tenant"
}Phản hồi 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PATCH /v1/platform/support-requests/{id}
Change a support request's status or reply
Xác thực: cookie · updatePlatformSupportRequest
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-2-7 (#196). CropPath sets a request's status and/or its reply (plain text; null or blank clears it); the company then sees both in its Help panel. Audited (support_request.update, in the same transaction, in the request's company's activity log; never the reply's text). Allowed for only platform_admin, through a signed-in session: an API token or the legacy token is refused (403).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The request id. |
Nội dung yêu cầu
SupportRequestUpdate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"status": "answered",
"reply": "Please restart the scale; it reconnects in a minute."
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | PlatformSupportRequestapplication/json | The request, as the queue shows it. |
| 400 | Errorapplication/json | Invalid JSON, nothing to change, an unknown field or a bad value, 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 (only platform_admin, through a signed-in session: an API token or the legacy token is refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only once the request's company has left CropPath, whatever company the platform admin acts for; nothing changes. During that company's 30-day read-only window CropPath can still reply (owner decision A). |
| 404 | Errorapplication/json | No support request with this id. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"id": 12,
"tenant": "coop-dl",
"user": {
"id": 7,
"email": "op@coop.example",
"display_name": "Lan"
},
"subject": "Scale at line A1 shows no weight",
"body": "Since this morning the scale at line A1 shows 0 kg for every fruit.",
"record_id": "LOT-2026-001",
"status": "answered",
"reply": "Please restart the scale; it reconnects in a minute.",
"created_at": 1790000000.5,
"updated_at": 1790003600.5,
"updated_by": "support@croppath.example"
}Phản hồi 400 · application/json · nothing
{
"error": "nothing to change: send a status, a reply or both",
"code": "nothing_to_change"
}Phản hồi 400 · application/json · status
{
"error": "invalid status: one of open, in_progress, answered, closed",
"code": "invalid_status"
}Phản hồi 400 · application/json · reply
{
"error": "invalid reply: text of at most 5000 characters",
"code": "invalid_reply"
}Phản hồi 400 · application/json · unknown
{
"error": "unknown field: note",
"code": "unknown_field"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: 12",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/platform/announcements
List the platform announcements
Xác thực: cookie · listAnnouncements
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-2-7 (#196). Every announcement, newest first, each live, scheduled or ended. Allowed for only platform_admin, through a signed-in session: an API token or the legacy token is refused (403).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
limitkhông bắt buộc | query | integer | 1 to 200 (default 50). |
cursorkhông bắt buộc | query | string | The previous page's |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | AnnouncementPageapplication/json | One page of announcements. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin, through a signed-in session: an API token or the legacy token is refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"id": 3,
"text": "Planned maintenance on Sunday 22:00 to 23:00 (Vietnam time): the console may be slow.",
"level": "warning",
"starts_at": 1790000000.5,
"ends_at": 1790086400.5,
"state": "live",
"created_at": 1790000000.5,
"created_by": "support@croppath.example",
"expired_at": null,
"expired_by": null
}
],
"next_cursor": null
}Phản hồi 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/platform/announcements
Post a platform announcement for the staff shell
Xác thực: cookie · createAnnouncement
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-2-7 (#196). A short plain-text notice every signed-in user sees as a banner in the staff shell (never on a public page), from starts_at until ends_at or until expired. At most 20 live or scheduled at once (409). Audited (announcement.create, in the same transaction; in no company's activity log). Allowed for only platform_admin, through a signed-in session: an API token or the legacy token is refused (403).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
AnnouncementCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"text": "Planned maintenance on Sunday 22:00 to 23:00 (Vietnam time): the console may be slow.",
"level": "warning",
"ends_at": 1790086400.5
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | Announcementapplication/json | The announcement. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field or a value outside the limits, or a bad X-Request-Id; 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 (only platform_admin, through a signed-in session: an API token or the legacy token is refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | 20 announcements are already live or scheduled; or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | 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 | 409 | string | Request id: the caller's |
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 |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"id": 3,
"text": "Planned maintenance on Sunday 22:00 to 23:00 (Vietnam time): the console may be slow.",
"level": "warning",
"starts_at": 1790000000.5,
"ends_at": 1790086400.5,
"state": "live",
"created_at": 1790000000.5,
"created_by": "support@croppath.example",
"expired_at": null,
"expired_by": null
}Phản hồi 400 · application/json · text
{
"error": "invalid text: required, text of at most 500 characters",
"code": "invalid_text"
}Phản hồi 400 · application/json · level
{
"error": "invalid level: one of info, warning",
"code": "invalid_level"
}Phản hồi 400 · application/json · ends_at
{
"error": "invalid ends_at: later than the start, and at most a year after it",
"code": "invalid_ends_at"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · too_many
{
"error": "too many announcements: at most 20 live or scheduled; expire one first",
"code": "too_many_announcements"
}Phản hồi 409 · application/json · idempotency
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/platform/announcements/{id}/expire
End a platform announcement now
Xác thực: cookie · expireAnnouncement
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-2-7 (#196). Stops showing the announcement at once; final. Audited (announcement.expire, in the same transaction). Allowed for only platform_admin, through a signed-in session: an API token or the legacy token is refused (403).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The announcement id. |
Idempotency-Keykhông bắt buộc | 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 |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | Announcementapplication/json | The announcement, ended. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only platform_admin, through a signed-in session: an API token or the legacy token is refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No announcement with this id. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The announcement already ended; or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 409 | string | Request id: the caller's |
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"id": 3,
"text": "Planned maintenance on Sunday 22:00 to 23:00 (Vietnam time): the console may be slow.",
"level": "warning",
"starts_at": 1790000000.5,
"ends_at": 1790086400.5,
"state": "ended",
"created_at": 1790000000.5,
"created_by": "support@croppath.example",
"expired_at": 1790000600.5,
"expired_by": "support@croppath.example"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}Phản hồi 404 · application/json
{
"error": "not found: 3",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · ended
{
"error": "announcement already ended",
"code": "announcement_already_ended"
}Phản hồi 409 · application/json · idempotency
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/platform/overview
Read the platform overview
Xác thực: cookie · getPlatformOverview
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
#274. What a platform admin monitors across every company on the admin home: the service's health (as getAdminHealth), this server's traffic and ingest since it started with their per-minute figures, the queues, the work waiting on CropPath, sign-in security and the companies (at most 50, those that need attention first; names, codes and counts only, no person's data). Computed at most every 30 seconds: the server serves one answer for max_age_s seconds after generated_at. Read-only and not audited (a read). no-store. Allowed for only platform_admin, through a signed-in session: an API token (a platform_admin one included) or the legacy token is refused (403). Not part of the partner SDK clients (x-not-in-sdk): an operation of the console's admin home.
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | PlatformOverviewapplication/json | The platform overview. |
| 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 (only platform_admin, through a signed-in session: an API token or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"generated_at": "2026-10-17T07:32:05Z",
"max_age_s": 30,
"process": {
"started_at": "2026-10-17T01:02:03Z",
"role": "all",
"mqtt_ingest": "bridge"
},
"sections": {
"health": {
"state": "ok",
"read_only": false,
"warnings": [],
"db": {
"dialect": "postgresql",
"schema_version": 108,
"expected_schema_version": 108,
"round_trip_ms": 0.8
},
"mqtt": {
"connected": true,
"subscribed": true
},
"certificates": [
{
"name": "broker",
"not_after": "2027-01-02T00:00:00Z",
"days_left": 77
}
],
"tsa": {
"mode": "on",
"pending": 0,
"failing": 0
},
"issuer_keys": {
"available": true
},
"anchor_last_day": "2026-10-16",
"evidence_archive": {
"last_day": "2026-10-15",
"status": "archived"
},
"platform_alerts_open": 0,
"platform_alerts_open_high": 0
},
"traffic": {
"state": "ok",
"since": "2026-10-17T01:02:03Z",
"answers": 18234,
"server_errors": 2,
"refused_429": 14,
"series_since": "2026-10-17T07:28:05Z",
"server_errors_per_minute": [
0,
0,
1,
0
]
},
"ingest": {
"state": "ok",
"since": "2026-10-17T01:02:03Z",
"outcomes": {
"accepted": 90122,
"quarantined": 12,
"duplicate": 40,
"rejected": 3
},
"series_since": "2026-10-17T07:28:05Z",
"messages_per_minute": [
1502,
1498,
1510
],
"backlog": {
"messages": 0,
"capped": false,
"companies": 0,
"over_budget": 0
}
},
"queues": {
"state": "ok",
"outbound": {
"epcis": 0
},
"webhooks_pending": 0,
"email": {
"queued": 0,
"oldest_queued_at": null,
"failed_24h": 0
},
"recall_notices_pending": 0,
"exports": {
"active": 0,
"failed_7d": 0
}
},
"waiting": {
"state": "ok",
"device_approvals": 1,
"gateway_approvals": 0,
"key_approvals": 0,
"facility_proposals": 2,
"boundary_proposals": 0,
"support_open": 1,
"support_in_progress": 0,
"lab_accreditations_expiring": 0,
"lab_approvals_expiring": 1,
"companies_leaving": 0
},
"security": {
"state": "ok",
"failed_sign_ins_24h": 5,
"capped": false,
"accounts_locked": 0
},
"companies": {
"state": "ok",
"total": 1,
"items": [
{
"id": "coop-dl",
"name": "HTX Dak Lak",
"sandbox": false,
"offboarding": null,
"members_active": 9,
"admins_active": 2,
"devices_registered": 42,
"messages_last_hour": 9000,
"api_calls_today": 1200,
"api_day_percent": 0,
"open_high_alerts": 2,
"support_open": 1
}
]
},
"irrigation": {
"state": "ok",
"controllers": 14,
"online": 12,
"not_measured": 1,
"controllers_capped": false,
"online_rate_7d": [
0.98,
0.97,
0.99,
0.99,
0.96,
0.98,
0.99
],
"rejects_14d": {
"interlock": 1,
"manual_override_active": 4
},
"expired_rate_14d": 0.02,
"commands_capped": false,
"companies": [
{
"id": "coop-dl",
"open_urgent": 0,
"alarms_raised_7d": 18
}
],
"capped": false,
"attention": []
}
}
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/tenants/{id}/offboarding
Mark a company as leaving CropPath
Xác thực: cookie · startCompanyOffboarding
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-2-4 (#193). Starts the company's departure: a 30-day read-only window in which its people still sign in, read and download the full data export (POST /v1/company/exports), while every other write of the company is refused (403 company_read_only) and its devices' messages are refused (company_read_only). After the window the background job stops sign-in for the company (members who belong to no other company are disabled; others lose this membership), revokes its API tokens, API clients and webhooks and removes its people's names and emails everywhere except the append-only activity log; one audit row per step, by system:offboarding. Sealed lot records, evidence and public lot pages stay for retention_years from each lot's seal; trust tiers never change. retention_years is required (owner decision D-S4: no default). Audited (company.offboarding.start, in the same transaction, in the company's own log). Allowed for platform_admin through a signed-in session only; the session must have confirmed its password within the last 10 minutes (SELF-1-2), else 401 reauthentication_required before anything is done.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The company (tenant id). |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
CompanyOffboardingStart (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"retention_years": 5
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CompanyOffboardingapplication/json | The company is leaving: its state. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a missing or out-of-range |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (platform_admin only, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The company is already leaving or has left, or it is the company of CropPath's platform admins or the company record of CropPath's lab logins ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"status": "leaving",
"retention_years": 5,
"started_at": 1790000000.5,
"window_ends_at": 1792592000.5,
"left_at": null,
"retention_ends_at": 1949858000.5,
"steps_done": 0
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · unknown
{
"error": "unknown fields: window_days",
"code": "unknown_fields"
}Phản hồi 400 · application/json · retention
{
"error": "invalid retention_years: a whole number of years from 1 to 30",
"code": "invalid_retention_years"
}Phản hồi 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: coop-new",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · leaving
{
"error": "already leaving: the company is already leaving CropPath",
"code": "already_leaving"
}Phản hồi 409 · application/json · left
{
"error": "already left: the company has left CropPath",
"code": "already_left"
}Phản hồi 409 · application/json · platform
{
"error": "platform company: the company of CropPath's platform admins cannot leave",
"code": "platform_company"
}Phản hồi 409 · application/json · lab_logins
{
"error": "lab logins company: the company record of CropPath's lab logins cannot leave",
"code": "lab_logins_company"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/tenants/{id}/offboarding/cancel
Cancel a company's departure during its window
Xác thực: cookie · cancelCompanyOffboarding
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
SELF-2-4 (#193). Cancels the departure of a company that is leaving, during its read-only window (or until the job has stopped its sign-in): the company works normally again. No body. Audited (company.offboarding.cancel, in the company's own log). Allowed for platform_admin through a signed-in session only, with a password confirmed within the last 10 minutes (SELF-1-2).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | The company (tenant id). |
Idempotency-Keykhông bắt buộc | 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 |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | CompanyOffboardingapplication/json | The departure is cancelled: the company's state, |
| 400 | Errorapplication/json | Invalid JSON, any field in the body, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (platform_admin only, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The company is not leaving, or it has left (sign-in stopped; cancelling cannot restore it). |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"status": "active",
"retention_years": null,
"started_at": null,
"window_ends_at": null,
"left_at": null,
"retention_ends_at": null,
"steps_done": 0
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · unknown
{
"error": "unknown fields: retention_years",
"code": "unknown_fields"
}Phản hồi 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: coop-new",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · not_leaving
{
"error": "not leaving: the company is not leaving CropPath",
"code": "not_leaving"
}Phản hồi 409 · application/json · left
{
"error": "already left: sign-in has stopped and the departure cannot be cancelled",
"code": "already_left"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}