labs
14 thao tác
GET /v1/labsLab partnersGET /v1/labs/{code}A lab partnerGET /v1/labs/{code}/keysA lab's signing keysPOST /v1/labs/{code}/keysRegister a lab signing keyPOST /v1/labs/{code}/keys/{kid}/revokeRevoke a lab signing keyGET /v1/lots/{lot}/residue-certificateA lot's residue certificateGET /v1/lab/samplesThe caller lab's sample assignmentsPOST /v1/lab/samples/{id}/resultsSubmit the signed lab report of an assigned samplingGET /v1/market-limitsMarket limits (maximum residue levels and bans)GET /v1/lab/samples/{id}One of the lab's assigned samplings, with its reportPOST /v1/lab/samples/{id}/entryEnter the lab results of an assigned sampling in the portalPUT /v1/lab/samples/{id}/report-pdfStore the PDF original of a lab reportGET /v1/labs/{code}/approvalsA lab's market approvalsGET /v1/lab/homeRead the lab portal's home
GET /v1/labs
Lab partners
Xác thực: cookie, bearer · listLabs
Labs ordered by code, with keyset pagination (at most 100 per page). Allowed for platform_admin (every lab) and for a lab user signed in with a session (its own lab only; another lab answers 404 like a missing one). A lab principal without a lab (an API token) is refused 403. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 100. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabPageapplication/json | One page of labs. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"code": "LAB-VN-118",
"name": "Phòng thử nghiệm mẫu",
"accreditation": "VILAS 118 (ISO/IEC 17025)",
"valid_to": "2027-12-31",
"status": "active",
"created_at": 1790000000.5,
"updated_at": 1790000000.5,
"in_force": true,
"accreditation_body": "BoA (VILAS)",
"accreditation_number": "VILAS 118",
"accreditation_scope": "Cadmium (ICP-MS) and auramine O (LC-MS/MS) in fresh fruit"
}
],
"next_cursor": null
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/labs/{code}
A lab partner
Xác thực: cookie, bearer · getLab
One lab. Allowed for platform_admin (every lab) and for a lab user signed in with a session (its own lab only; another lab answers 404 like a missing one). A lab principal without a lab (an API token) is refused 403. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | Labapplication/json | The lab. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lab, or a lab outside the caller's scope (a lab user's other labs). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"code": "LAB-VN-118",
"name": "Phòng thử nghiệm mẫu",
"accreditation": "VILAS 118 (ISO/IEC 17025)",
"valid_to": "2027-12-31",
"status": "active",
"created_at": 1790000000.5,
"updated_at": 1790000000.5,
"in_force": true,
"accreditation_body": "BoA (VILAS)",
"accreditation_number": "VILAS 118",
"accreditation_scope": "Cadmium (ICP-MS) and auramine O (LC-MS/MS) in fresh fruit"
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-118",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/labs/{code}/keys
A lab's signing keys
Xác thực: cookie, bearer · listLabKeys
Keys ordered by kid, with keyset pagination (at most 100 per page). Never returns key material, only fingerprints. Allowed for platform_admin (every lab) and for a lab user signed in with a session (its own lab only; another lab answers 404 like a missing one). A lab principal without a lab (an API token) is refused 403. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 100. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabKeyPageapplication/json | One page of keys. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lab, or a lab outside the caller's scope (a lab user's other labs). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"kid": "LAB-VN-118.2026",
"lab": "LAB-VN-118",
"status": "active",
"created_at": 1790000000.5,
"revoked_at": null,
"revoke_reason": null,
"revoked_by": null,
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"custody": "lab"
}
],
"next_cursor": null
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-118",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/labs/{code}/keys
Register a lab signing key
Xác thực: cookie, bearer · createLabKey
Registers an active EC P-256 public key of the lab. Key ids share one namespace with device and gateway keys: a taken or reserved kid is 409. Audited (lab_key.create; the PEM is never copied into the audit row). Allowed for platform_admin (every lab) and for a lab user signed in with a session (its own lab only; another lab answers 404 like a missing one). A lab principal without a lab (an API token) is refused 403.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
LabKeyCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"kid": "LAB-VN-118.2026",
"public_key_pem": "-----BEGIN PUBLIC KEY-----\n…\n-----END PUBLIC KEY-----\n"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | LabKeyapplication/json | The new key. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a bad kid or public key, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such lab, or a lab outside the caller's scope (a lab user's other labs). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The key id is taken (by any key) or reserved. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"kid": "LAB-VN-118.2026",
"lab": "LAB-VN-118",
"status": "active",
"created_at": 1790000000.5,
"revoked_at": null,
"revoke_reason": null,
"revoked_by": null,
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"custody": "lab"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_pem
{
"error": "invalid public_key_pem: an EC P-256 public key as PEM SubjectPublicKeyInfo",
"code": "invalid_public_key_pem"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-118",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/labs/{code}/keys/{kid}/revoke
Revoke a lab signing key
Xác thực: cookie, bearer · revokeLabKey
Marks the key revoked with its reason; a revoked key cannot be revoked again (the first reason and time stay). compromise also raises one high-severity lab_key_compromised platform alert. Audited (lab_key.revoke). Allowed for platform_admin (every lab) and for a lab user signed in with a session (its own lab only; another lab answers 404 like a missing one). A lab principal without a lab (an API token) is refused 403. Step-up (#87): a signed-in session of an account with two-step sign-in must have confirmed a code from its authenticator app (or a backup code) within the last 5 minutes and its password within the last 10 minutes, else 401 mfa_step_up_required before anything is done (no audit row): confirm both with POST /v1/auth/reauth, then repeat the request. A session of an account without two-step sign-in, API tokens and API clients are served as before.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
kidbắt buộc | path | string | Key id. |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
KeyRevoke (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"reason": "rotation"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabKeyapplication/json | The key after revocation. |
| 400 | Errorapplication/json | Invalid JSON, a reason other than rotation or compromise, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. Or a session of an account with two-step sign-in whose code was last confirmed more than 5 minutes ago, or its password more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). |
| 404 | Errorapplication/json | No such lab in the caller's scope, or no such key of the lab. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The key is already revoked. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"kid": "LAB-VN-118.2026",
"lab": "LAB-VN-118",
"status": "revoked",
"created_at": 1790000000.5,
"revoked_at": 1790086400.5,
"revoke_reason": "rotation",
"revoked_by": "lab@lab.example",
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"custody": "lab"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_reason
{
"error": "invalid reason: rotation or compromise",
"code": "invalid_reason"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-118",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · key_already_revoked
{
"error": "key already revoked",
"code": "key_already_revoked"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/lots/{lot}/residue-certificate
A lot's residue certificate
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: records_export · getLotResidueCertificate
#157: every analyte the lot's lab report tested, with its result, the limit of the lot's destination market, where that limit comes from and the verdict, for staff to hand to a buyer. The destination market (market_from) is the lot's shipment's destination once the lot is on a shipment, else the lot's own destination when it names a market, else the market of the lab report. For the report's own market each analyte keeps the limit copied onto its results when the lab report was stored; for another market the limit is that market's entry for the lot's product on the report's signed date (limits_on, Asia/Ho_Chi_Minh), else the market's default limit rule for pesticides (basis default_limit: Japan's and Korea's uniform 0.01 mg/kg, the EU's default of Regulation (EC) No 396/2005 Art. 18(1)(b), and in the United States a residue without a tolerance is not permitted). The default rule applies only to a pesticide that a source the platform has read shows the market sets no specific limit for in the lot's product; otherwise the analyte has no limit. It never applies to a contaminant such as cadmium or to auramine O. Limits are read on the report's signed date, so a limit the platform records later never judges a report signed before it takes effect. An analyte passes when every sample's result passes (a detection limit above a maximum cannot show compliance; a banned substance passes only when not detected); no_limit when the market sets none. required_analytes are the analytes the destination market's sampling rule for the lot's crop requires, missing_analytes those the lab did not test. The certificate's verdict: fail when an analyte fails, else incomplete when an analyte has no limit, a required analyte is missing or the lab key that signed the report has been revoked for compromise (report.key_revoked_for_compromise: the report then counts as unsigned, as on the public lot record, so it never earns pass), else pass; all null and empty while the lab has not reported. Never on the public record (owner decision: staff and buyers only; buyers have no account yet). An audited read (export.residue_certificate: the market, the verdict and the analyte counts), downloaded as an attachment (Content-Disposition), never cached. Allowed for tenant_admin, platform_admin acting for the tenant and auditor; operators and labs are refused; another tenant's lot answers like a missing one. An OAuth2 access token needs the records_export scope. Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
lotbắt buộc | path | string | Lot code (unique within the tenant). |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | ResidueCertificateapplication/json | The residue certificate (ResidueCertificate). |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (tenant_admin, platform_admin and auditor only) or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lot for this tenant: a lot of another tenant answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Content-Disposition | 200 | string | attachment; filename="residue-certificate-{lot}.json" |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"lot": "LO-260928-014",
"product": "durian",
"report": {
"report_no": "KN-260929-0071",
"lab": "LAB-VN-118",
"market": "CN",
"signed_at": 1790671200,
"received_at": 1790671260,
"key_custody": "lab",
"key_revoked_for_compromise": false
},
"market": "CN",
"market_from": "report",
"limits_on": "2026-09-29",
"verdict": "pass",
"analytes": [
{
"analyte": "cadmium",
"samples": 3,
"outcome": "measured",
"value": 0.018,
"lod": null,
"unit": "mg/kg",
"limit": {
"kind": "max",
"value": 0.05,
"unit": "mg/kg",
"source": "GB 2762-2022 National food safety standard: maximum levels of contaminants in foods, 4.2 cadmium, fresh fruit 0.05 mg/kg (published 2022-06-30, in force 2023-06-30)",
"basis": "market_limit"
},
"verdict": "pass"
},
{
"analyte": "auramine_o",
"samples": 3,
"outcome": "not_detected",
"value": null,
"lod": 0.001,
"unit": "mg/kg",
"limit": {
"kind": "banned",
"value": null,
"unit": "mg/kg",
"source": "Auramine O is a non-edible substance in China (Ministry of Health list, 2008): no level is permitted",
"basis": "market_limit"
},
"verdict": "pass"
}
],
"required_analytes": [
"cadmium",
"auramine_o"
],
"missing_analytes": []
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LO-260928-014",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/lab/samples
The caller lab's sample assignments
Xác thực: cookie, bearer · listLabAssignments
The samplings assigned to the caller's lab across every tenant, newest first, with keyset pagination (at most 50 per page): exporter, lot, facility, test scope and the fruits to collect. Allowed for a lab user signed in with a session (its lab only); every other role, and a lab principal without a lab (an API token), is refused 403. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 50. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabAssignmentPageapplication/json | One page of assignments. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"id": 41,
"exporter": "HTX Ngũ Hiệp",
"lot": {
"code": "LO-260928-014",
"product": "durian",
"variety": "Ri6",
"harvest_date": "2026-09-27"
},
"facility": {
"code": "VN-TGPH-021",
"name": "Cơ sở đóng gói Tân Phú",
"address": null,
"province": "Tiền Giang",
"district": "Cai Lậy"
},
"analytes": [
"cadmium",
"auramine_o"
],
"sample_count": 3,
"selected_at": 1790000000.5,
"samples": [
{
"k": 1,
"fruit": "Q-014-0017",
"status": "selected"
},
{
"k": 2,
"fruit": "Q-014-0062",
"status": "selected"
},
{
"k": 3,
"fruit": "Q-014-0109",
"status": "selected"
}
],
"report": null
}
],
"next_cursor": null
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/lab/samples/{id}/results
Submit the signed lab report of an assigned sampling
Xác thực: cookie, bearer · submitLabReport
The assigned lab's report for one of its samplings (the id of GET /v1/lab/samples): a document signed with an active key of that lab (LabReportSubmission). The server verifies the signature against the registered key, judges every result against the market's limits (China: cadmium at most 0.05 mg/kg, GB 2762-2022; auramine O banned), and any optional origin isotope result by its region match (a mismatch fails), and stores the report once: each drawn sample becomes passed or failed, and a failing report raises a high-severity lab_result_failed alert for the lot's tenant and puts the lot on hold on its public record. Audited (lab_report.submit). Allowed only for a lab user signed in with a session, for its own lab's samplings (another lab's sampling answers 404 like a missing one); every other role, and a lab principal without a lab (an API token), is refused 403, so a tenant can never submit a result for its own lot.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Sampling id, as |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
LabReportSubmission (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"v": 1,
"lab": "LAB-VN-118",
"sampling": 41,
"report_no": "KN-260929-0071",
"signed_at": "2026-09-29T15:40:00+07:00",
"report_sha256": "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f",
"results": [
{
"sample": 1,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS"
},
{
"sample": 1,
"analyte": "auramine_o",
"outcome": "not_detected",
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS"
},
{
"sample": 2,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS"
},
{
"sample": 2,
"analyte": "auramine_o",
"outcome": "not_detected",
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS"
},
{
"sample": 3,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS"
},
{
"sample": 3,
"analyte": "auramine_o",
"outcome": "not_detected",
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS"
}
],
"sig": {
"alg": "ES256",
"kid": "LAB-VN-118.2026",
"value": "oXJnReuBsgt-B5Q50XZIMc1f4ZyKrNbBmGQGqNG_AlzMknHMQA6jRzDDnLYMSR2xQ4fONFxUvflGduCSkSCgTg"
}
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | LabReportapplication/json | The stored report. |
| 400 | Errorapplication/json | Invalid JSON, a missing or unknown member, a result outside the sampling or an incomplete report, a bad value, unit or detection limit, a bad origin result (outcome, region), a signed_at before the draw or in the future, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session or token, or the report is unsigned or its signature does not verify with an active key of the assigned lab (unknown or revoked key, another lab's key, altered content). |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the sampling's company is leaving CropPath or has left, whatever company the lab user belongs to; nothing is stored. |
| 404 | Errorapplication/json | No such sampling, or one assigned to another lab. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The sampling already has a report (nothing is overwritten), the lab's report number is taken, or the lab is not in force. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"report_no": "KN-260929-0071",
"lab": "LAB-VN-118",
"kid": "LAB-VN-118.2026",
"key_custody": "lab",
"market": "CN",
"signed_at": 1790671200,
"report_sha256": "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f",
"passed": true,
"analytes": [
{
"analyte": "auramine_o",
"passed": true
},
{
"analyte": "cadmium",
"passed": true
}
],
"results": [
{
"sample": 1,
"analyte": "auramine_o",
"outcome": "not_detected",
"value": null,
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS",
"limit": {
"kind": "banned",
"value": null,
"unit": "mg/kg",
"source": "Auramine O is a non-edible substance in China (Ministry of Health list, 2008): no level is permitted; GACC requires an auramine O test report with every durian shipment since 2025-01-10 (https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports)"
},
"passed": true
},
{
"sample": 1,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS",
"limit": {
"kind": "max",
"value": 0.05,
"unit": "mg/kg",
"source": "GB 2762-2022 National food safety standard: maximum levels of contaminants in foods, 4.2 cadmium, fresh fruit 0.05 mg/kg (published 2022-06-30, in force 2023-06-30)"
},
"passed": true
},
{
"sample": 2,
"analyte": "auramine_o",
"outcome": "not_detected",
"value": null,
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS",
"limit": {
"kind": "banned",
"value": null,
"unit": "mg/kg",
"source": "Auramine O is a non-edible substance in China (Ministry of Health list, 2008): no level is permitted; GACC requires an auramine O test report with every durian shipment since 2025-01-10 (https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports)"
},
"passed": true
},
{
"sample": 2,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS",
"limit": {
"kind": "max",
"value": 0.05,
"unit": "mg/kg",
"source": "GB 2762-2022 National food safety standard: maximum levels of contaminants in foods, 4.2 cadmium, fresh fruit 0.05 mg/kg (published 2022-06-30, in force 2023-06-30)"
},
"passed": true
},
{
"sample": 3,
"analyte": "auramine_o",
"outcome": "not_detected",
"value": null,
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS",
"limit": {
"kind": "banned",
"value": null,
"unit": "mg/kg",
"source": "Auramine O is a non-edible substance in China (Ministry of Health list, 2008): no level is permitted; GACC requires an auramine O test report with every durian shipment since 2025-01-10 (https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports)"
},
"passed": true
},
{
"sample": 3,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS",
"limit": {
"kind": "max",
"value": 0.05,
"unit": "mg/kg",
"source": "GB 2762-2022 National food safety standard: maximum levels of contaminants in foods, 4.2 cadmium, fresh fruit 0.05 mg/kg (published 2022-06-30, in force 2023-06-30)"
},
"passed": true
}
],
"origin": [],
"submitted_by": "lab@lab.example",
"received_at": 1790671260.5,
"report_pdf": null
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · incomplete
{
"error": "incomplete results: no cadmium result for sample 3 (1 missing)",
"code": "incomplete_results"
}Phản hồi 400 · application/json · unit
{
"error": "invalid results[0].unit: mg/kg",
"code": "invalid_results_0_unit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json · token
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 401 · application/json · signature
{
"error": "signature not verified: sign the report with an active key of the assigned lab",
"code": "signature_not_verified"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "not found: 41",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · reported
{
"error": "sampling already reported",
"code": "sampling_already_reported"
}Phản hồi 409 · application/json · number
{
"error": "report number taken",
"code": "report_number_taken"
}Phản hồi 409 · application/json · lab
{
"error": "lab not in force: suspended, or its accreditation expired before the signed date",
"code": "lab_not_in_force"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/market-limits
Market limits (maximum residue levels and bans)
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: market_limit_read · listMarketLimits
Every entry by id, one page (limit, default 100, at most 200; cursor from the previous page), each with its status on today. Platform data, the same for every tenant. Allowed for every role. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
limitkhông bắt buộc | query | integer | 1 to 200 (default 100). |
cursorkhông bắt buộc | query | string | The previous page's |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | MarketLimitPageapplication/json | One page of entries. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (a principal without a role), tenant not allowed (X-Tenant). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"id": 1,
"market": "CN",
"product": "durian",
"analyte": "cadmium",
"kind": "max",
"value": 0.05,
"unit": "mg/kg",
"valid_from": "2023-06-30",
"source": "GB 2762-2022 National food safety standard: maximum levels of contaminants in foods, 4.2 cadmium, fresh fruit 0.05 mg/kg (published 2022-06-30, in force 2023-06-30)",
"created_at": 1790000000.5,
"created_by": "migration",
"status": "in_force"
},
{
"id": 2,
"market": "CN",
"product": "durian",
"analyte": "auramine_o",
"kind": "banned",
"value": null,
"unit": "mg/kg",
"valid_from": "2025-01-10",
"source": "Auramine O is a non-edible substance in China (Ministry of Health list, 2008): no level is permitted; GACC requires an auramine O test report with every durian shipment since 2025-01-10 (https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports)",
"created_at": 1790000000.5,
"created_by": "migration",
"status": "in_force"
}
],
"today": "2026-09-30",
"next_cursor": null
}Phản hồi 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/lab/samples/{id}
One of the lab's assigned samplings, with its report
Xác thực: cookie, bearer · getLabAssignment
A7 (#73): the lab portal's sampling page. One sampling assigned to the caller's lab, with its samples, its full report once stored (LabReport, with the custody of the key that signed it) and the lab's active server-held portal key. Allowed only for a lab user signed in with a session; another lab's sampling answers 404 like a missing one; every other role, and a lab principal without a lab (an API token), is refused 403.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Sampling id, as |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabAssignmentDetailapplication/json | The sampling. |
| 400 | Errorapplication/json | A bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such sampling, or one assigned to another lab. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"id": 41,
"exporter": "HTX Ngũ Hiệp",
"lot": {
"code": "LO-260928-014",
"product": "durian",
"variety": "Ri6",
"harvest_date": "2026-09-27"
},
"facility": {
"code": "VN-TGPH-021",
"name": "Cơ sở đóng gói Tân Phú",
"address": null,
"province": "Tiền Giang",
"district": "Cai Lậy"
},
"analytes": [
"cadmium",
"auramine_o"
],
"sample_count": 3,
"selected_at": 1790000000.5,
"samples": [
{
"k": 1,
"fruit": "Q-014-0017",
"status": "selected"
},
{
"k": 2,
"fruit": "Q-014-0062",
"status": "selected"
},
{
"k": 3,
"fruit": "Q-014-0109",
"status": "selected"
}
],
"report": null,
"portal_key": {
"kid": "LAB-VN-118.portal"
}
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: 41",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/lab/samples/{id}/entry
Enter the lab results of an assigned sampling in the portal
Xác thực: cookie, bearer · enterLabReport
A7 (#73): the lab portal's result form for one of the lab's samplings. The server builds the report document from the entry (LabPortalEntry: version 1, the lab, the sampling, the server's time as signed_at), signs it with the lab's active server-held key (custody server, generated by POST /v1/labs/{code}/portal-key) and stores it exactly as POST /v1/lab/samples/{id}/results stores an uploaded signed report (verification, market limits, sample statuses, the lab_result_failed alert and lab hold). The report's key_custody is server: the public record and the credential state that the platform, not the lab, holds the key, and the lab step never counts the result as signed by the accredited lab (ADR 0001: at most Cross-checked). Audited (lab_report.enter). Allowed only for a lab user signed in with a session, for its own lab's samplings (another lab's sampling answers 404 like a missing one); every other role, and a lab principal without a lab (an API token), is refused 403.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Sampling id, as |
Idempotency-Keykhông bắt buộc | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Nội dung yêu cầu
LabPortalEntry (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"report_no": "KN-260929-0071",
"report_sha256": "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f",
"results": [
{
"sample": 1,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS"
},
{
"sample": 1,
"analyte": "auramine_o",
"outcome": "not_detected",
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS"
},
{
"sample": 2,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS"
},
{
"sample": 2,
"analyte": "auramine_o",
"outcome": "not_detected",
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS"
},
{
"sample": 3,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS"
},
{
"sample": 3,
"analyte": "auramine_o",
"outcome": "not_detected",
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS"
}
]
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 201 | LabReportapplication/json | The stored report. |
| 400 | Errorapplication/json | Invalid JSON, a missing or unknown member, a result outside the sampling or an incomplete report, a bad value, unit or detection limit, a bad origin result (outcome, region), a signed_at before the draw or in the future, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the sampling's company is leaving CropPath or has left, whatever company the lab user belongs to; nothing is stored. |
| 404 | Errorapplication/json | No such sampling, or one assigned to another lab. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The lab holds no active server-held key, the sampling already has a report (nothing is overwritten), the lab's report number is taken, or the lab is not in force. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | The server cannot read the lab's server-held key: no key-encryption key is configured (AGRITRACE_ISSUER_KEK) or its file does not decrypt; nothing changed. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
Ví dụ phản hồi
Phản hồi 201 · application/json
{
"report_no": "KN-260929-0071",
"lab": "LAB-VN-118",
"kid": "LAB-VN-118.portal",
"key_custody": "server",
"market": "CN",
"signed_at": 1790671200,
"report_sha256": "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f",
"passed": true,
"analytes": [
{
"analyte": "auramine_o",
"passed": true
},
{
"analyte": "cadmium",
"passed": true
}
],
"results": [
{
"sample": 1,
"analyte": "auramine_o",
"outcome": "not_detected",
"value": null,
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS",
"limit": {
"kind": "banned",
"value": null,
"unit": "mg/kg",
"source": "Auramine O is a non-edible substance in China (Ministry of Health list, 2008): no level is permitted; GACC requires an auramine O test report with every durian shipment since 2025-01-10 (https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports)"
},
"passed": true
},
{
"sample": 1,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS",
"limit": {
"kind": "max",
"value": 0.05,
"unit": "mg/kg",
"source": "GB 2762-2022 National food safety standard: maximum levels of contaminants in foods, 4.2 cadmium, fresh fruit 0.05 mg/kg (published 2022-06-30, in force 2023-06-30)"
},
"passed": true
},
{
"sample": 2,
"analyte": "auramine_o",
"outcome": "not_detected",
"value": null,
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS",
"limit": {
"kind": "banned",
"value": null,
"unit": "mg/kg",
"source": "Auramine O is a non-edible substance in China (Ministry of Health list, 2008): no level is permitted; GACC requires an auramine O test report with every durian shipment since 2025-01-10 (https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports)"
},
"passed": true
},
{
"sample": 2,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS",
"limit": {
"kind": "max",
"value": 0.05,
"unit": "mg/kg",
"source": "GB 2762-2022 National food safety standard: maximum levels of contaminants in foods, 4.2 cadmium, fresh fruit 0.05 mg/kg (published 2022-06-30, in force 2023-06-30)"
},
"passed": true
},
{
"sample": 3,
"analyte": "auramine_o",
"outcome": "not_detected",
"value": null,
"unit": "mg/kg",
"lod": 0.001,
"method": "LC-MS/MS",
"limit": {
"kind": "banned",
"value": null,
"unit": "mg/kg",
"source": "Auramine O is a non-edible substance in China (Ministry of Health list, 2008): no level is permitted; GACC requires an auramine O test report with every durian shipment since 2025-01-10 (https://www.producereport.com/article/vietnamese-durian-exports-china-halted-over-missing-test-reports)"
},
"passed": true
},
{
"sample": 3,
"analyte": "cadmium",
"outcome": "measured",
"value": 0.018,
"unit": "mg/kg",
"lod": 0.002,
"method": "ICP-MS",
"limit": {
"kind": "max",
"value": 0.05,
"unit": "mg/kg",
"source": "GB 2762-2022 National food safety standard: maximum levels of contaminants in foods, 4.2 cadmium, fresh fruit 0.05 mg/kg (published 2022-06-30, in force 2023-06-30)"
},
"passed": true
}
],
"origin": [],
"submitted_by": "lab@lab.example",
"received_at": 1790671260.5,
"report_pdf": null
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · incomplete
{
"error": "incomplete results: no cadmium result for sample 3 (1 missing)",
"code": "incomplete_results"
}Phản hồi 400 · application/json · unit
{
"error": "invalid results[0].unit: mg/kg",
"code": "invalid_results_0_unit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "not found: 41",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · reported
{
"error": "sampling already reported",
"code": "sampling_already_reported"
}Phản hồi 409 · application/json · number
{
"error": "report number taken",
"code": "report_number_taken"
}Phản hồi 409 · application/json · lab
{
"error": "lab not in force: suspended, or its accreditation expired before the signed date",
"code": "lab_not_in_force"
}Phản hồi 409 · application/json · no_portal_key
{
"error": "no portal key: the lab holds no active server-held key to sign portal entries",
"code": "no_portal_key"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Phản hồi 503 · application/json
{
"error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
"code": "issuer_keys_unavailable"
}PUT /v1/lab/samples/{id}/report-pdf
Store the PDF original of a lab report
Xác thực: cookie, bearer · attachLabReportPdf
A7 (#73, owner decision 4): the PDF original of the report of one of the lab's samplings, sent after the report was stored by either POST /v1/lab/samples/{id}/results or POST /v1/lab/samples/{id}/entry. The body is the PDF itself. Content-Type must be application/pdf (parameters ignored) and the bytes must start with %PDF-. The body is at most 1 MiB and must hash to the report's report_sha256. The file is stored once as a staff-only attachment owned by the sampling's tenant: only its tenant-wide staff read the bytes with GET /v1/attachments/{sha256}, a facility-scoped grant does not. The report links it as report_pdf. Nothing public changes: the public record keeps lab.report_url null and never names the file. It changes no verdict and no trust tier. A repeat of a stored PDF answers 200 and changes nothing, but its bytes are still checked against the report. Audited (lab_report.attach_pdf: the hash, media type and size, never the bytes). Allowed only for a lab user, for its own lab's samplings (another lab's sampling answers 404 like a missing one); every other role, and a lab principal without a lab (an API token), is refused 403.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Sampling id, as |
Nội dung yêu cầu
string (bắt buộc)
Kiểu nội dung: application/pdf
Ví dụ yêu cầu · application/pdf
%PDF-1.7 ... (binary PDF bytes)Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | AttachmentStoredapplication/json | The sampling's tenant already holds this PDF; nothing changed. |
| 201 | AttachmentStoredapplication/json | Stored and linked from the report as |
| 400 | Errorapplication/json | A missing or malformed Content-Length, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only when the sampling's company is leaving CropPath or has left, whatever company the lab user belongs to; nothing is stored. |
| 404 | Errorapplication/json | No such sampling, or one assigned to another lab. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The sampling has no report yet: the PDF follows the report. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 415 | Errorapplication/json | Not declared as |
| 422 | Errorapplication/json | The body does not hash to the report's |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 201 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 415 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"sha256": "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f",
"media_type": "application/pdf",
"size": 182344
}Phản hồi 201 · application/json
{
"sha256": "5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f",
"media_type": "application/pdf",
"size": 182344
}Phản hồi 400 · application/json · bad_content_length
{
"error": "bad content length",
"code": "bad_content_length"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Phản hồi 404 · application/json
{
"error": "not found: 41",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json
{
"error": "no report yet: store the sampling's report before its PDF",
"code": "no_report_yet"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 415 · application/json · unsupported_media_type
{
"error": "unsupported media type",
"code": "unsupported_media_type"
}Phản hồi 415 · application/json · content_does_not_match_the_media_type
{
"error": "content does not match the media type",
"code": "content_does_not_match_the_media_type"
}Phản hồi 422 · application/json
{
"error": "report pdf mismatch: the file does not hash to the report's report_sha256",
"code": "report_pdf_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/labs/{code}/approvals
A lab's market approvals
Xác thực: cookie, bearer · listLabApprovals
#154: every market approval of the lab (at most 100, one page), each with whether it is in force today. Allowed for platform_admin (every lab) and for a lab user signed in with a session (its own lab only; another lab answers 404 like a missing one). A lab principal without a lab (an API token) is refused 403. Not audited (a read).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
codebắt buộc | path | string | Lab code, e.g. LAB-VN-118. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabApprovalListapplication/json | The lab's approvals. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such lab, or a lab outside the caller's scope (a lab user's other labs). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"items": [
{
"id": 7,
"lab": "LAB-VN-118",
"market": "CN",
"approving_body": "Plant Protection Department (MAE)",
"reference": "List of approved labs, 2026-08-07, No. 17",
"analytes": [
"auramine_o",
"cadmium"
],
"valid_from": "2026-08-07",
"valid_to": "2027-08-06",
"source_url": "https://example.org/approved-labs-2026",
"evidence_sha256": "9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9f",
"status": "active",
"in_force": true,
"created_at": 1790000000.5,
"created_by": "admin@platform.example",
"updated_at": 1790000000.5,
"updated_by": "admin@platform.example"
}
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: LAB-VN-118",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/lab/home
Read the lab portal's home
Xác thực: cookie · getLabHome
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
#286. For the caller's lab: whether it can sign (its status, accreditation, market approvals and keys) and its work, among its newest 500 samplings across every exporter: the samplings waiting for results, oldest first, with how many were drawn more than target_hours (48) ago; the reports stored without their PDF original; the reports stored in the last 7 days and how many failed. Never another lab's samplings. Computed at most every 30 seconds per lab: the server serves one answer for max_age_s seconds after generated_at. Read-only and not audited (a read). no-store. Allowed for a lab user through a signed-in session only (its lab only): an API token, an API client or the legacy token is refused (403), and so is every other role. Not part of the partner SDK clients (x-not-in-sdk): an operation of the lab portal's home.
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 200 | LabHomeapplication/json | The lab's home. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (only a lab user of a lab, through a signed-in session), tenant not allowed (X-Tenant), two-factor required. |
| 404 | Errorapplication/json | The caller's lab is not in the registry. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"lab": {
"code": "LAB-VN-118",
"name": "Phòng kiểm nghiệm 118",
"status": "active",
"accreditation": "VILAS 118",
"valid_to": "2027-03-31",
"approvals": [
{
"market": "CN",
"status": "active",
"valid_to": "2027-12-31"
}
],
"keys": {
"lab_held": 1,
"server_held": true
}
},
"generated_at": "2026-10-18T02:12:40Z",
"max_age_s": 30,
"window": {
"samplings": 500,
"full": false
},
"target_hours": 48,
"sections": {
"waiting": {
"state": "ok",
"count": 3,
"past_target": 1,
"items": [
{
"id": 71,
"lot": "LO-260927-009",
"exporter": "HTX Đắk Lắk",
"sample_count": 3,
"analytes": [
"cadmium",
"auramine_o"
],
"selected_at": "2026-10-16T03:00:00Z"
}
]
},
"pdf_missing": {
"state": "ok",
"count": 1,
"items": [
{
"id": 68,
"report_no": "KN-261015-0031",
"received_at": "2026-10-15T08:40:00Z"
}
]
},
"sent": {
"state": "ok",
"count_7d": 4,
"failed_7d": 0,
"items": [
{
"id": 69,
"lot": "LO-260925-004",
"report_no": "KN-261016-0040",
"passed": true,
"received_at": "2026-10-16T07:10:00Z"
}
]
}
}
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}Phản hồi 404 · application/json
{
"error": "not found: lab",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}