CropPath 开发者

API 参考

registry

49 个操作

GET /v1/facilities

Facilities of the caller's tenant

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_read · listFacilities

Facilities (packing houses) of the caller's tenant ordered by code, with keyset pagination. Allowed for platform_admin, tenant_admin and auditor (the whole tenant) and for an operator signed in with a session (only the facilities of its memberships).

参数

名称位置类型说明
cursor
可选
querystring

next_cursor of the previous page of facilities.

limit
可选
queryinteger

Page size, 1 to 200.

admin_units
可选
query"0" | "1"

#273: 1 adds the address by official code (province_code, commune_code, admin_units_version, address_status, address_before_reform, address_candidates, commune); 0 or none leaves them out and answers exactly as before; any other value is refused (400 bad admin_units).

响应

状态码类型说明
200FacilityPage
application/json

One page of facilities.

400Error
application/json

A cursor that is not one this API issued, a limit outside 1 to 200, admin_units not 0 or 1, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "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": null,
      "slug": "vn-tgph-021",
      "created_at": 1790000000.5,
      "updated_at": 1790000000.5,
      "proposed_at": null
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · bad_admin_units
{
  "error": "bad admin_units",
  "code": "bad_admin_units"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/facilities/{code}

One facility

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_read · getFacility

Same roles as the list; an operator reads only its own facilities.

参数

名称位置类型说明
code
必填
pathstring

Facility code.

admin_units
可选
query"0" | "1"

#273: 1 adds the address by official code (province_code, commune_code, admin_units_version, address_status, address_before_reform, address_candidates, commune); 0 or none leaves them out and answers exactly as before; any other value is refused (400 bad admin_units).

响应

状态码类型说明
200Facility
application/json

The facility.

400Error
application/json

admin_units is not 0 or 1, or the X-Request-Id header is malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such facility for this tenant: a facility of another tenant, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 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": null,
  "slug": "vn-tgph-021",
  "created_at": 1790000000.5,
  "updated_at": 1790000000.5,
  "proposed_at": null
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · bad_admin_units
{
  "error": "bad admin_units",
  "code": "bad_admin_units"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGPH-021",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PATCH /v1/facilities/{code}

Edit a facility

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_edit · updateFacility

A tenant_admin may change name, address, province, district and lines; a platform_admin also gacc_phc_code and slug. The code is immutable; tenant, source and approved_at change only through platform paths. Edits keep the approval. Audited (facility.update). #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.

参数

名称位置类型说明
code
必填
pathstring

Facility code.

请求体

FacilityUpdate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "name": "Tan Phu packing house 2",
  "lines": [
    "L1",
    "L2",
    "L3"
  ]
}

响应

状态码类型说明
200Facility
application/json

The facility after the change.

400Error
application/json

Invalid JSON, the code in the body, a field the caller may not change, an empty body, a value out of bounds, or a bad X-Request-Id. #273: also a code that is not in the administrative units list in force (admin_unit_unknown), a commune that the list places in another province (commune_not_in_province), a district (district_with_codes) or a province name sent with the codes (invalid_province), or a malformed code or one code without the other (invalid_province_code, invalid_commune_code).

401Error
application/json

No valid session, API token or legacy token.

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

404Error
application/json

No such facility for this tenant: a facility of another tenant, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The slug is taken by another facility, or the facility has an issuer key (#34: its slug is its did:web path and never changes from then on).

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

#273: province_code and commune_code were sent but the server has no administrative units list in force to check them (administrative_units_catalog_unavailable); nothing was written. A text-only address is not refused this way.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Deprecation200string

#273: sent only when the request gave the address in Viet Nam as text only (province or district, without province_code and commune_code), on every answer, errors included. Not sent when a successful update sends the record's own stored text back unchanged (compared after Unicode NFC normalisation and trimming): that changes no address, the record keeps its codes, status and candidates. @1792195200 (RFC 9745): the text-only address was deprecated at the start of 17 October 2026, UTC.

Sunset200string

#273: sent only when the request gave the address in Viet Nam as text only (province or district, without province_code and commune_code), on every answer, errors included. Not sent when a successful update sends the record's own stored text back unchanged (compared after Unicode NFC normalisation and trimming): that changes no address, the record keeps its codes, status and candidates. Sat, 01 May 2027 00:00:00 GMT (RFC 8594): from then a text-only address in Viet Nam may be refused.

Link200string

#273: sent only when the request gave the address in Viet Nam as text only (province or district, without province_code and commune_code), on every answer, errors included. Not sent when a successful update sends the record's own stored text back unchanged (compared after Unicode NFC normalisation and trimming): that changes no address, the record keeps its codes, status and candidates. <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="deprecation", <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="sunset": the changelog entry that says what to send instead.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · 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
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · immutable
{
  "error": "code is immutable",
  "code": "code_is_immutable"
}
响应 400 · application/json · not_editable
{
  "error": "field not editable",
  "code": "field_not_editable"
}
响应 400 · application/json · empty
{
  "error": "nothing to update",
  "code": "nothing_to_update"
}
响应 400 · application/json · invalid_lines
{
  "error": "invalid lines: at most 32 distinct names of 1 to 32 characters",
  "code": "invalid_lines"
}
响应 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"
}
响应 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"
}
响应 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"
}
响应 400 · application/json · invalid_province
{
  "error": "invalid province: absent or null with the codes, the server writes the official name",
  "code": "invalid_province"
}
响应 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"
}
响应 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"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGPH-021",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · slug_taken
{
  "error": "slug already in use",
  "code": "slug_already_in_use"
}
响应 409 · application/json · slug_fixed
{
  "error": "slug fixed: the facility has issuer keys",
  "code": "slug_fixed"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
响应 503 · application/json
{
  "error": "administrative units catalog unavailable",
  "code": "administrative_units_catalog_unavailable"
}

GET /v1/facilities/{code}/gln

A facility's GLN

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_read · getFacilityGln

#161: the facility's GS1 Global Location Number, null when it has none. Same roles as reading the facility; an operator reads only its own facilities. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Facility code.

响应

状态码类型说明
200FacilityGln
application/json

The facility's GLN.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such facility for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "facility": "VN-TGPH-021",
  "gln": "6141410000014"
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGPH-021",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/facilities/{code}/gln

Set, clear or allocate a facility's GLN

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_edit · setFacilityGln

#161: the GLN names the facility as read point and business location in the lot's EPCIS documents (staff, and the public one issued at a later seal). Unique within the company. allocate takes the next GLN of the platform's GS1 company prefix (the deployment's AGRITRACE_GS1_COMPANY_PREFIX; 409 while none is configured). Same roles as editing the facility (tenant_admin, platform_admin acting for the company). Audited (facility.gln.set) in the company's activity log. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Facility code.

请求体

GlnChange (必填)

媒体类型: application/json

请求示例 · application/json
{
  "gln": "6141410000014"
}

响应

状态码类型说明
200FacilityGln
application/json

The GLN as stored.

400Error
application/json

A body that is not {"gln": <13 digits> | null} or {"allocate": true}, a GLN whose check digit is wrong or that carries the platform's prefix (allocated only), invalid JSON or a bad X-Request-Id.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such record for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

Another record of the company has that GLN; or no GS1 company prefix is configured (allocation), or every reference of it is allocated.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "facility": "VN-TGPH-021",
  "gln": "6141410000014"
}
响应 400 · application/json · invalid_body
{
  "error": "invalid body: {\"gln\": \"<13 digits>\" | null} or {\"allocate\": true}",
  "code": "invalid_body"
}
响应 400 · application/json · invalid_gln
{
  "error": "invalid gln: 13 digits with a valid GS1 check digit",
  "code": "invalid_gln"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGPH-021",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · gln_in_use
{
  "error": "gln already in use by another facility of the company",
  "code": "gln_already_in_use_by_another_facility_of_the_company"
}
响应 409 · application/json · prefix
{
  "error": "prefix not configured: the platform has no GS1 company prefix yet; enter a number of the company's own GS1 membership",
  "code": "prefix_not_configured"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/facilities/{code}/certifications

A facility's packing-house certifications

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_read · listFacilityCertifications

#269: every packing-house certification of the facility (ISO 22000, FSSC 22000, BRCGS, IFS; at most 100, one page), newest valid_from first, each with its status on today's date in Viet Nam. Shown to the company's staff only: no trust tier and no public page uses them (architect decision on #269; ADR 0001). Same roles as reading the facility; an operator reads only its own facilities. Not audited (a read). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Facility code.

响应

状态码类型说明
200FacilityCertificationList
application/json

The facility's certifications.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such facility for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "id": 12,
      "facility": "VN-TGPH-021",
      "scheme": "BRCGS",
      "number": "BRC-12345",
      "issuer": "Bureau Veritas Certification",
      "valid_from": "2026-03-01",
      "valid_to": "2027-02-28",
      "evidence_sha256": "9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f",
      "created_at": 1790000000.5,
      "ended_on": null,
      "end_reason": null,
      "ended_at": null,
      "status": "valid"
    }
  ]
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGPH-021",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/facilities/{code}/certifications

Record a facility's packing-house certification

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_edit · createFacilityCertification

#269: records a certification of a packing-house scheme on the facility: its number, its certifier, its validity and the SHA-256 of the certificate document, which the company uploads first with PUT /v1/attachments/{sha256} (never public; the facility's readers read it through GET /v1/attachments/{sha256}). A facility proposal takes none until CropPath approves it (409 facility not approved, as for its GLN, lots and devices). The same scheme and number are recorded once per facility. Nothing is edited or deleted: end a certification instead. Shown to the company's staff only: no trust tier and no public page uses them (architect decision on #269; ADR 0001). Same roles as editing the facility (tenant_admin, platform_admin acting for the company). Audited (facility.certification.create) in the company's activity log. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Facility code.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

FacilityCertificationCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "scheme": "BRCGS",
  "number": "BRC-12345",
  "issuer": "Bureau Veritas Certification",
  "valid_from": "2026-03-01",
  "valid_to": "2027-02-28",
  "evidence_sha256": "9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f"
}

响应

状态码类型说明
201FacilityCertification
application/json

The certification as stored.

400Error
application/json

Invalid JSON, an unknown field, a scheme outside the list, a bad value, a certificate the company has not uploaded, or a bad X-Request-Id. Or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

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

404Error
application/json

No such facility for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The facility is a proposal CropPath has not approved yet, has a certification of that scheme and number, or holds 100 certifications. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "id": 12,
  "facility": "VN-TGPH-021",
  "scheme": "BRCGS",
  "number": "BRC-12345",
  "issuer": "Bureau Veritas Certification",
  "valid_from": "2026-03-01",
  "valid_to": "2027-02-28",
  "evidence_sha256": "9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f",
  "created_at": 1790000000.5,
  "ended_on": null,
  "end_reason": null,
  "ended_at": null,
  "status": "valid"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field: status",
  "code": "unknown_field"
}
响应 400 · application/json · invalid_scheme
{
  "error": "invalid scheme: one of ISO 22000, FSSC 22000, BRCGS, IFS",
  "code": "invalid_scheme"
}
响应 400 · application/json · invalid_evidence_sha256
{
  "error": "invalid evidence_sha256: upload the certificate first (PUT /v1/attachments/{sha256})",
  "code": "invalid_evidence_sha256"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGPH-021",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · not_approved
{
  "error": "facility not approved",
  "code": "facility_not_approved"
}
响应 409 · application/json · recorded
{
  "error": "certification already recorded",
  "code": "certification_already_recorded"
}
响应 409 · application/json · too_many
{
  "error": "too many certifications: a facility holds at most 100",
  "code": "too_many_certifications"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/facilities/{code}/certifications/{id}/end

End a facility's packing-house certification

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_edit · endFacilityCertification

#269: ends the certification from a day within its validity (withdrawn, suspended or replaced), with a reason; once, never undone (a mistake is ended and recorded again). Its status is ended from that day. Shown to the company's staff only: no trust tier and no public page uses them (architect decision on #269; ADR 0001). Same roles as editing the facility. Audited (facility.certification.end) in the company's activity log. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Facility code.

id
必填
pathstring

Certification id.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

FacilityCertificationEnd (必填)

媒体类型: application/json

请求示例 · application/json
{
  "ended_on": "2026-10-19",
  "reason": "Suspended by the certification body"
}

响应

状态码类型说明
200FacilityCertification
application/json

The certification after the change.

400Error
application/json

Invalid JSON, an unknown field, a day outside the validity, no reason, or a bad X-Request-Id. Or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

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

404Error
application/json

No such facility for this company (one of another company, or outside an operator's facilities, answers exactly like a missing one), or no such certification of the facility.

405Error
application/json

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

409Error
application/json

The certification was ended already. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "id": 12,
  "facility": "VN-TGPH-021",
  "scheme": "BRCGS",
  "number": "BRC-12345",
  "issuer": "Bureau Veritas Certification",
  "valid_from": "2026-03-01",
  "valid_to": "2027-02-28",
  "evidence_sha256": "9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f",
  "created_at": 1790000000.5,
  "ended_on": "2026-10-19",
  "end_reason": "Suspended by the certification body",
  "ended_at": 1790000100.5,
  "status": "ended"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · invalid_ended_on
{
  "error": "invalid ended_on: a day from valid_from to valid_to",
  "code": "invalid_ended_on"
}
响应 400 · application/json · invalid_reason
{
  "error": "invalid reason: 1 to 500 characters on one line",
  "code": "invalid_reason"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGPH-021",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · ended
{
  "error": "certification already ended",
  "code": "certification_already_ended"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/facility-proposals

Propose a facility of the company

身份验证:cookie · proposeFacility

仅限登录会话——API 令牌和 OAuth 客户端不可调用

SELF-2-8 (#197): a company admin proposes a facility (packing house) of the company it acts for; the body cannot name another company. The facility starts unapproved with proposed_at set, the default slug of its code (numbered when taken) and no GACC PHC code. Until CropPath approves it, no lot, shipment, device, gateway, harvest app key or signing key may name it (409 facility not approved), so it never reaches a label, a public page, a customs file or a trust tier. The code is unique across all companies and cannot be changed later; a company holds at most 20 proposals waiting for CropPath (409 too many pending proposals). Audited (facility.propose). Allowed for tenant_admin and platform_admin through a signed-in session only: an API token, an API client or the legacy token is refused (403), so no integration registers codes. #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.

参数

名称位置类型说明
Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

FacilityProposalCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "code": "VN-TGPH-044",
  "name": "Hoa Hung packing house",
  "address": "Ấp Hòa Hưng",
  "province_code": "82",
  "commune_code": "28516",
  "lines": [
    "A1"
  ]
}

响应

状态码类型说明
201Facility
application/json

The proposed facility, unapproved.

400Error
application/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 (admin_unit_unknown), a commune that the list places in another province (commune_not_in_province), a district (district_with_codes) or a province name sent with the codes (invalid_province), or a malformed code or one code without the other (invalid_province_code, invalid_commune_code).

401Error
application/json

No valid session, API token or legacy token.

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

405Error
application/json

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

409Error
application/json

The code is taken (by any company), or the acting company is not registered. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

#273: province_code and commune_code were sent but the server has no administrative units list in force to check them (administrative_units_catalog_unavailable); nothing was written. A text-only address is not refused this way.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

Deprecation201string

#273: sent only when the request gave the address in Viet Nam as text only (province or district, without province_code and commune_code), on every answer, errors included. @1792195200 (RFC 9745): the text-only address was deprecated at the start of 17 October 2026, UTC.

Sunset201string

#273: sent only when the request gave the address in Viet Nam as text only (province or district, without province_code and commune_code), on every answer, errors included. Sat, 01 May 2027 00:00:00 GMT (RFC 8594): from then a text-only address in Viet Nam may be refused.

Link201string

#273: sent only when the request gave the address in Viet Nam as text only (province or district, without province_code and commune_code), on every answer, errors included. <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="deprecation", <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="sunset": the changelog entry that says what to send instead.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "code": "VN-TGPH-044",
  "tenant": "coop-dl",
  "name": "Hoa Hung packing house",
  "address": "Ấp Hòa Hưng",
  "province": "Tỉnh Đồng Tháp",
  "district": null,
  "gacc_phc_code": null,
  "lines": [
    "A1"
  ],
  "source": "manual",
  "approved_at": null,
  "slug": "vn-tgph-044",
  "created_at": 1790000000.5,
  "updated_at": 1790000000.5,
  "proposed_at": 1790000000.5
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · invalid_code
{
  "error": "invalid code: must look like VN-TGPH-021",
  "code": "invalid_code"
}
响应 400 · application/json · invalid_name
{
  "error": "invalid name: a string of at most 200 characters, not empty",
  "code": "invalid_name"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 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"
}
响应 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"
}
响应 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"
}
响应 400 · application/json · invalid_province
{
  "error": "invalid province: absent or null with the codes, the server writes the official name",
  "code": "invalid_province"
}
响应 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"
}
响应 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"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · code_taken
{
  "error": "facility code already exists",
  "code": "facility_code_already_exists"
}
响应 409 · application/json · tenant
{
  "error": "tenant not registered",
  "code": "tenant_not_registered"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
响应 503 · application/json
{
  "error": "administrative units catalog unavailable",
  "code": "administrative_units_catalog_unavailable"
}

GET /v1/product-gtins

The company's trade item GTINs

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:tenant_read · listProductGtins

#161: every trade item (product, variety, grade) the company registered with its GTIN, at most 500. Allowed for the company's readers (admins, auditors). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

响应

状态码类型说明
200ProductGtinList
application/json

The trade items.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "product": "durian",
      "variety": "Ri6",
      "grade": null,
      "gtin": "09520000000011",
      "allocated": true,
      "created_by": "admin@coop.example",
      "created_at": 1790000000.5
    }
  ]
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/product-gtins

Register a trade item's GTIN

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_edit · createProductGtin

#161: the GTIN of a (product, variety, grade), allocated from the platform's GS1 company prefix (owner decision D2; 409 while none is configured), or a GTIN of the company's own GS1 membership. A lot created without a GTIN then takes the GTIN of its ungraded (product, variety). The item and the GTIN are each unique within the company. Allowed for tenant_admin and platform_admin acting for the company. Audited (product_gtin.create) in the company's activity log. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

ProductGtinCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "product": "durian",
  "variety": "Ri6"
}

响应

状态码类型说明
201ProductGtin
application/json

The trade item registered.

400Error
application/json

An unknown or malformed field (a GTIN whose check digit is wrong or that carries the platform's prefix), invalid JSON, a bad X-Request-Id or Idempotency-Key.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

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

409Error
application/json

The item or the GTIN is registered already, the company holds 500 items, no GS1 company prefix is configured; or the Idempotency-Key's first request is still running.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "product": "durian",
  "variety": "Ri6",
  "grade": null,
  "gtin": "09520000000011",
  "allocated": true,
  "created_by": "admin@coop.example",
  "created_at": 1790000000.5
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 400 · application/json · invalid_gtin
{
  "error": "invalid gtin: 14 digits with a valid GS1 check digit",
  "code": "invalid_gtin"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · item
{
  "error": "trade item already has a gtin",
  "code": "trade_item_already_has_a_gtin"
}
响应 409 · application/json · gtin
{
  "error": "gtin already in use by another trade item of the company",
  "code": "gtin_already_in_use_by_another_trade_item_of_the_company"
}
响应 409 · application/json · prefix
{
  "error": "prefix not configured: the platform has no GS1 company prefix yet; enter a number of the company's own GS1 membership",
  "code": "prefix_not_configured"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growers

Growers of the caller's tenant

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · listGrowers

Newest first with keyset pagination. The name appears for tenant_admin and platform_admin (who manage growers) and, for auditors and operators, only when public_consent is on; display_name is Co-op member #<id> without consent. Allowed for platform_admin, tenant_admin, auditor and operator (operators read tenant-wide: a growing area carries no facility); lab is refused.

参数

名称位置类型说明
cursor
可选
querystring

next_cursor of the previous page of growers.

limit
可选
queryinteger

Page size, 1 to 200.

响应

状态码类型说明
200GrowerPage
application/json

One page of growers.

400Error
application/json

A cursor that is not one this API issued, a limit outside 1 to 200, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "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
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growers

Register a grower

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_edit · createGrower

Creates a grower of the caller's tenant. Audited (grower.create; the id and consent flag only, never the name). Allowed for platform_admin and tenant_admin. #163: a grower created with public_consent on also gets its first consent record (channel record_edit, listGrowerConsents). Such a grant carries no evidence, so staff see it as "no evidence recorded" (in_force[].evidence_recorded false); granting through public_consent is kept for SDK 0.2.0 and is to be deprecated in favour of recordGrowerConsent, which needs written evidence (turning it off, a withdrawal, stays).

参数

名称位置类型说明
Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

GrowerCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "name": "Nguyen Van An",
  "cooperative": "HTX Ngu Hiep",
  "public_consent": false
}

响应

状态码类型说明
201Grower
application/json

The new grower.

400Error
application/json

Invalid JSON, an unknown field, a missing name, a non-boolean consent, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), 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).

405Error
application/json

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

409Error
application/json

The caller's tenant is not registered. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "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"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 400 · application/json · invalid_name
{
  "error": "invalid name: a string of at most 200 characters, not empty",
  "code": "invalid_name"
}
响应 400 · application/json · invalid_public_consent
{
  "error": "invalid public_consent: a boolean",
  "code": "invalid_public_consent"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · tenant_not_registered
{
  "error": "tenant not registered",
  "code": "tenant_not_registered"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growers/{id}

One grower

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · getGrower

The name appears for tenant_admin and platform_admin (who manage growers) and, for auditors and operators, only when public_consent is on; display_name is Co-op member #<id> without consent. Allowed for platform_admin, tenant_admin, auditor and operator (operators read tenant-wide: a growing area carries no facility); lab is refused.

参数

名称位置类型说明
id
必填
pathstring

Grower id.

响应

状态码类型说明
200Grower
application/json

The grower as the caller may see it.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such grower in this tenant (a grower of another tenant, or an id that is not a positive integer, answers exactly like a missing one).

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "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
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PATCH /v1/growers/{id}

Edit a grower or its consent

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_edit · updateGrower

Changes name, cooperative or public_consent. Turning consent on records consent_at; turning it off clears it. Audited (grower.update; field names and the consent flag only). #163: a change of public_consent is also appended to the grower's consent records (channel record_edit, listGrowerConsents). Such a grant carries no evidence, so staff see it as "no evidence recorded" (in_force[].evidence_recorded false); granting through public_consent is kept for SDK 0.2.0 and is to be deprecated in favour of recordGrowerConsent, which needs written evidence (turning it off, a withdrawal, stays).

参数

名称位置类型说明
id
必填
pathstring

Grower id.

请求体

GrowerUpdate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "public_consent": true
}

响应

状态码类型说明
200Grower
application/json

The grower after the change.

400Error
application/json

Invalid JSON, an empty body, a field that cannot be changed, a value out of bounds, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), 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).

404Error
application/json

No such grower in this tenant (a grower of another tenant, or an id that is not a positive integer, answers exactly like a missing one).

405Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "id": 12,
  "tenant": "coop-dl",
  "display_name": "Nguyen Van An",
  "cooperative": "HTX Ngu Hiep",
  "public_consent": true,
  "consent_at": 1790000100,
  "consent_date": null,
  "consent_scope": null,
  "created_at": 1790000000.5,
  "updated_at": 1790000000.5,
  "name": "Nguyen Van An"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · nothing_to_update
{
  "error": "nothing to update",
  "code": "nothing_to_update"
}
响应 400 · application/json · field_not_editable
{
  "error": "field not editable",
  "code": "field_not_editable"
}
响应 400 · application/json · invalid_public_consent
{
  "error": "invalid public_consent: a boolean",
  "code": "invalid_public_consent"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas

Growing areas the caller's tenant may read

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · listGrowingAreas

The tenant's own areas and the unowned (seeded) ones, ordered by code, with keyset pagination. The grower's name appears only for the owning admins or with public consent; the polygon only for the owning tenant_admin and platform_admin. Allowed for platform_admin, tenant_admin, auditor and operator (operators read tenant-wide: a growing area carries no facility); lab is refused.

参数

名称位置类型说明
cursor
可选
querystring

next_cursor of the previous page of growing areas.

limit
可选
queryinteger

Page size, 1 to 200.

admin_units
可选
query"0" | "1"

#273: 1 adds the address by official code (province_code, commune_code, admin_units_version, address_status, address_before_reform, address_candidates); 0 or none leaves them out and answers exactly as before; any other value is refused (400 bad admin_units).

响应

状态码类型说明
200GrowingAreaPage
application/json

One page of growing areas.

400Error
application/json

A cursor that is not one this API issued, a limit outside 1 to 200, admin_units not 0 or 1, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "code": "VN-DL-SR-0123",
      "tenant": null,
      "name": null,
      "crop": "durian",
      "variety": null,
      "province": null,
      "district": null,
      "commune": null,
      "area_ha": 1,
      "yield_kg_per_ha": 20000,
      "trees": null,
      "planted_year": null,
      "grower_id": null,
      "gacc_puc_code": null,
      "source": "seed",
      "approved_at": null,
      "created_at": null,
      "updated_at": null,
      "registry_changed_at": null,
      "cap_kg": 20000,
      "approval_current": false,
      "grower": null
    },
    {
      "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": null,
      "created_at": 1790000000.5,
      "updated_at": 1790000000.5,
      "registry_changed_at": null,
      "cap_kg": 20000,
      "approval_current": false,
      "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
      }
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · bad_admin_units
{
  "error": "bad admin_units",
  "code": "bad_admin_units"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growing-areas

Register a growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_edit · createGrowingArea

Creates an unapproved area (source manual) owned by the tenant the caller acts for; the body cannot name another tenant. The code is the key across all tenants: a taken code is 409 whoever owns it. Audited (growing_area.create). Allowed for platform_admin and tenant_admin. #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, district and commune 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.

参数

名称位置类型说明
Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

GrowingAreaCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "code": "VN-TGOR-0387",
  "area_ha": 2,
  "yield_kg_per_ha": 10000,
  "name": "Orchard 387",
  "crop": "durian",
  "variety": "Ri6",
  "province_code": "82",
  "commune_code": "28516",
  "trees": 240,
  "planted_year": 2015,
  "grower_id": 12,
  "gacc_puc_code": "VNPUC-TG-0387",
  "polygon": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          106.1,
          10.4
        ],
        [
          106.2,
          10.4
        ],
        [
          106.2,
          10.5
        ],
        [
          106.1,
          10.5
        ],
        [
          106.1,
          10.4
        ]
      ]
    ]
  }
}

响应

状态码类型说明
201GrowingArea
application/json

The new growing area.

400Error
application/json

Invalid JSON, an unknown field, a code that does not look like VN-TGOR-0387, a value out of bounds, an invalid polygon, a grower of another tenant, a crop that names no crop of the crop registry and no configured crop, 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 (admin_unit_unknown), a commune that the list places in another province (commune_not_in_province), a district (district_with_codes) or a province or commune name sent with the codes (invalid_province and invalid_commune), or a malformed code or one code without the other (invalid_province_code, invalid_commune_code).

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), 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).

405Error
application/json

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

409Error
application/json

The code is taken (by any tenant), or the caller's tenant is not registered. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

#273: province_code and commune_code were sent but the server has no administrative units list in force to check them (administrative_units_catalog_unavailable); nothing was written. A text-only address is not refused this way.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

Deprecation201string

#273: sent only when the request gave the address in Viet Nam as text only (province, district or commune, without province_code and commune_code), on every answer, errors included. @1792195200 (RFC 9745): the text-only address was deprecated at the start of 17 October 2026, UTC.

Sunset201string

#273: sent only when the request gave the address in Viet Nam as text only (province, district or commune, without province_code and commune_code), on every answer, errors included. Sat, 01 May 2027 00:00:00 GMT (RFC 8594): from then a text-only address in Viet Nam may be refused.

Link201string

#273: sent only when the request gave the address in Viet Nam as text only (province, district or commune, without province_code and commune_code), on every answer, errors included. <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="deprecation", <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="sunset": the changelog entry that says what to send instead.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "code": "VN-TGOR-0387",
  "tenant": "coop-dl",
  "name": "Orchard 387",
  "crop": "durian",
  "variety": "Ri6",
  "province": "Tỉnh Đồng Tháp",
  "district": null,
  "commune": "Xã Ngũ Hiệp",
  "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": null,
  "created_at": 1790000000.5,
  "updated_at": 1790000000.5,
  "registry_changed_at": null,
  "cap_kg": 20000,
  "approval_current": false,
  "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
        ]
      ]
    ]
  }
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 400 · application/json · invalid_code
{
  "error": "invalid code: must look like VN-TGOR-0387",
  "code": "invalid_code"
}
响应 400 · application/json · invalid_area_ha
{
  "error": "invalid area_ha: a number above 0 up to 100000",
  "code": "invalid_area_ha"
}
响应 400 · application/json · invalid_polygon
{
  "error": "invalid polygon: a ring must be closed (first position equals the last)",
  "code": "invalid_polygon"
}
响应 400 · application/json · invalid_grower_id
{
  "error": "invalid grower_id: no such grower in this tenant",
  "code": "invalid_grower_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 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"
}
响应 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"
}
响应 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"
}
响应 400 · application/json · invalid_province
{
  "error": "invalid province: absent or null with the codes, the server writes the official name",
  "code": "invalid_province"
}
响应 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"
}
响应 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"
}
响应 400 · application/json · invalid_commune
{
  "error": "invalid commune: absent or null with the codes, the server writes the official name",
  "code": "invalid_commune"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · growing_area_code_already_exists
{
  "error": "growing area code already exists",
  "code": "growing_area_code_already_exists"
}
响应 409 · application/json · tenant_not_registered
{
  "error": "tenant not registered",
  "code": "tenant_not_registered"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
响应 503 · application/json
{
  "error": "administrative units catalog unavailable",
  "code": "administrative_units_catalog_unavailable"
}

GET /v1/growing-areas/{code}

One growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · getGrowingArea

Same roles and consent rules as the list.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

admin_units
可选
query"0" | "1"

#273: 1 adds the address by official code (province_code, commune_code, admin_units_version, address_status, address_before_reform, address_candidates); 0 or none leaves them out and answers exactly as before; any other value is refused (400 bad admin_units).

响应

状态码类型说明
200GrowingArea
application/json

The growing area as the caller may see it.

400Error
application/json

admin_units is not 0 or 1, or the X-Request-Id header is malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 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": null,
  "created_at": 1790000000.5,
  "updated_at": 1790000000.5,
  "registry_changed_at": null,
  "cap_kg": 20000,
  "approval_current": false,
  "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
        ]
      ]
    ]
  }
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · bad_admin_units
{
  "error": "bad admin_units",
  "code": "bad_admin_units"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PATCH /v1/growing-areas/{code}

Edit a growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_edit · updateGrowingArea

A tenant_admin of the owner changes the descriptive fields; area_ha, yield_kg_per_ha (the cap inputs of the cross-tenant volume check) and gacc_puc_code are platform_admin only after creation. An unowned (seeded) area is changed by platform_admin only, who may also claim it for a registered tenant once. The code is immutable; approval is kept. Audited (growing_area.update, field names 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, district and commune 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.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

请求体

GrowingAreaUpdate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "trees": 250,
  "province_code": "82",
  "commune_code": "28516"
}

响应

状态码类型说明
200GrowingArea
application/json

The growing area after the change.

400Error
application/json

Invalid JSON, the code in the body, a field the caller may not change, an empty body, a value out of bounds, a grower of another tenant (or on an unowned area), a claim of an owned area, a crop that names no crop of the crop registry and no configured crop, or a bad X-Request-Id. #273: also a code that is not in the administrative units list in force (admin_unit_unknown), a commune that the list places in another province (commune_not_in_province), a district (district_with_codes) or a province or commune name sent with the codes (invalid_province and invalid_commune), or a malformed code or one code without the other (invalid_province_code, invalid_commune_code).

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), 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).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The tenant an unowned area is claimed for is not registered.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

#273: province_code and commune_code were sent but the server has no administrative units list in force to check them (administrative_units_catalog_unavailable); nothing was written. A text-only address is not refused this way.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Deprecation200string

#273: sent only when the request gave the address in Viet Nam as text only (province, district or commune, without province_code and commune_code), on every answer, errors included. Not sent when a successful update sends the record's own stored text back unchanged (compared after Unicode NFC normalisation and trimming): that changes no address, the record keeps its codes, status and candidates. @1792195200 (RFC 9745): the text-only address was deprecated at the start of 17 October 2026, UTC.

Sunset200string

#273: sent only when the request gave the address in Viet Nam as text only (province, district or commune, without province_code and commune_code), on every answer, errors included. Not sent when a successful update sends the record's own stored text back unchanged (compared after Unicode NFC normalisation and trimming): that changes no address, the record keeps its codes, status and candidates. Sat, 01 May 2027 00:00:00 GMT (RFC 8594): from then a text-only address in Viet Nam may be refused.

Link200string

#273: sent only when the request gave the address in Viet Nam as text only (province, district or commune, without province_code and commune_code), on every answer, errors included. Not sent when a successful update sends the record's own stored text back unchanged (compared after Unicode NFC normalisation and trimming): that changes no address, the record keeps its codes, status and candidates. <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="deprecation", <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="sunset": the changelog entry that says what to send instead.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "code": "VN-TGOR-0387",
  "tenant": "coop-dl",
  "name": "Orchard 387",
  "crop": "durian",
  "variety": "Ri6",
  "province": "Tỉnh Đồng Tháp",
  "district": null,
  "commune": "Xã Ngũ Hiệp",
  "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": null,
  "created_at": 1790000000.5,
  "updated_at": 1790000000.5,
  "registry_changed_at": null,
  "cap_kg": 20000,
  "approval_current": false,
  "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
        ]
      ]
    ]
  }
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · code_is_immutable
{
  "error": "code is immutable",
  "code": "code_is_immutable"
}
响应 400 · application/json · field_not_editable
{
  "error": "field not editable",
  "code": "field_not_editable"
}
响应 400 · application/json · nothing_to_update
{
  "error": "nothing to update",
  "code": "nothing_to_update"
}
响应 400 · application/json · invalid_grower_id
{
  "error": "invalid grower_id: an unowned area has no growers",
  "code": "invalid_grower_id"
}
响应 400 · application/json · tenant_is_set_already
{
  "error": "tenant is set already: an owned area keeps its owner",
  "code": "tenant_is_set_already"
}
响应 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"
}
响应 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"
}
响应 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"
}
响应 400 · application/json · invalid_province
{
  "error": "invalid province: absent or null with the codes, the server writes the official name",
  "code": "invalid_province"
}
响应 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"
}
响应 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"
}
响应 400 · application/json · invalid_commune
{
  "error": "invalid commune: absent or null with the codes, the server writes the official name",
  "code": "invalid_commune"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json
{
  "error": "tenant not registered",
  "code": "tenant_not_registered"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
响应 503 · application/json
{
  "error": "administrative units catalog unavailable",
  "code": "administrative_units_catalog_unavailable"
}

GET /v1/growing-areas/{code}/gln

A growing area's GLN

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · getGrowingAreaGln

#161: the area's GS1 Global Location Number, null when it has none. Same roles as reading the area (its own and unowned areas). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

响应

状态码类型说明
200GrowingAreaGln
application/json

The area's GLN.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "growing_area": "VN-TGOR-0387",
  "gln": "6141410000014"
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/growing-areas/{code}/gln

Set, clear or allocate a growing area's GLN

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_edit · setGrowingAreaGln

#161: the GLN names the area as read point in the lot's staff EPCIS document; a public document keeps the area's code (a GLN in the GS1 registry can name the grower). Unique among the owner's areas. Same roles as editing the area: an unowned area only for a platform admin (403 otherwise). Audited (growing_area.gln.set) in the company's activity log. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

请求体

GlnChange (必填)

媒体类型: application/json

请求示例 · application/json
{
  "allocate": true
}

响应

状态码类型说明
200GrowingAreaGln
application/json

The GLN as stored.

400Error
application/json

A body that is not {"gln": <13 digits> | null} or {"allocate": true}, a GLN whose check digit is wrong or that carries the platform's prefix (allocated only), invalid JSON or a bad X-Request-Id.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such record for this company: one of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

Another record of the company has that GLN; or no GS1 company prefix is configured (allocation), or every reference of it is allocated.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "growing_area": "VN-TGOR-0387",
  "gln": "9520000000004"
}
响应 400 · application/json · invalid_body
{
  "error": "invalid body: {\"gln\": \"<13 digits>\" | null} or {\"allocate\": true}",
  "code": "invalid_body"
}
响应 400 · application/json · invalid_gln
{
  "error": "invalid gln: 13 digits with a valid GS1 check digit",
  "code": "invalid_gln"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · gln_in_use
{
  "error": "gln already in use by another facility of the company",
  "code": "gln_already_in_use_by_another_facility_of_the_company"
}
响应 409 · application/json · prefix
{
  "error": "prefix not configured: the platform has no GS1 company prefix yet; enter a number of the company's own GS1 membership",
  "code": "prefix_not_configured"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/polygon-versions

Boundary versions of a growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · listPolygonVersions

SENS-A1 (#224): the growing area's pending boundary proposal (null when none) and every boundary the platform approved, newest first with keyset pagination. A version never changes and is in force from its valid_from until the next one's. The owning tenant_admin and platform_admin get the boundaries and who proposed and approved them; operators and auditors (and a tenant_admin on an unowned area) get the SHA-256 and times only. Allowed for platform_admin, tenant_admin, auditor and operator; lab is refused. Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

cursor
可选
querystring

next_cursor of the previous page of versions.

limit
可选
queryinteger

Page size, 1 to 200.

响应

状态码类型说明
200PolygonHistory
application/json

The pending proposal and one page of versions.

400Error
application/json

A cursor that is not one this API issued, a limit outside 1 to 200, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "pending": {
    "polygon_sha256": "9c419c419c419c419c419c419c419c419c419c419c419c419c419c419c419c41",
    "proposed_at": 1790007200.5,
    "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_by": "admin@coop.example"
  },
  "items": [
    {
      "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"
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/boundary-walks

Boundary walks of a growing area

身份验证:cookie, bearer · listBoundaryWalks

#248: the walks sent for the growing area, newest first with keyset pagination, without their tracks: who walked, when, how long, the threshold, the counts and the area. A walk is the evidence of the boundary proposal and of the boundary version with the same polygon_sha256; polygon_sha256 keeps only those. Allowed for the tenant_admin of the area's company and a platform_admin acting for it (X-Tenant); operators, auditors and labs are refused, and it is never public (never an OAuth client). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

polygon_sha256
可选
querystring

Only the walks of this outline (64 lower-case hex characters).

cursor
可选
querystring

next_cursor of the previous page.

limit
可选
queryinteger

Page size, 1 to 200.

响应

状态码类型说明
200BoundaryWalkPage
application/json

One page of walks.

400Error
application/json

A bad cursor, limit or polygon_sha256, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (operators, auditors and labs do not read walks) or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this company: another company's area (and an unowned, seeded one) answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "id": 17,
      "growing_area": "VN-TGOR-0387",
      "client_walk_id": "6f1c2a7e-3b4d-4e5f-8a9b-0c1d2e3f4a5b",
      "submitted_by": "op@coop.example",
      "submitted_at": 1790000300,
      "started_at": 1790000000,
      "finished_at": 1790000240,
      "accuracy_threshold_m": 15,
      "polygon_sha256": "5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e",
      "area_ha": 1.2172891,
      "registered_area_ha": 2,
      "area_difference_ratio": -0.39135545,
      "points_total": 6,
      "points_kept": 5,
      "points_dropped": 1,
      "superseded": false
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · sha
{
  "error": "invalid polygon_sha256: 64 lower-case hex characters",
  "code": "invalid_polygon_sha256"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growing-areas/{code}/boundary-walks

Submit a boundary walk

身份验证:cookie, bearer · submitBoundaryWalk

#248: someone of the company walked the edge of the growing area with a phone: the outline becomes the area's pending boundary proposal and the walk is kept as its evidence. A walk is always a proposal, whoever sends it and whether or not the area is approved: it never changes the boundary in force, it replaces a proposal that was waiting (as a company admin's boundary change does), and a platform admin approves or rejects it in the boundary proposal queue, which records the approved boundary as a new version (approving the boundary does not approve the area). The server checks the outline (one ring, at least 3 different corners, not crossing itself, at least 0.01 ha, every corner one of the submitted points within the accuracy threshold) and computes its area. Idempotent on the area and client_walk_id: the same walk sent again answers the stored result (200) and changes nothing; another walk with the same id is 409. Audited (growing_area.boundary_walk.submit, one row per request naming the walk, the outline's SHA-256 and the counts, never the track or coordinates). Allowed for operator, tenant_admin and a platform_admin acting for the company (X-Tenant), never an OAuth client; auditors and labs are refused. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

BoundaryWalkCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "client_walk_id": "6f1c2a7e-3b4d-4e5f-8a9b-0c1d2e3f4a5b",
  "polygon": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          106.1,
          10.4
        ],
        [
          106.101,
          10.4
        ],
        [
          106.101,
          10.401
        ],
        [
          106.1,
          10.401
        ],
        [
          106.1,
          10.4
        ]
      ]
    ]
  },
  "accuracy_threshold_m": 15,
  "started_at": 1790000000,
  "finished_at": 1790000240,
  "points": [
    [
      106.1,
      10.4,
      4,
      1790000000
    ],
    [
      106.1005,
      10.4,
      3.5,
      1790000030
    ],
    [
      106.1004,
      10.4003,
      32,
      1790000040
    ],
    [
      106.101,
      10.4,
      4.2,
      1790000060
    ],
    [
      106.101,
      10.401,
      3.8,
      1790000150
    ],
    [
      106.1,
      10.401,
      4,
      1790000240
    ]
  ]
}

响应

状态码类型说明
200BoundaryWalkResult
application/json

The same walk was sent before: its stored result; nothing changed.

201BoundaryWalkResult
application/json

The walk was stored and its outline is the area's pending boundary proposal.

400Error
application/json

An unknown, missing or malformed field (a time before 2020 or more than 300 s ahead included), an outline that is not a Polygon of exactly one ring or has more than 1000 positions, or an outline the walk does not support: fewer than 3 different corners (too_few_corners), crossing itself (self_intersecting), under 0.01 ha (too_small), a corner that is not one of the submitted points within the accuracy threshold (vertex_not_walked). Or a bad X-Request-Id or Idempotency-Key.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (auditors and labs; also anyone on an unowned, seeded area, which has no company to propose for), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions), or company read-only while the company is leaving CropPath or has left.

404Error
application/json

No such growing area for this company: another company's area answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

Another walk was already sent with this client_walk_id for the area. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "id": 17,
  "polygon_sha256": "5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e",
  "area_ha": 1.2172891,
  "registered_area_ha": 2,
  "area_difference_ratio": -0.39135545,
  "points_total": 6,
  "points_kept": 5,
  "points_dropped": 1,
  "superseded": false
}
响应 201 · application/json
{
  "id": 17,
  "polygon_sha256": "5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e",
  "area_ha": 1.2172891,
  "registered_area_ha": 2,
  "area_difference_ratio": -0.39135545,
  "points_total": 6,
  "points_kept": 5,
  "points_dropped": 1,
  "superseded": false
}
响应 400 · application/json · self_intersecting
{
  "error": "self_intersecting: the boundary crosses itself",
  "code": "self_intersecting"
}
响应 400 · application/json · too_small
{
  "error": "too_small: the walked area is under 0.01 ha",
  "code": "too_small"
}
响应 400 · application/json · too_few_corners
{
  "error": "too_few_corners: the boundary needs at least 3 different corners",
  "code": "too_few_corners"
}
响应 400 · application/json · vertex_not_walked
{
  "error": "vertex_not_walked: every corner must be a walked point within the accuracy threshold",
  "code": "vertex_not_walked"
}
响应 400 · application/json · one_ring
{
  "error": "invalid polygon: a walk is a Polygon with exactly one ring",
  "code": "invalid_polygon"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · walk_id_taken
{
  "error": "client_walk_id taken: another walk was sent with this id",
  "code": "client_walk_id_taken"
}
响应 409 · application/json · idempotency_in_progress
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/boundary-walks/{id}

A boundary walk with its track

身份验证:cookie, bearer · getBoundaryWalk

#248: one walk of the growing area with its outline and its raw track (every fix, the imprecise ones included). Allowed for the tenant_admin of the area's company and a platform_admin acting for it (X-Tenant); operators, auditors and labs are refused, and it is never public (never an OAuth client). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

id
必填
pathinteger

The walk's id.

响应

状态码类型说明
200BoundaryWalk
application/json

The walk.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (operators, auditors and labs do not read walks) or tenant not allowed (X-Tenant).

404Error
application/json

No such walk of this growing area of this company: another company's area or walk, or a walk of another area, answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "id": 17,
  "growing_area": "VN-TGOR-0387",
  "client_walk_id": "6f1c2a7e-3b4d-4e5f-8a9b-0c1d2e3f4a5b",
  "submitted_by": "op@coop.example",
  "submitted_at": 1790000300,
  "started_at": 1790000000,
  "finished_at": 1790000240,
  "accuracy_threshold_m": 15,
  "polygon_sha256": "5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e5d0e",
  "area_ha": 1.2172891,
  "registered_area_ha": 2,
  "area_difference_ratio": -0.39135545,
  "points_total": 6,
  "points_kept": 5,
  "points_dropped": 1,
  "superseded": false,
  "polygon": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          106.1,
          10.4
        ],
        [
          106.101,
          10.4
        ],
        [
          106.101,
          10.401
        ],
        [
          106.1,
          10.401
        ],
        [
          106.1,
          10.4
        ]
      ]
    ]
  },
  "points": [
    [
      106.1,
      10.4,
      4,
      1790000000
    ],
    [
      106.1005,
      10.4,
      3.5,
      1790000030
    ],
    [
      106.1004,
      10.4003,
      32,
      1790000040
    ],
    [
      106.101,
      10.4,
      4.2,
      1790000060
    ],
    [
      106.101,
      10.401,
      3.8,
      1790000150
    ],
    [
      106.1,
      10.401,
      4,
      1790000240
    ]
  ]
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: 17",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/land-certificates

Land certificates of a growing area

身份验证:cookie, bearer · listLandCertificates

#250: the land-use right certificates sent for the growing area, newest first with keyset pagination, without their corners: the central meridian, the number of corners, the plane area, the photo's hash, the converted outline's SHA-256 and area, compared with the registered size and with the area's latest boundary walk. A certificate is the evidence of the boundary proposal and of the boundary version with the same polygon_sha256 (that boundary is "from land certificate"); polygon_sha256 keeps only those. Allowed for the tenant_admin of the area's company and a platform_admin acting for it (X-Tenant); operators, auditors and labs are refused, and it is never public (never an OAuth client). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

polygon_sha256
可选
querystring

Only the certificates of this outline (64 lower-case hex characters).

cursor
可选
querystring

next_cursor of the previous page.

limit
可选
queryinteger

Page size, 1 to 200.

响应

状态码类型说明
200LandCertificatePage
application/json

One page of certificates.

400Error
application/json

A bad cursor, limit or polygon_sha256, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (operators, auditors and labs do not read land certificates) or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this company: another company's area (and an unowned, seeded one) answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "id": 5,
      "growing_area": "VN-TGOR-0387",
      "submitted_at": 1790000300,
      "central_meridian_min": 6345,
      "corners_total": 4,
      "plane_area_m2": 12110.71,
      "photo_sha256": "3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c",
      "polygon_sha256": "8ba5874c1392fdd1261f2be94e4ecc813d585bc485a4d066711e7afdf41d681e",
      "area_ha": 1.2188975,
      "registered_area_ha": 2,
      "area_difference_ratio": -0.39055124,
      "walk": {
        "walk_id": 17,
        "area_ha": 1.2172891,
        "area_difference_ratio": 0.00132129,
        "centre_offset_m": 0.02
      },
      "superseded": false
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · sha
{
  "error": "invalid polygon_sha256: 64 lower-case hex characters",
  "code": "invalid_polygon_sha256"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growing-areas/{code}/land-certificates

Submit a land certificate's parcel corners

身份验证:cookie, bearer · submitLandCertificate

#250: the corners of the parcel printed on a land-use right certificate's parcel map, VN-2000 plane coordinates (X northing, Y easting in metres) of the 3-degree transverse Mercator projection with k0 = 0.9999 on the province's central meridian (Circular 26/2024/TT-BTNMT), with the photo of the certificate page. The server converts the corners to WGS 84 with the transformation the government published (Decision 05/2007/QD-BTNMT's parameters in Circular 973/2001/TT-TCDC's formulas): the outline becomes the area's pending boundary proposal and the certificate is kept as its evidence. A certificate is always a proposal, whoever sends it and whether or not the area is approved: it never changes the boundary in force, it replaces a proposal that was waiting, and a platform admin approves or rejects it in the boundary proposal queue, which records the approved boundary as a new version. The answer compares the outline with the registered size and with the area's latest boundary walk. The published sources give no control points: the conversion's accuracy against official points is not established. Audited (growing_area.land_certificate.submit, one row per request naming the certificate, the outline's SHA-256, the central meridian and the number of corners, never the corners or the photo). Allowed for the tenant_admin of the area's company and a platform_admin acting for it (X-Tenant); operators, auditors and labs are refused, and it is never public (never an OAuth client). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

LandCertificateCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "central_meridian_min": 6345,
  "corners": [
    [
      1150116.67,
      538126.67
    ],
    [
      1150116.79,
      538236.17
    ],
    [
      1150227.39,
      538236.05
    ],
    [
      1150227.27,
      538126.55
    ]
  ],
  "photo_sha256": "3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c"
}

响应

状态码类型说明
201LandCertificate
application/json

The certificate was stored and its outline is the area's pending boundary proposal.

400Error
application/json

An unknown, missing or malformed field: a central meridian that is not one of Circular 26/2024/TT-BTNMT Appendix 01, a photo hash that is not 64 lower-case hex characters, fewer than 3 or more than 200 corners, a corner out of range; an image the company did not upload (unknown_photo_sha256); or an outline the server refuses: fewer than 3 different corners (too_few_corners), crossing itself (self_intersecting), under 0.01 ha (too_small). Or a bad X-Request-Id or Idempotency-Key.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (operators, auditors and labs; also anyone on an unowned, seeded area, which has no company to propose for), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions), or company read-only while the company is leaving CropPath or has left.

404Error
application/json

No such growing area for this company: another company's area answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "id": 5,
  "growing_area": "VN-TGOR-0387",
  "submitted_at": 1790000300,
  "central_meridian_min": 6345,
  "corners_total": 4,
  "plane_area_m2": 12110.71,
  "photo_sha256": "3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c",
  "polygon_sha256": "8ba5874c1392fdd1261f2be94e4ecc813d585bc485a4d066711e7afdf41d681e",
  "area_ha": 1.2188975,
  "registered_area_ha": 2,
  "area_difference_ratio": -0.39055124,
  "walk": {
    "walk_id": 17,
    "area_ha": 1.2172891,
    "area_difference_ratio": 0.00132129,
    "centre_offset_m": 0.02
  },
  "superseded": false,
  "corners": [
    [
      1150116.67,
      538126.67
    ],
    [
      1150116.79,
      538236.17
    ],
    [
      1150227.39,
      538236.05
    ],
    [
      1150227.27,
      538126.55
    ]
  ],
  "polygon": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          106.09999996,
          10.39999998
        ],
        [
          106.10100002,
          10.39999997
        ],
        [
          106.10100004,
          10.40099996
        ],
        [
          106.09999998,
          10.40099996
        ],
        [
          106.09999996,
          10.39999998
        ]
      ]
    ]
  }
}
响应 400 · application/json · meridian
{
  "error": "invalid central_meridian_min: a central meridian of Circular 26/2024/TT-BTNMT Appendix 01",
  "code": "invalid_central_meridian_min"
}
响应 400 · application/json · photo
{
  "error": "unknown photo_sha256: upload the photo of the certificate (JPEG or PNG) first",
  "code": "unknown_photo_sha256"
}
响应 400 · application/json · self_intersecting
{
  "error": "self_intersecting: the boundary crosses itself",
  "code": "self_intersecting"
}
响应 400 · application/json · too_small
{
  "error": "too_small: the parcel is under 0.01 ha",
  "code": "too_small"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growing-areas/{code}/land-certificates/check

Check a land certificate's parcel corners before its photo

身份验证:cookie, bearer · checkLandCertificate

#250: the refusals a land certificate (submitLandCertificate) would meet before its photo matters, for the same corners and central meridian without photo_sha256: the corners, the converted outline (too_few_corners, self_intersecting, too_small) and the area (another company's area 404, an unowned one 403). Nothing is stored and the request is not audited; the answer is the outline the certificate would propose. The console calls it before it uploads the certificate's photo, so a refused certificate never leaves the land user's certificate page behind as an ordinary company upload (readable to auditors and API clients through the upload's activity log row). Allowed for the tenant_admin of the area's company and a platform_admin acting for it (X-Tenant); operators, auditors and labs are refused, and it is never public (never an OAuth client). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

LandCertificateCheck (必填)

媒体类型: application/json

请求示例 · application/json
{
  "central_meridian_min": 6345,
  "corners": [
    [
      1150116.67,
      538126.67
    ],
    [
      1150116.79,
      538236.17
    ],
    [
      1150227.39,
      538236.05
    ],
    [
      1150227.27,
      538126.55
    ]
  ]
}

响应

状态码类型说明
200LandCertificateCheckResult
application/json

The certificate would pass these checks: the outline it would propose. Nothing was stored.

400Error
application/json

An unknown, missing or malformed field (photo_sha256 included: a check never takes the photo): a central meridian that is not one of Circular 26/2024/TT-BTNMT Appendix 01, fewer than 3 or more than 200 corners, a corner out of range; or an outline the server refuses: fewer than 3 different corners (too_few_corners), crossing itself (self_intersecting), under 0.01 ha (too_small). Or a bad X-Request-Id or Idempotency-Key.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (operators, auditors and labs; also anyone on an unowned, seeded area, which has no company to propose for), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions), or company read-only while the company is leaving CropPath or has left.

404Error
application/json

No such growing area for this company: another company's area answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "corners_total": 4,
  "plane_area_m2": 12110.71,
  "polygon_sha256": "8ba5874c1392fdd1261f2be94e4ecc813d585bc485a4d066711e7afdf41d681e",
  "area_ha": 1.2188975,
  "registered_area_ha": 2,
  "area_difference_ratio": -0.39055124,
  "polygon": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          106.09999996,
          10.39999998
        ],
        [
          106.10100002,
          10.39999997
        ],
        [
          106.10100004,
          10.40099996
        ],
        [
          106.09999998,
          10.40099996
        ],
        [
          106.09999996,
          10.39999998
        ]
      ]
    ]
  }
}
响应 400 · application/json · meridian
{
  "error": "invalid central_meridian_min: a central meridian of Circular 26/2024/TT-BTNMT Appendix 01",
  "code": "invalid_central_meridian_min"
}
响应 400 · application/json · self_intersecting
{
  "error": "self_intersecting: the boundary crosses itself",
  "code": "self_intersecting"
}
响应 400 · application/json · too_small
{
  "error": "too_small: the parcel is under 0.01 ha",
  "code": "too_small"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/land-certificates/{id}

A land certificate with its corners

身份验证:cookie, bearer · getLandCertificate

#250: one land certificate of the growing area with its corners as typed and the converted outline (WGS 84). Allowed for the tenant_admin of the area's company and a platform_admin acting for it (X-Tenant); operators, auditors and labs are refused, and it is never public (never an OAuth client). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

id
必填
pathinteger

The certificate's id.

响应

状态码类型说明
200LandCertificate
application/json

The certificate.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (operators, auditors and labs do not read land certificates) or tenant not allowed (X-Tenant).

404Error
application/json

No such certificate of this growing area of this company: another company's area or certificate, or a certificate of another area, answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "id": 5,
  "growing_area": "VN-TGOR-0387",
  "submitted_at": 1790000300,
  "central_meridian_min": 6345,
  "corners_total": 4,
  "plane_area_m2": 12110.71,
  "photo_sha256": "3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c3f9c",
  "polygon_sha256": "8ba5874c1392fdd1261f2be94e4ecc813d585bc485a4d066711e7afdf41d681e",
  "area_ha": 1.2188975,
  "registered_area_ha": 2,
  "area_difference_ratio": -0.39055124,
  "walk": {
    "walk_id": 17,
    "area_ha": 1.2172891,
    "area_difference_ratio": 0.00132129,
    "centre_offset_m": 0.02
  },
  "superseded": false,
  "corners": [
    [
      1150116.67,
      538126.67
    ],
    [
      1150116.79,
      538236.17
    ],
    [
      1150227.39,
      538236.05
    ],
    [
      1150227.27,
      538126.55
    ]
  ],
  "polygon": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          106.09999996,
          10.39999998
        ],
        [
          106.10100002,
          10.39999997
        ],
        [
          106.10100004,
          10.40099996
        ],
        [
          106.09999998,
          10.40099996
        ],
        [
          106.09999996,
          10.39999998
        ]
      ]
    ]
  }
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: 5",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/sensor-series

Sensor series of a growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · getSensorSeries

SENS-B1e (#235): the hourly, daily (UTC days) or farm-day (local_daily, #365) summaries of one vocabulary capability in the growing area, from the caller's company's devices only (an unowned area shows each company its own readings), one series per depth unless depth_cm names one. Each bucket gives the minimum, maximum, mean and count of the values flagged pass or not evaluated (mean null when none counted), every reading's count and the count per QC flag. A bucket is returned when its start is from the start of the bucket holding from to before to. A local_daily bucket is the merge of the 24 hourly summaries of one Asia/Ho_Chi_Minh day (its least minimum, greatest maximum, summed sums and counts), so it is exact over the whole history; its bucket_start is the day's local midnight and the answer adds time_zone and day_starts_at. The range is at most 31 days hourly, 5 years daily and 366 days local_daily (range_too_long); the answer at most 5000 buckets (truncated). No coordinate is ever part of a series. Allowed for platform_admin, tenant_admin, auditor and operator; lab is refused. Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

capability
必填
querystring

A capability of the vocabulary (capability_is_required, unknown_capability).

depth_cm
可选
querynumber

One depth in cm, 0 to 10000; omitted: every depth, each its own series.

grain
可选
query"hourly" | "daily" | "local_daily"

Bucket width: an hour or a day in UTC (hourly, daily: a UTC day runs from 07:00 to 07:00 in Viet Nam), or a farm day in Asia/Ho_Chi_Minh (local_daily).

from
可选
querystring

Start: an ISO 8601 date or date-time (+07:00 without an offset). Default: 7 days (hourly) or 365 days (daily, local_daily) before to.

to
可选
querystring

End (excluded), as from. Default: now.

响应

状态码类型说明
200SensorSeries
application/json

The series.

400Error
application/json

A missing or unknown capability, a bad grain, depth or time, a range whose start is not before its end or longer than the grain allows, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "growing_area": "VN-TGOR-0387",
  "capability": "soil.moisture",
  "unit": "%",
  "grain": "hourly",
  "bucket_s": 3600,
  "from": 1790125200,
  "to": 1790730000,
  "truncated": false,
  "series": [
    {
      "depth_cm": 10,
      "buckets": [
        {
          "bucket_start": 1790726400,
          "min": 30.7,
          "max": 31.1,
          "mean": 30.9,
          "count": 2,
          "n_total": 3,
          "n_pass": 2,
          "n_not_evaluated": 0,
          "n_suspect": 0,
          "n_fail": 0,
          "n_missing": 1
        },
        {
          "bucket_start": 1790730000,
          "min": null,
          "max": null,
          "mean": null,
          "count": 0,
          "n_total": 1,
          "n_pass": 0,
          "n_not_evaluated": 0,
          "n_suspect": 0,
          "n_fail": 1,
          "n_missing": 0
        }
      ]
    }
  ]
}
响应 400 · application/json · capability_is_required
{
  "error": "capability is required",
  "code": "capability_is_required"
}
响应 400 · application/json · unknown_capability
{
  "error": "unknown capability",
  "code": "unknown_capability"
}
响应 400 · application/json · bad_grain
{
  "error": "bad grain: hourly, daily or local_daily",
  "code": "bad_grain"
}
响应 400 · application/json · bad_depth_cm
{
  "error": "bad depth_cm",
  "code": "bad_depth_cm"
}
响应 400 · application/json · bad_from
{
  "error": "bad from",
  "code": "bad_from"
}
响应 400 · application/json · bad_to
{
  "error": "bad to",
  "code": "bad_to"
}
响应 400 · application/json · bad_range
{
  "error": "bad range: from must be before to",
  "code": "bad_range"
}
响应 400 · application/json · range_too_long
{
  "error": "range too long",
  "code": "range_too_long"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/location-check

Location check of a growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · getAreaLocationCheck

#247: which location check ingest makes now for the caller's company's positions of the growing area, in plain terms for the console: against its approved plot boundary (plot_boundary), else against its registered commune with the commune boundaries the platform imported from OpenStreetMap (commune: a mismatch is an alert only, never a hold, and the location trust is unchanged), else none. For the commune check: whether the registered commune is a commune of the boundary data (a name from before the 2025-07-01 reform is not, and gets only commune_unknown), the commune verdict counts over a range of reception times (at most 31 days; both ends included), and, only for a platform admin and the operators and admins (tenant_admin) of the area's owning company, the communes the area's judged positions fell in (the area mapped by point). The OpenStreetMap attribution comes with every answer that names a dataset. Never public. Allowed for platform_admin, tenant_admin, auditor and operator; lab is refused; another company's area answers 404. Not part of the partner SDK clients (x-not-in-sdk).

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

from
可选
querystring

Start: an ISO 8601 date or date-time (+07:00 without an offset). Default: 7 days before to.

to
可选
querystring

End (included), as from. Default: now.

响应

状态码类型说明
200LocationCheck
application/json

Which check applies, and the area by point.

400Error
application/json

A bad time, a range whose start is not before its end or longer than 31 days, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "applies": "commune",
  "registered_commune": "Long Trung",
  "dataset": "osm-2026-10-15T20:21:00Z",
  "name": "unmatched",
  "commune_verdict_counts": {
    "commune_match": 0,
    "commune_mismatch": 0,
    "commune_unknown": 12
  },
  "position_communes": [
    {
      "name": "Xã Mẫu Một",
      "osm_relation": 101,
      "positions": 12
    }
  ],
  "attribution": "© OpenStreetMap contributors",
  "copyright": "https://www.openstreetmap.org/copyright"
}
响应 400 · application/json · bad_from
{
  "error": "bad from",
  "code": "bad_from"
}
响应 400 · application/json · bad_to
{
  "error": "bad to",
  "code": "bad_to"
}
响应 400 · application/json · bad_range
{
  "error": "bad range: from must be before to",
  "code": "bad_range"
}
响应 400 · application/json · range_too_long
{
  "error": "range too long",
  "code": "range_too_long"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/verdict-map

Verdict map of a growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · getVerdictMap

SENS-B1e (#235): for a range of reception times (at most 31 days; both ends included), every device of the caller's company bound to the growing area by its current placement or whose positions were judged against the area in the range (at most 500, truncated): its profile, a summary of its current placement, how many positions got each geofence verdict and its latest verdict with the time it was judged. The install point and the latest judged position are given only to a platform admin and to the operators and admins (tenant_admin) of the area's owning company (coordinates_shown); an auditor, and every caller but a platform admin on an unowned area, get the same answer without them. The boundary only to whom the growing-area read gives it. Never public. Allowed for platform_admin, tenant_admin, auditor and operator; lab is refused. Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

from
可选
querystring

Start: an ISO 8601 date or date-time (+07:00 without an offset). Default: 7 days before to.

to
可选
querystring

End (included), as from. Default: now.

响应

状态码类型说明
200VerdictMap
application/json

The devices and their verdicts.

400Error
application/json

A bad time, a range whose start is not before its end or longer than 31 days, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "growing_area": "VN-TGOR-0387",
  "from": 1790121600,
  "to": 1790726400,
  "coordinates_shown": true,
  "truncated": false,
  "devices": [
    {
      "device_id": "knk-1",
      "profile": "vn.agritrace.durian-knocker",
      "placement": {
        "version": 1,
        "mobility": "fixed",
        "growing_area": "VN-TGOR-0387",
        "bound_here": true,
        "depth_cm": 30,
        "installed_at": 1790000000,
        "removed_at": null,
        "install_point": {
          "lat": 10.45,
          "lon": 106.15,
          "accuracy_m": 2
        }
      },
      "verdict_counts": {
        "inside": 41,
        "near": 2,
        "outside": 1,
        "ambiguous": 0,
        "unverifiable": 0,
        "no_position": 0,
        "no_polygon": 0
      },
      "latest_verdict": "inside",
      "latest_verdict_at": 1790726400,
      "latest_position": {
        "lat": 10.4501,
        "lon": 106.1502,
        "acc_m": 3,
        "verdict": "inside",
        "checked_at": 1790726400
      }
    }
  ],
  "polygon": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          106.1,
          10.4
        ],
        [
          106.2,
          10.4
        ],
        [
          106.2,
          10.5
        ],
        [
          106.1,
          10.5
        ],
        [
          106.1,
          10.4
        ]
      ]
    ]
  }
}
响应 400 · application/json · bad_from
{
  "error": "bad from",
  "code": "bad_from"
}
响应 400 · application/json · bad_to
{
  "error": "bad to",
  "code": "bad_to"
}
响应 400 · application/json · bad_range
{
  "error": "bad range: from must be before to",
  "code": "bad_range"
}
响应 400 · application/json · range_too_long
{
  "error": "range too long",
  "code": "range_too_long"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/certifications

Certifications of a growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · listCertifications

Newest first with keyset pagination. Each certification's status is judged against today's UTC date. Allowed for platform_admin, tenant_admin, auditor and operator (operators read tenant-wide: a growing area carries no facility); lab is refused. #269 review: verified=1 adds each certification's verified, the server's own judgement of whether it is verified (see Certification); the console shows it instead of repeating the rule. The parameter and the field are not part of the partner SDK clients (x-not-in-sdk).

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

cursor
可选
querystring

next_cursor of the previous page of certifications.

limit
可选
queryinteger

Page size, 1 to 200.

verified
可选
query"0" | "1"

#269 review: 1 adds each certification's verified (items[].verified); 0 or none leaves it out and answers exactly as before; any other value is refused (400 bad verified). It selects no certifications: every one is listed either way.

响应

状态码类型说明
200CertificationPage
application/json

One page of certifications.

400Error
application/json

A cursor that is not one this API issued, a limit outside 1 to 200, verified not 0 or 1, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "id": 1,
      "growing_area": "VN-TGOR-0387",
      "scheme": "VietGAP",
      "number": "VG-TG-0387",
      "issuer": "NAFIQAD",
      "valid_from": "2025-01-01",
      "valid_to": "2027-12-31",
      "evidence_sha256": null,
      "created_at": 1790000000.5,
      "status": "valid"
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · bad_verified
{
  "error": "bad verified",
  "code": "bad_verified"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growing-areas/{code}/certifications

Record a certification

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_edit · createCertification

Adds a certification to an area of the caller's tenant (a platform_admin also to an unowned area). The same scheme and number recorded again on the area is refused (409), except when the stored certification is unverified and this request is verified (never for ISO 22000, FSSC 22000, BRCGS or IFS, which are now recorded on the facility, #269): that request verifies the stored certification in place (the same id; its issuer, validity and evidence_sha256 become the request's and created_at the time of the change) and answers 201 with it. Audited (growing_area.certification.create). Allowed for platform_admin and tenant_admin.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

CertificationCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "scheme": "VietGAP",
  "number": "VG-TG-0387",
  "issuer": "NAFIQAD",
  "valid_from": "2025-01-01",
  "valid_to": "2027-12-31",
  "evidence_sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
}

响应

状态码类型说明
201Certification
application/json

The new certification, or the unverified one this request verified.

400Error
application/json

Invalid JSON, an unknown field, a value out of bounds, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), 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).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The same scheme and number is already recorded for this area, verified, or this request would not verify it. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "id": 1,
  "growing_area": "VN-TGOR-0387",
  "scheme": "VietGAP",
  "number": "VG-TG-0387",
  "issuer": "NAFIQAD",
  "valid_from": "2025-01-01",
  "valid_to": "2027-12-31",
  "evidence_sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
  "created_at": 1790000000.5,
  "status": "valid"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 400 · application/json · invalid_valid_to
{
  "error": "invalid valid_to: not before valid_from",
  "code": "invalid_valid_to"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · certification_already_recorded
{
  "error": "certification already recorded",
  "code": "certification_already_recorded"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/satellite-checks

Satellite checks of a growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · listSatelliteChecks

Newest first with keyset pagination. Recorded by hand (source manual); automatic Sentinel-2 fetching is not part of this API. Allowed for platform_admin, tenant_admin, auditor and operator (operators read tenant-wide: a growing area carries no facility); lab is refused.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

cursor
可选
querystring

next_cursor of the previous page of satellite checks.

limit
可选
queryinteger

Page size, 1 to 200.

响应

状态码类型说明
200SatelliteCheckPage
application/json

One page of satellite checks.

400Error
application/json

A cursor that is not one this API issued, a limit outside 1 to 200, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "id": 1,
      "growing_area": "VN-TGOR-0387",
      "image_date": "2026-09-20",
      "provider": "sentinel-2",
      "result": "match",
      "cultivated_ha": 1.9,
      "deforestation": false,
      "confidence": 0.86,
      "image_sha256": "9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c",
      "source": "manual",
      "created_at": 1790000000.5
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growing-areas/{code}/satellite-checks

Record a satellite check

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_edit · createSatelliteCheck

Adds a satellite check to an area of the caller's tenant (a platform_admin also to an unowned area). Audited (growing_area.satellite_check.create). Allowed for platform_admin and tenant_admin.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

SatelliteCheckCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "image_date": "2026-09-20",
  "provider": "sentinel-2",
  "result": "match",
  "cultivated_ha": 1.9,
  "deforestation": false,
  "confidence": 0.86,
  "image_sha256": "9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c"
}

响应

状态码类型说明
201SatelliteCheck
application/json

The new satellite check.

400Error
application/json

Invalid JSON, an unknown field, a value out of bounds, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), 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).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "id": 1,
  "growing_area": "VN-TGOR-0387",
  "image_date": "2026-09-20",
  "provider": "sentinel-2",
  "result": "match",
  "cultivated_ha": 1.9,
  "deforestation": false,
  "confidence": 0.86,
  "image_sha256": "9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c",
  "source": "manual",
  "created_at": 1790000000.5
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 400 · application/json · invalid_result
{
  "error": "invalid result: one of match, mismatch, inconclusive",
  "code": "invalid_result"
}
响应 400 · application/json · invalid_deforestation
{
  "error": "invalid deforestation: a boolean",
  "code": "invalid_deforestation"
}
响应 400 · application/json · invalid_image_sha256
{
  "error": "invalid image_sha256: 64 lower-case hex characters",
  "code": "invalid_image_sha256"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/sprays

Spray records of a growing area

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · listSprayRecords

Newest first with keyset pagination. Each record carries safe_from (sprayed_on + withholding_days) and its withholding_status against the harvest date: violated when sprayed_on <= harvest_date < safe_from, so a harvest on safe_from is ok. Allowed for platform_admin, tenant_admin, auditor and operator (operators read tenant-wide: a growing area carries no facility); lab is refused.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

harvest_date
可选
querystring (date)

The harvest date (YYYY-MM-DD) to judge withholding against; today's UTC date when omitted.

cursor
可选
querystring

next_cursor of the previous page of spray records.

limit
可选
queryinteger

Page size, 1 to 200.

响应

状态码类型说明
200SprayRecordPage
application/json

One page of spray records.

400Error
application/json

A cursor that is not one this API issued, a limit outside 1 to 200, a malformed harvest_date, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "id": 3,
      "growing_area": "VN-TGOR-0387",
      "sprayed_on": "2026-09-01",
      "product": "Ridomil Gold",
      "active_ingredient": "metalaxyl-M",
      "withholding_days": 14,
      "evidence_sha256": "9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c",
      "created_at": 1790000000.5,
      "safe_from": "2026-09-15",
      "evaluated_on": "2026-09-14",
      "withholding_status": "violated"
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_harvest_date
{
  "error": "invalid harvest_date: a date YYYY-MM-DD from 1900 to 2100",
  "code": "invalid_harvest_date"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growing-areas/{code}/sprays

Record a spray record

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_edit · createSprayRecord

Adds a spray record to an area of the caller's tenant (a platform_admin also to an unowned area). Audited (growing_area.spray.create). Allowed for platform_admin and tenant_admin.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

SprayRecordCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "sprayed_on": "2026-09-01",
  "product": "Ridomil Gold",
  "active_ingredient": "metalaxyl-M",
  "withholding_days": 14,
  "evidence_sha256": "9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c"
}

响应

状态码类型说明
201SprayRecord
application/json

The new spray record.

400Error
application/json

Invalid JSON, an unknown field, a value out of bounds, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), 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).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "id": 3,
  "growing_area": "VN-TGOR-0387",
  "sprayed_on": "2026-09-01",
  "product": "Ridomil Gold",
  "active_ingredient": "metalaxyl-M",
  "withholding_days": 14,
  "evidence_sha256": "9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c9f2c",
  "created_at": 1790000000.5,
  "safe_from": "2026-09-15",
  "evaluated_on": "2026-09-14",
  "withholding_status": "violated"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
响应 400 · application/json · invalid_sprayed_on
{
  "error": "invalid sprayed_on: a date YYYY-MM-DD from 1900 to 2100",
  "code": "invalid_sprayed_on"
}
响应 400 · application/json · invalid_withholding_days
{
  "error": "invalid withholding_days: an integer from 0 to 365",
  "code": "invalid_withholding_days"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growing-areas/{code}/volume

Cap and headroom of a growing area for a season

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_read · getGrowingAreaVolume

Queries.volume for the area (declared kg summed across all tenants, cap = area_ha x yield_kg_per_ha) plus headroom_kg = cap_kg - declared_kg. The area must be readable by the caller (own or unowned). Allowed for platform_admin, tenant_admin, auditor and operator (operators read tenant-wide: a growing area carries no facility); lab is refused.

参数

名称位置类型说明
code
必填
pathstring

Growing area code.

season
必填
querystring

Season label (the calendar year by default).

响应

状态码类型说明
200GrowingAreaVolume
application/json

Cap, declared volume and headroom.

400Error
application/json

A missing or malformed season, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such growing area for this tenant: another tenant's area answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "growing_area": "VN-TGOR-0387",
  "season": "2026",
  "declared_kg": 2000,
  "cap_kg": 20000,
  "headroom_kg": 18000
}
响应 400 · application/json · season_is_required
{
  "error": "season is required",
  "code": "season_is_required"
}
响应 400 · application/json · invalid_season
{
  "error": "invalid season: 1 to 32 letters, digits, dots, hyphens or underscores",
  "code": "invalid_season"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGOR-0387",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/facilities/{code}/issuer-keys

List a facility's issuer keys

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:facility_read · listIssuerKeys

Every did:web issuer key of the facility (#34), active, retired and revoked, by number; never a private key. Read like the facility: admins and auditors tenant-wide, an operator only within its facilities. Not audited (a read).

参数

名称位置类型说明
code
必填
pathstring

Facility code.

响应

状态码类型说明
200IssuerKeyList
application/json

The facility's keys.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods).

404Error
application/json

No such facility for this tenant: a facility of another tenant, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "facility": "VN-TGPH-021",
      "n": 1,
      "name": "key-1",
      "did": "did:web:txng.theio.vn:tanphu",
      "key_id": "did:web:txng.theio.vn:tanphu#key-1",
      "alg": "ES256",
      "public_jwk": {
        "kty": "EC",
        "crv": "P-256",
        "x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
        "y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
      },
      "status": "active",
      "created_by": "admin@coop.example",
      "created_at": 1790000000.5,
      "retired_at": null,
      "revoked_at": null,
      "revoke_reason": null,
      "revoked_by": null
    }
  ]
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 404 · application/json
{
  "error": "not found: VN-TGPH-021",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/facilities/{code}/issuer-keys

Generate (rotate) a facility's issuer key

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:issuer_key_admin · createIssuerKey

Generates the facility's next ES256 (P-256) key pair server-side as key-<n> and makes it the active key; a key active until now becomes retired and stays in the DID document, so what it signed stays verifiable (a rotation). The request has no body (or {}). The private key is encrypted under AGRITRACE_ISSUER_KEK into its own 0600 file and is never returned, logged or audited. The facility must be approved; its slug (the DID path) is frozen from then on. Audited (issuer_key.create, entity <facility>#key-<n>). Allowed for tenant_admin and platform_admin of the owning tenant. Second admin approval (INTEGRITY-3, #203): while the company requires a second admin (PUT /v1/company/four-eyes), a direct call answers 403 second_admin_approval_required before anything is done (no audit row, no Idempotency-Key used): ask for it with POST /v1/approval-requests, and another admin of the company approves it.

参数

名称位置类型说明
code
必填
pathstring

Facility code.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

响应

状态码类型说明
201IssuerKey
application/json

The new active key.

400Error
application/json

Invalid JSON, a body with any field, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted, 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).

404Error
application/json

No such facility for this tenant: a facility of another tenant, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The facility is not approved, or it already holds 100 keys. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

No key-encryption key is configured (AGRITRACE_ISSUER_KEK), or the store cannot be used; nothing changed. Retry after Retry-After seconds once it is configured.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

响应示例

响应 201 · application/json
{
  "facility": "VN-TGPH-021",
  "n": 1,
  "name": "key-1",
  "did": "did:web:txng.theio.vn:tanphu",
  "key_id": "did:web:txng.theio.vn:tanphu#key-1",
  "alg": "ES256",
  "public_jwk": {
    "kty": "EC",
    "crv": "P-256",
    "x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
    "y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
  },
  "status": "active",
  "created_by": "admin@coop.example",
  "created_at": 1790000000.5,
  "retired_at": null,
  "revoked_at": null,
  "revoke_reason": null,
  "revoked_by": null
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field: an issuer key is generated by the server and takes no input",
  "code": "unknown_field"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: VN-TGPH-021",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · not_approved
{
  "error": "facility not approved",
  "code": "facility_not_approved"
}
响应 409 · application/json · limit
{
  "error": "issuer key limit reached",
  "code": "issuer_key_limit_reached"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
响应 503 · application/json
{
  "error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
  "code": "issuer_keys_unavailable"
}

POST /v1/facilities/{code}/issuer-keys/{key}/revoke

Revoke a compromised issuer key

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:issuer_key_admin · revokeIssuerKey

Marks the key revoked (reason compromise, the only one: a rotation generates a new key instead). It leaves the DID document at once, so nothing it signed verifies any more, and one high-severity issuer_key_compromised alert is raised for the tenant. A revoked active key leaves the facility without an active key until a new one is generated. Audited (issuer_key.revoke). Allowed for tenant_admin and platform_admin of the owning tenant. 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.

参数

名称位置类型说明
code
必填
pathstring

Facility code.

key
必填
pathstring

Key name key-<n>.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

IssuerKeyRevoke (必填)

媒体类型: application/json

请求示例 · application/json
{
  "reason": "compromise"
}

响应

状态码类型说明
200IssuerKey
application/json

The key after revocation.

400Error
application/json

Invalid JSON, a reason other than compromise, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/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 (mfa_step_up_required, #87: confirm both with POST /v1/auth/reauth, then repeat the request; nothing was done and no audit row was written).

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

404Error
application/json

No such facility for this tenant (another tenant's, or outside an operator's facilities, answers like a missing one), or no such key of the facility.

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "facility": "VN-TGPH-021",
  "n": 1,
  "name": "key-1",
  "did": "did:web:txng.theio.vn:tanphu",
  "key_id": "did:web:txng.theio.vn:tanphu#key-1",
  "alg": "ES256",
  "public_jwk": {
    "kty": "EC",
    "crv": "P-256",
    "x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
    "y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
  },
  "status": "revoked",
  "created_by": "admin@coop.example",
  "created_at": 1790000000.5,
  "retired_at": null,
  "revoked_at": 1790086400.5,
  "revoke_reason": "compromise",
  "revoked_by": "admin@coop.example"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · invalid_reason
{
  "error": "invalid reason: compromise (a rotation generates a new key instead)",
  "code": "invalid_reason"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: key-9",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · key_already_revoked
{
  "error": "key already revoked",
  "code": "key_already_revoked"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growers/batch

Create up to 1,000 growers

身份验证:cookie, bearer, oauth2 · OAuth2 作用域:growing_area_edit · createGrowerBatch

Creates growers of the caller's tenant, each checked like the single creation. Audited once (grower.batch_create; ids and a consent count, never a name). Allowed like the single creation. Atomic: the batch commits whole or not at all, in one transaction with its one audit row. Every item is validated first and every invalid item is reported (400 invalid_batch, items by index); then the items are applied in order and the first one the stored state refuses rolls the batch back and is reported (batch_rejected with the item's own status and items naming it). At most 1,000 items and a body within 1 MiB. Rate limited per tenant and caller (bursts of 10 batches, then one every 6 seconds).

参数

名称位置类型说明
Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

GrowerBatch (必填)

媒体类型: application/json

请求示例 · application/json
{
  "items": [
    {
      "name": "Nguyễn Văn A",
      "cooperative": "HTX Đắk Lắk"
    }
  ]
}

响应

状态码类型说明
201GrowerBatchResult
application/json

The batch, committed.

400Error
application/json

Invalid JSON, a body of the wrong shape, invalid items (invalid_batch, each one listed), an item the stored state refuses as invalid (batch_rejected) or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (also a tenant_admin changing an unowned, seeded area), 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).

405Error
application/json

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

409Error
application/json

The caller's tenant is not registered, or the Idempotency-Key's batch was applied more than 24 hours ago (its response is no longer stored) for this route, path id and body. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used before with another request (another method, path, query or body): idempotency_key_mismatch within 24 hours, idempotency_key_reused_with_a_different_request for a batch key older than that; nothing was done.

429Error
application/json

Too many batch requests from this caller of this tenant (bursts of 10, then one every 6 seconds); nothing was done; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "batch_id": 12,
  "count": 1,
  "items": [
    {
      "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"
    }
  ]
}
响应 400 · application/json · invalid_batch
{
  "error": "invalid batch: 1 of the items failed validation",
  "code": "invalid_batch",
  "items": [
    {
      "index": 3,
      "status": 400,
      "error": "invalid kg: a number above 0 and at most 1000000",
      "code": "invalid_kg"
    }
  ]
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · tenant_not_registered
{
  "error": "tenant not registered",
  "code": "tenant_not_registered"
}
响应 409 · application/json · idempotency_key_already_used
{
  "error": "idempotency key already used: batch 12",
  "code": "idempotency_key_already_used"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json · idempotency_key_mismatch
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 422 · application/json · idempotency_key_reused_with_a_different_request
{
  "error": "idempotency key reused with a different request",
  "code": "idempotency_key_reused_with_a_different_request"
}
响应 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/growers/{id}/consents

A grower's consents

身份验证:cookie · listGrowerConsents

仅限登录会话——API 令牌和 OAuth 客户端不可调用

#163. The grower's consents in force (in_force) and its consent records, newest first: every decision the grower made about showing their name or orchard position (per market or for every market), how it was captured, its evidence's SHA-256 and who recorded it. Another company's grower answers 404. Allowed for only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused (403). Not part of the partner SDK clients yet (x-not-in-sdk).

参数

名称位置类型说明
id
必填
pathstring

Grower id.

limit
可选
queryinteger

1 to 200 (default 50).

cursor
可选
querystring

The previous page's next_cursor.

响应

状态码类型说明
200GrowerConsentPage
application/json

The consents in force and one page of records.

400Error
application/json

A bad limit or cursor, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client 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).

404Error
application/json

No such grower in the selected company (a grower of another company, or an id that is not a positive integer, answers exactly like a missing one).

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "grower_id": 12,
  "in_force": [],
  "items": [
    {
      "id": 32,
      "grower_id": 12,
      "purpose": "public_name",
      "market": null,
      "decision": "withdrawn",
      "channel": "in_person",
      "evidence_sha256": null,
      "consent_date": null,
      "scope": null,
      "request_id": null,
      "recorded_at": 1790086400.5,
      "recorded_by": "user-7"
    },
    {
      "id": 31,
      "grower_id": 12,
      "purpose": "public_name",
      "market": null,
      "decision": "granted",
      "channel": "paper",
      "evidence_sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
      "consent_date": "2026-09-12",
      "scope": "Fruit pages, every market",
      "request_id": null,
      "recorded_at": 1790000000.5,
      "recorded_by": "user-7"
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/growers/{id}/consents

Record a grower's consent decision

身份验证:cookie · recordGrowerConsent

仅限登录会话——API 令牌和 OAuth 客户端不可调用

#163. Appends a grower's decision (granted or withdrawn) about one purpose and market. A grant needs written evidence (paper or electronic, with the evidence's SHA-256); a withdrawal is accepted however the grower made it. The public name for every market is also the grower's public_consent (with consent_date and consent_scope), which the public fruit page reads: a withdrawal takes the name off it at once (a cached copy at the edge lasts up to 60 seconds). The public fruit page names the grower with the public_name consent for the destination market of the shipment its lot is on (the more specific decision wins: a withdrawal for that market hides the name there even while the every-market consent stands), or else with the one for every market; a lot on no shipment has no market, so a consent for one market never names the grower there. While the company is leaving CropPath (the read-only window) a withdrawal is still accepted and a grant is refused 403 company_read_only; once the company has left, a platform admin acting for it can still record a withdrawal (the public pages stay up for the retention period). 409 when the decision does not change what is in force. Audited (grower.consent.record, in the same transaction: the purpose, market, decision and channel; never the evidence hash or the scope). Allowed for only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused (403). Not part of the partner SDK clients yet (x-not-in-sdk).

参数

名称位置类型说明
id
必填
pathstring

Grower id.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

GrowerConsentCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "purpose": "public_name",
  "market": null,
  "decision": "granted",
  "channel": "paper",
  "evidence_sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
  "consent_date": "2026-09-12",
  "scope": "Fruit pages, every market"
}

响应

状态码类型说明
201GrowerConsent
application/json

The new consent record.

400Error
application/json

Invalid JSON, an unknown field or a value outside the limits (a grant without written evidence included), or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client 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 while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such grower in the selected company (a grower of another company, or an id that is not a positive integer, answers exactly like a missing one).

405Error
application/json

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

409Error
application/json

The decision does not change what is in force (a grant of a consent in force, a withdrawal of one that is not); or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "id": 31,
  "grower_id": 12,
  "purpose": "public_name",
  "market": null,
  "decision": "granted",
  "channel": "paper",
  "evidence_sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
  "consent_date": "2026-09-12",
  "scope": "Fruit pages, every market",
  "request_id": null,
  "recorded_at": 1790000000.5,
  "recorded_by": "user-7"
}
响应 400 · application/json · channel
{
  "error": "invalid channel: a grant needs written evidence (paper, electronic)",
  "code": "invalid_channel"
}
响应 400 · application/json · evidence
{
  "error": "invalid evidence_sha256: a grant needs the SHA-256 of its evidence",
  "code": "invalid_evidence_sha256"
}
响应 400 · application/json · market
{
  "error": "invalid market: two capital letters (ISO 3166-1 alpha-2), or null for every market",
  "code": "invalid_market"
}
响应 400 · application/json · unknown
{
  "error": "unknown field: name",
  "code": "unknown_field"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · already_granted
{
  "error": "already granted: this consent is already in force",
  "code": "already_granted"
}
响应 409 · application/json · not_granted
{
  "error": "not granted: this consent is not in force, there is nothing to withdraw",
  "code": "not_granted"
}
响应 409 · application/json · idempotency
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/grower-data-requests

List the growers' data requests

身份验证:cookie · listGrowerDataRequests

仅限登录会话——API 令牌和 OAuth 客户端不可调用

#163. The requests the company's growers made about their personal data (access, rectification, erasure, objection), newest first, with the day each answer is due and whether it is overdue; status and grower_id narrow the list. Allowed for only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused (403). Not part of the partner SDK clients yet (x-not-in-sdk).

参数

名称位置类型说明
status
可选
query"open" | "handled"

Only requests of this status.

grower_id
可选
querystring

Only this grower's requests.

limit
可选
queryinteger

1 to 200 (default 50).

cursor
可选
querystring

The previous page's next_cursor.

响应

状态码类型说明
200GrowerDataRequestPage
application/json

One page of requests.

400Error
application/json

A bad status, grower_id, limit or cursor, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client 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).

405Error
application/json

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

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "items": [
    {
      "id": 4,
      "grower": {
        "id": 12,
        "name": "Nguyễn Văn An"
      },
      "kind": "erasure",
      "channel": "paper",
      "text": "Please take my name off the fruit pages.",
      "received_on": "2026-09-28",
      "due_on": "2026-10-28",
      "overdue": false,
      "status": "handled",
      "created_at": 1790000000.5,
      "created_by": "user-7",
      "handled_at": 1790086400.5,
      "handled_by": "user-7",
      "answer": "Your name no longer shows on the public fruit pages. The signed lot records never named you; the company keeps your name in its own registry for traceability.",
      "withdrawn": [
        {
          "purpose": "public_name",
          "market": null
        }
      ]
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · status
{
  "error": "invalid status: one of open, handled",
  "code": "invalid_status"
}
响应 400 · application/json · grower_id
{
  "error": "invalid grower_id: a grower id",
  "code": "invalid_grower_id"
}
响应 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/grower-data-requests

Record a grower's data request

身份验证:cookie · createGrowerDataRequest

仅限登录会话——API 令牌和 OAuth 客户端不可调用

#163. Records a request a grower made to the company about their personal data, as received: access, rectification, erasure or objection, the channel, the day received and the grower's words (plain text). The answer is due 30 days after the day received (due_on, a proposal pending counsel). Open while the company is leaving CropPath (the read-only window), like a member's personal data request; refused 403 company_read_only once it has left. Audited (grower_data_request.create, in the same transaction: the kind, the grower and the channel; never the text). Allowed for only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused (403). Not part of the partner SDK clients yet (x-not-in-sdk).

参数

名称位置类型说明
Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

GrowerDataRequestCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "grower_id": 12,
  "kind": "erasure",
  "channel": "paper",
  "received_on": "2026-09-28",
  "text": "Please take my name off the fruit pages."
}

响应

状态码类型说明
201GrowerDataRequest
application/json

The request.

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client 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 while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such grower in the selected company (another company's answers exactly like a missing one).

405Error
application/json

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

409Error
application/json

The Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 201 · application/json
{
  "id": 4,
  "grower": {
    "id": 12,
    "name": "Nguyễn Văn An"
  },
  "kind": "erasure",
  "channel": "paper",
  "text": "Please take my name off the fruit pages.",
  "received_on": "2026-09-28",
  "due_on": "2026-10-28",
  "overdue": false,
  "status": "open",
  "created_at": 1790000000.5,
  "created_by": "user-7",
  "handled_at": null,
  "handled_by": null,
  "answer": null,
  "withdrawn": null
}
响应 400 · application/json · kind
{
  "error": "invalid kind: one of access, rectification, erasure, objection",
  "code": "invalid_kind"
}
响应 400 · application/json · received_on
{
  "error": "invalid received_on: a date YYYY-MM-DD from 2000-01-01, not after today",
  "code": "invalid_received_on"
}
响应 400 · application/json · text
{
  "error": "invalid text: required, text of at most 2000 characters",
  "code": "invalid_text"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · idempotency
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/grower-data-requests/{id}/handled

Mark a grower's data request handled

身份验证:cookie · handleGrowerDataRequest

仅限登录会话——API 令牌和 OAuth 客户端不可调用

#163. Marks the request handled with the answer given to the grower (final). For an erasure or an objection, withdraw_public also withdraws every consent in force of the grower (each recorded as a data_request withdrawal naming the request), so the name leaves the public fruit page at once; withdrawn lists them. The answer can say that signed lot records never name a grower, so nothing signed is changed. Another company's request answers 404. Open while the company is leaving CropPath (the read-only window), like a member's personal data request; refused 403 company_read_only once it has left. Audited (grower_data_request.handle, in the same transaction: the kind, the grower and what was withdrawn; never the answer). Allowed for only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused (403). Not part of the partner SDK clients yet (x-not-in-sdk).

参数

名称位置类型说明
id
必填
pathstring

The request id.

Idempotency-Key
可选
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

请求体

GrowerDataRequestHandle (必填)

媒体类型: application/json

请求示例 · application/json
{
  "answer": "Your name no longer shows on the public fruit pages. The signed lot records never named you; the company keeps your name in its own registry for traceability.",
  "withdraw_public": true
}

响应

状态码类型说明
200GrowerDataRequest
application/json

The request, handled.

400Error
application/json

Invalid JSON, an unknown field, an answer outside the limits, withdraw_public for a request that is not an erasure or an objection, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client 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 while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No grower data request with this id in the selected company.

405Error
application/json

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

409Error
application/json

The request was already handled; or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

响应示例

响应 200 · application/json
{
  "id": 4,
  "grower": {
    "id": 12,
    "name": "Nguyễn Văn An"
  },
  "kind": "erasure",
  "channel": "paper",
  "text": "Please take my name off the fruit pages.",
  "received_on": "2026-09-28",
  "due_on": "2026-10-28",
  "overdue": false,
  "status": "handled",
  "created_at": 1790000000.5,
  "created_by": "user-7",
  "handled_at": 1790086400.5,
  "handled_by": "user-7",
  "answer": "Your name no longer shows on the public fruit pages. The signed lot records never named you; the company keeps your name in its own registry for traceability.",
  "withdrawn": [
    {
      "purpose": "public_name",
      "market": null
    }
  ]
}
响应 400 · application/json · answer
{
  "error": "invalid answer: required, text of at most 2000 characters",
  "code": "invalid_answer"
}
响应 400 · application/json · withdraw_public
{
  "error": "invalid withdraw_public: only for an erasure or an objection",
  "code": "invalid_withdraw_public"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 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"
}
响应 404 · application/json
{
  "error": "not found: 4",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · handled
{
  "error": "already handled: this request was already marked handled",
  "code": "already_handled"
}
响应 409 · application/json · idempotency
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/admin-units

Viet Nam's provinces, or one province's communes, by official code

无需身份验证 · getAdminUnits

#273: the official list of Viet Nam's administrative units, two levels since 1 July 2025: provinces (tỉnh, thành phố trung ương; 2-digit codes) and communes (xã, phường, đặc khu; 5-digit codes), as the National Statistics Office publishes them (Decision 19/2025/QĐ-TTg). Without province the answer lists the provinces; with province that province's communes. A commune belongs to the province the list names, never to the one its code's digits suggest. The list changes when a resolution merges, splits or renames units, so it is versioned: by default the version in force on Viet Nam's date today (Asia/Ho_Chi_Minh), or the one version names (an older version, to show an address coded from it). A code alone never names a unit: codes were reused across the 2025 reform, so a stored code always goes with its version. Unit names and kinds are the official Vietnamese ones in every language. Reference data, no personal data: anonymous and the same bytes for every visitor; cacheable for an hour with a strong ETag, and a matching If-None-Match answers 304. Not audited (a read). Rate limited per client before anything else (the /v1/public/* bucket: bursts of 60, then 20 a second). Not part of the partner SDK clients (x-not-in-sdk). Bounded work: in-memory lookups, no database statement.

参数

名称位置类型说明
province
可选
querystring

A province's 2-digit official code: answer its communes instead of the provinces. A code that is not a province of the version answers 404; anything but two ASCII digits 400.

version
可选
querystring

A catalog version, vn- and the date of its list (as every answer's version gives it): read that version instead of the one in force today. An unknown version answers 404; another shape 400.

If-None-Match
可选
headerstring

An ETag of an earlier answer (quoted), a list of them or *; compared weakly (RFC 9110). When it names the version's tag the answer is 304.

响应

状态码类型说明
200AdminUnitProvinces | AdminUnitCommunes
application/json

The provinces of the version (AdminUnitProvinces), or the communes of the province asked (AdminUnitCommunes; an empty list for a province without communes in that version).

304

Not modified: the request's If-None-Match names the version's ETag. No body.

400Error
application/json

bad_province: province is not two ASCII digits; bad_version: version is not vn- and a date; bad_request_id: the X-Request-Id header is malformed.

404Error
application/json

Not a province of the version, or not a version this server has. Every such request gets this same body and headers, held to the same minimum time; the code is never echoed. Answered so even when If-None-Match names the version's tag.

405Error
application/json

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

429Error
application/json

Too many requests from this client address (the per-IP token bucket the /v1/public/* routes share: bursts of 60, then 20 a second). The address is the CF-Connecting-IP a trusted proxy (AGRITRACE_TRUSTED_PROXIES) sends, else the socket peer. Nothing else was done; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

No catalog is installed on this server, or none of its versions is in force yet on Viet Nam's date (a version named by version is still served). Never cached; retry later.

响应头

名称状态码类型说明
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control200string

public, max-age=3600: browsers (and any shared cache that honours it) keep it an hour, then revalidate with the ETag. Never Set-Cookie.

ETag200string

The SHA-256 hex of the catalog version's data file, quoted (a strong ETag). Every answer of one version carries the same tag; a new version has another.

X-Request-Id304string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control304string

public, max-age=3600, as on the 200.

ETag304string

The version's ETag, as on the 200.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control400string

no-store: never cached.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control404string

public, max-age=0, s-maxage=60 (a 404 is never served stale). Never Set-Cookie.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control429string

no-store: a refusal is never cached.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control503string

no-store.

Retry-After503string

Seconds to wait before retrying.

响应示例

响应 200 · application/json · provinces The provinces (two of 34 shown)
{
  "version": "vn-2026-10-17",
  "valid_from": "2026-09-20",
  "source": {
    "publisher": "National Statistics Office of Viet Nam (Cục Thống kê, Ministry of Finance)",
    "url": "https://danhmuchanhchinh.nso.gov.vn/"
  },
  "provinces": [
    {
      "code": "01",
      "name": "Thành phố Hà Nội",
      "kind": "thành phố trung ương"
    },
    {
      "code": "82",
      "name": "Tỉnh Đồng Tháp",
      "kind": "tỉnh"
    }
  ]
}
响应 200 · application/json · communes The communes of province 82 (two shown)
{
  "version": "vn-2026-10-17",
  "valid_from": "2026-09-20",
  "source": {
    "publisher": "National Statistics Office of Viet Nam (Cục Thống kê, Ministry of Finance)",
    "url": "https://danhmuchanhchinh.nso.gov.vn/"
  },
  "province": {
    "code": "82",
    "name": "Tỉnh Đồng Tháp",
    "kind": "tỉnh"
  },
  "communes": [
    {
      "code": "28439",
      "name": "Phường Cai Lậy",
      "kind": "phường"
    },
    {
      "code": "28516",
      "name": "Xã Ngũ Hiệp",
      "kind": "xã"
    }
  ]
}
响应 400 · application/json
{
  "error": "bad province",
  "code": "bad_province"
}
响应 404 · application/json
{
  "error": "not found: admin-units",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
响应 503 · application/json
{
  "error": "administrative units catalog unavailable",
  "code": "administrative_units_catalog_unavailable"
}