CropPath cho nhà phát triển

Tài liệu API

shipping

9 thao tác

POST /v1/shipments

Create a shipment

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · createShipment

A new open shipment departing one of the tenant's facilities: container (ISO 6346), border gate, destination market, reefer setpoint and tolerance, and the independent temperature logger, a registered device of the departure facility (its keys stay in the device registry). Audited (shipment.create). Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only shipments departing its facilities); auditor and lab are refused.

Tham số

TênVị tríKiểuMô tả
Idempotency-Key
không bắt buộc
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.

Nội dung yêu cầu

ShipmentCreate (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "code": "SH-260930-01",
  "facility": "VN-TGPH-021",
  "container": "MSKU1234565",
  "border_gate": "Hữu Nghị",
  "destination": "CN",
  "setpoint_c": 13,
  "logger": {
    "device_id": "reefer-logger-0731"
  }
}

Phản hồi

Mã trạng tháiKiểuMô tả
201Shipment
application/json

The new shipment.

400Error
application/json

Invalid JSON, an unknown or missing field, a bad value, a facility outside the tenant and scope, or a logger that is not a temperature logger of the registry at that facility; 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).

405Error
application/json

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

409Error
application/json

The tenant already has a shipment with this code, or the logger is inactive. 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). SELF-2-8 (#197): or the facility is a company's proposal CropPath has not approved yet.

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.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
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.

Ví dụ phản hồi

Phản hồi 201 · application/json
{
  "code": "SH-260930-01",
  "facility": "VN-TGPH-021",
  "container": "MSKU1234565",
  "border_gate": "Hữu Nghị",
  "destination": "CN",
  "setpoint_c": 13,
  "tolerance_c": 2,
  "logger_interval_minutes": 15,
  "logger": {
    "device_id": "reefer-logger-0731"
  },
  "status": "open",
  "created_by": "shipper@coop.example",
  "created_at": 1790040000,
  "departed_by": null,
  "departed_at": null,
  "lots": [],
  "logger_check": {
    "status": "missing",
    "readings": 0,
    "considered": 0,
    "first_at": null,
    "last_at": null,
    "min_c": null,
    "max_c": null,
    "seal_at": null,
    "until": null,
    "gap_count": 0,
    "gaps": [],
    "out_of_range_count": 0,
    "out_of_range": [],
    "complete": false,
    "within_setpoint": false
  },
  "national_portal": {
    "rows": 0,
    "delivered": 0,
    "pending": 0,
    "failing": 0,
    "filed": false
  },
  "consignee": null,
  "documents": [],
  "paperwork": {
    "required": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "missing": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "complete": false
  },
  "amendments": []
}
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_container
{
  "error": "invalid container: an ISO 6346 container number with a valid check digit",
  "code": "invalid_container"
}
Phản hồi 400 · application/json · invalid_destination
{
  "error": "invalid destination: one of CN",
  "code": "invalid_destination"
}
Phản hồi 400 · application/json · unknown_facility
{
  "error": "unknown facility",
  "code": "unknown_facility"
}
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_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf_token_missing_or_invalid
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json · shipment_code_already_exists
{
  "error": "shipment code already exists",
  "code": "shipment_code_already_exists"
}
Phản hồi 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Phản hồi 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Phản hồi 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Phản hồi 409 · application/json · facility_not_approved
{
  "error": "facility not approved",
  "code": "facility_not_approved"
}
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/shipments/{code}

A shipment, its lots, logger check and filing state

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_read · getShipment

The shipment with its linked lots (seal recorded at the link against the current one), the logger cross-check and the national-portal filing state from the outbound backlog. Allowed for platform_admin, tenant_admin and auditor (the whole tenant) and for an operator signed in with a session (only shipments departing its facilities). Not audited (a read).

Tham số

TênVị tríKiểuMô tả
code
bắt buộc
pathstring

Shipment code (unique within the tenant).

Phản hồi

Mã trạng tháiKiểuMô tả
200Shipment
application/json

The shipment.

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 shipment for this tenant: a shipment of another tenant, or departing a facility 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.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
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.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "code": "SH-260930-01",
  "facility": "VN-TGPH-021",
  "container": "MSKU1234565",
  "border_gate": "Hữu Nghị",
  "destination": "CN",
  "setpoint_c": 13,
  "tolerance_c": 2,
  "logger_interval_minutes": 15,
  "logger": {
    "device_id": "reefer-logger-0731"
  },
  "status": "departed",
  "created_by": "shipper@coop.example",
  "created_at": 1790040000,
  "departed_by": "shipper@coop.example",
  "departed_at": 1790042400,
  "lots": [
    {
      "lot": "LO-260928-014",
      "status": "shipped",
      "cartons": 41,
      "seal_no": "0492117",
      "sealed_at": 1790040600,
      "current_seal_no": "0492117",
      "seal_matches": true,
      "added_by": "shipper@coop.example",
      "added_at": 1790041000
    }
  ],
  "logger_check": {
    "status": "matched",
    "readings": 9,
    "considered": 9,
    "first_at": 1790040600,
    "last_at": 1790047800,
    "min_c": 12.6,
    "max_c": 13.4,
    "seal_at": 1790040600,
    "until": 1790042400,
    "gap_count": 0,
    "gaps": [],
    "out_of_range_count": 0,
    "out_of_range": [],
    "complete": true,
    "within_setpoint": true
  },
  "national_portal": {
    "rows": 386,
    "delivered": 386,
    "pending": 0,
    "failing": 0,
    "filed": true
  },
  "consignee": null,
  "documents": [],
  "paperwork": {
    "required": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "missing": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "complete": false
  },
  "amendments": []
}
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_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 404 · application/json
{
  "error": "not found: SH-260930-01",
  "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/shipments/{code}/lots

Put a packed lot on a shipment

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · addShipmentLot

Links a packed lot of the shipment's departure facility, whole: every carton of the lot goes on the shipment, with the lot's current seal number and its time. A lot ships once. Audited (shipment.lot.add). Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only shipments departing its facilities); auditor and lab are refused.

Tham số

TênVị tríKiểuMô tả
code
bắt buộc
pathstring

Shipment code (unique within the tenant).

Idempotency-Key
không bắt buộc
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.

Nội dung yêu cầu

ShipmentLotLink (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "lot": "LO-260928-014"
}

Phản hồi

Mã trạng tháiKiểuMô tả
201Shipment
application/json

The shipment with the lot.

400Error
application/json

Invalid JSON or a body that is not exactly a lot code; 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 shipment or lot for this tenant (another tenant's, or outside an operator's facilities).

405Error
application/json

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

409Error
application/json

The shipment departed or is full, or the lot is at another facility, not packed, has a failed lab result or is already on a shipment. 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.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
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.

Ví dụ phản hồi

Phản hồi 201 · application/json
{
  "code": "SH-260930-01",
  "facility": "VN-TGPH-021",
  "container": "MSKU1234565",
  "border_gate": "Hữu Nghị",
  "destination": "CN",
  "setpoint_c": 13,
  "tolerance_c": 2,
  "logger_interval_minutes": 15,
  "logger": {
    "device_id": "reefer-logger-0731"
  },
  "status": "open",
  "created_by": "shipper@coop.example",
  "created_at": 1790040000,
  "departed_by": null,
  "departed_at": null,
  "lots": [
    {
      "lot": "LO-260928-014",
      "status": "packed",
      "cartons": 41,
      "seal_no": "0492117",
      "sealed_at": 1790040600,
      "current_seal_no": "0492117",
      "seal_matches": true,
      "added_by": "shipper@coop.example",
      "added_at": 1790041000
    }
  ],
  "logger_check": {
    "status": "missing",
    "readings": 0,
    "considered": 0,
    "first_at": null,
    "last_at": null,
    "min_c": null,
    "max_c": null,
    "seal_at": null,
    "until": null,
    "gap_count": 0,
    "gaps": [],
    "out_of_range_count": 0,
    "out_of_range": [],
    "complete": false,
    "within_setpoint": false
  },
  "national_portal": {
    "rows": 0,
    "delivered": 0,
    "pending": 0,
    "failing": 0,
    "filed": false
  },
  "consignee": null,
  "documents": [],
  "paperwork": {
    "required": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "missing": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "complete": false
  },
  "amendments": []
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · invalid_body
{
  "error": "invalid body: exactly lot",
  "code": "invalid_body"
}
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_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf_token_missing_or_invalid
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · 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: 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 409 · application/json · shipment_is_departed
{
  "error": "shipment is departed",
  "code": "shipment_is_departed"
}
Phản hồi 409 · application/json · lot_is_at_another_facility
{
  "error": "lot is at another facility: a shipment carries lots of its departure facility",
  "code": "lot_is_at_another_facility"
}
Phản hồi 409 · application/json · lot_is_closed
{
  "error": "lot is closed: only a packed lot ships",
  "code": "lot_is_closed"
}
Phản hồi 409 · application/json · lot_failed_its_lab_test
{
  "error": "lot failed its lab test: a lot with a failed lab result does not ship",
  "code": "lot_failed_its_lab_test"
}
Phản hồi 409 · application/json · lot_already_on_shipment_sh_260930_01
{
  "error": "lot already on shipment SH-260930-01",
  "code": "lot_already_on_shipment_sh_260930_01"
}
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/shipments/{code}/logger-readings

Upload a signed logger temperature series

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · uploadShipmentLoggerReadings

Stores a temperature series of the shipment's independent logger, signed with an active key of the device registry owned by the shipment's logger while that logger is active (a single-trip logger delivers its series after the trip, so it comes as signed uploads, not envelopes; several uploads merge into the shipment's one series by instant). A document that does not verify, names another shipment or logger, or holds a reading later than now is refused and stored nowhere. A stored instant is never overwritten: the same value is skipped, another value is a 409; the same signed content twice is a 409. Then the logger cross-check is recomputed. Audited (shipment.logger.upload). Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only shipments departing its facilities); auditor and lab are refused.

Tham số

TênVị tríKiểuMô tả
code
bắt buộc
pathstring

Shipment code (unique within the tenant).

Idempotency-Key
không bắt buộc
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.

Nội dung yêu cầu

LoggerSeries (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "logger": "reefer-logger-0731",
  "shipment": "SH-260930-01",
  "capability": "air.temperature",
  "unit": "Cel",
  "readings": [
    {
      "time": "2026-09-30T08:30:00+07:00",
      "value": 13.1
    },
    {
      "time": "2026-09-30T08:45:00+07:00",
      "value": 12.9
    }
  ],
  "sig": {
    "alg": "ES256",
    "kid": "reefer-logger-0731.k1",
    "value": "MEUCIQ..."
  }
}

Phản hồi

Mã trạng tháiKiểuMô tả
201Shipment
application/json

The shipment with the recomputed logger check and the upload.

400Error
application/json

Invalid JSON, a malformed series, a series that names another shipment or logger, or a signature that does not verify with an active registry key of the shipment's active logger; 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 shipment for this tenant: a shipment of another tenant, or departing a facility 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 series was uploaded already, a stored instant has another value, or the shipment would hold too many readings. 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.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
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.

Ví dụ phản hồi

Phản hồi 201 · application/json
{
  "code": "SH-260930-01",
  "facility": "VN-TGPH-021",
  "container": "MSKU1234565",
  "border_gate": "Hữu Nghị",
  "destination": "CN",
  "setpoint_c": 13,
  "tolerance_c": 2,
  "logger_interval_minutes": 15,
  "logger": {
    "device_id": "reefer-logger-0731"
  },
  "status": "departed",
  "created_by": "shipper@coop.example",
  "created_at": 1790040000,
  "departed_by": "shipper@coop.example",
  "departed_at": 1790042400,
  "lots": [
    {
      "lot": "LO-260928-014",
      "status": "shipped",
      "cartons": 41,
      "seal_no": "0492117",
      "sealed_at": 1790040600,
      "current_seal_no": "0492117",
      "seal_matches": true,
      "added_by": "shipper@coop.example",
      "added_at": 1790041000
    }
  ],
  "logger_check": {
    "status": "matched",
    "readings": 9,
    "considered": 9,
    "first_at": 1790040600,
    "last_at": 1790047800,
    "min_c": 12.6,
    "max_c": 13.4,
    "seal_at": 1790040600,
    "until": 1790042400,
    "gap_count": 0,
    "gaps": [],
    "out_of_range_count": 0,
    "out_of_range": [],
    "complete": true,
    "within_setpoint": true
  },
  "national_portal": {
    "rows": 386,
    "delivered": 386,
    "pending": 0,
    "failing": 0,
    "filed": true
  },
  "upload": {
    "id": 1,
    "readings": 9,
    "added": 9
  },
  "consignee": null,
  "documents": [],
  "paperwork": {
    "required": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "missing": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "complete": false
  },
  "amendments": []
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · invalid_document
{
  "error": "invalid document: exactly logger, shipment, capability, unit, readings and sig",
  "code": "invalid_document"
}
Phản hồi 400 · application/json · invalid_signature
{
  "error": "invalid signature",
  "code": "invalid_signature"
}
Phản hồi 400 · application/json · invalid_readings
{
  "error": "invalid readings: a reading is later than now",
  "code": "invalid_readings"
}
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_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf_token_missing_or_invalid
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · 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: SH-260930-01",
  "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 · logger_series_already_uploaded
{
  "error": "logger series already uploaded",
  "code": "logger_series_already_uploaded"
}
Phản hồi 409 · application/json · reading_differs
{
  "error": "reading differs: a stored instant has another value",
  "code": "reading_differs"
}
Phản hồi 409 · application/json · too_many_readings
{
  "error": "too many readings: a shipment holds at most 8640",
  "code": "too_many_readings"
}
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/shipments/{code}/depart

The ship event: the shipment departs

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · departShipment

The open shipment departs now: its lots move from packed to shipped in the same transaction and the logger cross-check is recomputed up to the departure. A lot whose lab report failed after it was linked stops the departure (409 lot_failed_its_lab_test, #138). A shipment lacking its destination market's required papers does not depart (409 missing_paperwork, naming the missing items; CN: the consignee, the phytosanitary certificate and the test report, #153). The departure also takes each departing lot's carton label print check (ADR 0001, #176): if any of the lot's cartons has no carton label print recorded after its contents were last set, or the lot has no carton, the lot's packing step is lowered to Self-declared (trust reason carton_labels_not_printed, in GET /v1/lots/{lot}/trust and the public lot record's journey), and the lot's tier with it; a passed check changes nothing, a print recorded after the departure lifts nothing, and the departure is never refused for it. Tenant-entered (no signed ship envelope is emitted: the backend holds no private key). Audited (shipment.depart). Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only shipments departing its facilities); auditor and lab are refused.

Tham số

TênVị tríKiểuMô tả
code
bắt buộc
pathstring

Shipment code (unique within the tenant).

Idempotency-Key
không bắt buộc
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.

Nội dung yêu cầu

ShipmentDepart (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{}

Phản hồi

Mã trạng tháiKiểuMô tả
200Shipment
application/json

The departed shipment.

400Error
application/json

Invalid JSON or a non-empty body; 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 shipment for this tenant: a shipment of another tenant, or departing a facility 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 shipment departed already, carries no lot, a lot is no longer packed or has a failed lab result (#138), or the destination market's required papers are missing (#153). 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.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
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.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "code": "SH-260930-01",
  "facility": "VN-TGPH-021",
  "container": "MSKU1234565",
  "border_gate": "Hữu Nghị",
  "destination": "CN",
  "setpoint_c": 13,
  "tolerance_c": 2,
  "logger_interval_minutes": 15,
  "logger": {
    "device_id": "reefer-logger-0731"
  },
  "status": "departed",
  "created_by": "shipper@coop.example",
  "created_at": 1790040000,
  "departed_by": "shipper@coop.example",
  "departed_at": 1790042400,
  "lots": [
    {
      "lot": "LO-260928-014",
      "status": "shipped",
      "cartons": 41,
      "seal_no": "0492117",
      "sealed_at": 1790040600,
      "current_seal_no": "0492117",
      "seal_matches": true,
      "added_by": "shipper@coop.example",
      "added_at": 1790041000
    }
  ],
  "logger_check": {
    "status": "matched",
    "readings": 9,
    "considered": 9,
    "first_at": 1790040600,
    "last_at": 1790047800,
    "min_c": 12.6,
    "max_c": 13.4,
    "seal_at": 1790040600,
    "until": 1790042400,
    "gap_count": 0,
    "gaps": [],
    "out_of_range_count": 0,
    "out_of_range": [],
    "complete": true,
    "within_setpoint": true
  },
  "national_portal": {
    "rows": 386,
    "delivered": 386,
    "pending": 0,
    "failing": 0,
    "filed": true
  },
  "consignee": null,
  "documents": [],
  "paperwork": {
    "required": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "missing": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "complete": false
  },
  "amendments": []
}
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_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_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf_token_missing_or_invalid
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · 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: SH-260930-01",
  "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 · shipment_is_departed
{
  "error": "shipment is departed",
  "code": "shipment_is_departed"
}
Phản hồi 409 · application/json · no_lots
{
  "error": "no lots: a shipment departs with at least one packed lot",
  "code": "no_lots"
}
Phản hồi 409 · application/json · lot_lo_260928_014_is_shipped
{
  "error": "lot LO-260928-014 is shipped",
  "code": "lot_lo_260928_014_is_shipped"
}
Phản hồi 409 · application/json · lot_failed_its_lab_test
{
  "error": "lot failed its lab test: lot LO-260928-014 has a failed lab result and does not ship",
  "code": "lot_failed_its_lab_test"
}
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 409 · application/json · missing_paperwork
{
  "error": "missing paperwork: consignee, phytosanitary_certificate, test_report",
  "code": "missing_paperwork"
}
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"
}

PUT /v1/shipments/{code}/consignee

Set the shipment's consignee

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · setShipmentConsignee

Replaces the consignee of the shipment (#153): legal name, address, ISO 3166-1 alpha-2 country, optional GLN (GS1 check digit) and tax or importer registration id. Edited freely while the shipment is open; after the departure a reason is required and the change is kept as an amendment. Audited (shipment.consignee.set): the row names the changed fields, the consignee's country, the document types and the amendment id, never a name or an address. Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only shipments departing its facilities); auditor and lab are refused.

Tham số

TênVị tríKiểuMô tả
code
bắt buộc
pathstring

Shipment code (unique within the tenant).

Nội dung yêu cầu

ShipmentConsigneeSet (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "consignee": {
    "name": "Guangxi Fresh Import Co., Ltd.",
    "address": "88 Youyi Road, Pingxiang, Guangxi",
    "country": "CN",
    "gln": "6901234000009",
    "registration_id": "CIQ-4500/2026"
  }
}

Phản hồi

Mã trạng tháiKiểuMô tả
200Shipment
application/json

The shipment with its consignee, documents, paperwork and amendments.

400Error
application/json

Invalid JSON, a bad member, or a change to a departed shipment without a reason.

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 shipment for this tenant: a shipment of another tenant, or departing a facility 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 departed shipment already keeps the most amendments.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Header của phản hồi

TênMã trạng tháiKiểuMô tả
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.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "code": "SH-260930-01",
  "facility": "VN-TGPH-021",
  "container": "MSKU1234565",
  "border_gate": "Hữu Nghị",
  "destination": "CN",
  "setpoint_c": 13,
  "tolerance_c": 2,
  "logger_interval_minutes": 15,
  "logger": {
    "device_id": "reefer-logger-0731"
  },
  "status": "departed",
  "created_by": "shipper@coop.example",
  "created_at": 1790040000,
  "departed_by": "shipper@coop.example",
  "departed_at": 1790042400,
  "lots": [
    {
      "lot": "LO-260928-014",
      "status": "shipped",
      "cartons": 41,
      "seal_no": "0492117",
      "sealed_at": 1790040600,
      "current_seal_no": "0492117",
      "seal_matches": true,
      "added_by": "shipper@coop.example",
      "added_at": 1790041000
    }
  ],
  "logger_check": {
    "status": "matched",
    "readings": 9,
    "considered": 9,
    "first_at": 1790040600,
    "last_at": 1790047800,
    "min_c": 12.6,
    "max_c": 13.4,
    "seal_at": 1790040600,
    "until": 1790042400,
    "gap_count": 0,
    "gaps": [],
    "out_of_range_count": 0,
    "out_of_range": [],
    "complete": true,
    "within_setpoint": true
  },
  "national_portal": {
    "rows": 386,
    "delivered": 386,
    "pending": 0,
    "failing": 0,
    "filed": true
  },
  "consignee": {
    "name": "Guangxi Fresh Import Co., Ltd.",
    "address": "88 Youyi Road, Pingxiang, Guangxi",
    "country": "CN",
    "gln": "6901234000009",
    "registration_id": "CIQ-4500/2026"
  },
  "documents": [
    {
      "type": "phytosanitary_certificate",
      "number": "VN-PC/2026/0123",
      "issued_on": "2026-09-29",
      "attachment_sha256": null,
      "added_by": "shipper@coop.example",
      "added_at": 1790041200
    },
    {
      "type": "test_report",
      "number": "VILAS-1234/26",
      "issued_on": "2026-09-28",
      "attachment_sha256": null,
      "added_by": "shipper@coop.example",
      "added_at": 1790041200
    }
  ],
  "paperwork": {
    "required": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "missing": [],
    "complete": true
  },
  "amendments": []
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · reason_is_required
{
  "error": "reason is required: the shipment departed, a change is an amendment",
  "code": "reason_is_required"
}
Phản hồi 400 · application/json · invalid_reason
{
  "error": "invalid reason: 1 to 500 characters",
  "code": "invalid_reason"
}
Phản hồi 400 · application/json · invalid_body
{
  "error": "invalid body: consignee and optionally reason",
  "code": "invalid_body"
}
Phản hồi 400 · application/json · invalid_consignee_country
{
  "error": "invalid consignee country: an ISO 3166-1 alpha-2 code in capitals, e.g. CN",
  "code": "invalid_consignee_country"
}
Phản hồi 400 · application/json · invalid_consignee_gln
{
  "error": "invalid consignee gln: 13 digits with a valid GS1 check digit",
  "code": "invalid_consignee_gln"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf_token_missing_or_invalid
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · 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: SH-260930-01",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json · too_many_amendments
{
  "error": "too many amendments: a shipment keeps at most 50",
  "code": "too_many_amendments"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/shipments/{code}/documents

Set the shipment's document references

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · setShipmentDocuments

Replaces the shipment's document references (#153): each a type from a fixed list (phytosanitary certificate, certificate of origin, commercial invoice, packing list, customs declaration, bill of lading, air waybill, test report, other), a number, the issue date and optionally the SHA-256 of a PDF the tenant uploaded, which stays staff-only. An unchanged reference keeps who added it and when. Edited freely while the shipment is open; after the departure a reason is required and the change is kept as an amendment. Audited (shipment.documents.set): the row names the changed fields, the consignee's country, the document types and the amendment id, never a name or an address. Allowed for platform_admin and tenant_admin (the whole tenant) and for an operator signed in with a session (only shipments departing its facilities); auditor and lab are refused.

Tham số

TênVị tríKiểuMô tả
code
bắt buộc
pathstring

Shipment code (unique within the tenant).

Nội dung yêu cầu

ShipmentDocumentsSet (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "documents": [
    {
      "type": "phytosanitary_certificate",
      "number": "VN-PC/2026/0123",
      "issued_on": "2026-09-29"
    },
    {
      "type": "test_report",
      "number": "VILAS-1234/26",
      "issued_on": "2026-09-28"
    }
  ]
}

Phản hồi

Mã trạng tháiKiểuMô tả
200Shipment
application/json

The shipment with its consignee, documents, paperwork and amendments.

400Error
application/json

Invalid JSON, a bad member, or a change to a departed shipment without a reason.

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 shipment for this tenant: a shipment of another tenant, or departing a facility 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 departed shipment already keeps the most amendments.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Header của phản hồi

TênMã trạng tháiKiểuMô tả
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.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "code": "SH-260930-01",
  "facility": "VN-TGPH-021",
  "container": "MSKU1234565",
  "border_gate": "Hữu Nghị",
  "destination": "CN",
  "setpoint_c": 13,
  "tolerance_c": 2,
  "logger_interval_minutes": 15,
  "logger": {
    "device_id": "reefer-logger-0731"
  },
  "status": "departed",
  "created_by": "shipper@coop.example",
  "created_at": 1790040000,
  "departed_by": "shipper@coop.example",
  "departed_at": 1790042400,
  "lots": [
    {
      "lot": "LO-260928-014",
      "status": "shipped",
      "cartons": 41,
      "seal_no": "0492117",
      "sealed_at": 1790040600,
      "current_seal_no": "0492117",
      "seal_matches": true,
      "added_by": "shipper@coop.example",
      "added_at": 1790041000
    }
  ],
  "logger_check": {
    "status": "matched",
    "readings": 9,
    "considered": 9,
    "first_at": 1790040600,
    "last_at": 1790047800,
    "min_c": 12.6,
    "max_c": 13.4,
    "seal_at": 1790040600,
    "until": 1790042400,
    "gap_count": 0,
    "gaps": [],
    "out_of_range_count": 0,
    "out_of_range": [],
    "complete": true,
    "within_setpoint": true
  },
  "national_portal": {
    "rows": 386,
    "delivered": 386,
    "pending": 0,
    "failing": 0,
    "filed": true
  },
  "consignee": {
    "name": "Guangxi Fresh Import Co., Ltd.",
    "address": "88 Youyi Road, Pingxiang, Guangxi",
    "country": "CN",
    "gln": "6901234000009",
    "registration_id": "CIQ-4500/2026"
  },
  "documents": [
    {
      "type": "phytosanitary_certificate",
      "number": "VN-PC/2026/0123",
      "issued_on": "2026-09-29",
      "attachment_sha256": null,
      "added_by": "shipper@coop.example",
      "added_at": 1790041200
    },
    {
      "type": "test_report",
      "number": "VILAS-1234/26",
      "issued_on": "2026-09-28",
      "attachment_sha256": null,
      "added_by": "shipper@coop.example",
      "added_at": 1790041200
    }
  ],
  "paperwork": {
    "required": [
      "consignee",
      "phytosanitary_certificate",
      "test_report"
    ],
    "missing": [],
    "complete": true
  },
  "amendments": []
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · reason_is_required
{
  "error": "reason is required: the shipment departed, a change is an amendment",
  "code": "reason_is_required"
}
Phản hồi 400 · application/json · invalid_reason
{
  "error": "invalid reason: 1 to 500 characters",
  "code": "invalid_reason"
}
Phản hồi 400 · application/json · invalid_body
{
  "error": "invalid body: documents and optionally reason",
  "code": "invalid_body"
}
Phản hồi 400 · application/json · invalid_document_type
{
  "error": "invalid document type: one of phytosanitary_certificate, certificate_of_origin, commercial_invoice, packing_list, customs_declaration, bill_of_lading, air_waybill, test_report, other",
  "code": "invalid_document_type"
}
Phản hồi 400 · application/json · invalid_document_issued_on
{
  "error": "invalid document issued_on: a date YYYY-MM-DD from 2000-01-01, not in the future",
  "code": "invalid_document_issued_on"
}
Phản hồi 400 · application/json · invalid_documents
{
  "error": "invalid documents: phytosanitary_certificate VN-PC/2026/0123 is listed twice",
  "code": "invalid_documents"
}
Phản hồi 400 · application/json · unknown_attachment
{
  "error": "unknown attachment: a PDF this tenant uploaded",
  "code": "unknown_attachment"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf_token_missing_or_invalid
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · 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: SH-260930-01",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json · too_many_amendments
{
  "error": "too many amendments: a shipment keeps at most 50",
  "code": "too_many_amendments"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/shipments/{code}/sscc

A shipment's container load SSCC

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_read · getShipmentSscc

#161: the SSCC of the shipment's container load, null until set. Same roles as reading the shipment. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Tham số

TênVị tríKiểuMô tả
code
bắt buộc
pathstring

Shipment code.

Phản hồi

Mã trạng tháiKiểuMô tả
200ShipmentSscc
application/json

The load's SSCC.

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 shipment 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.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
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.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "shipment": "SH-2026-0042",
  "sscc": "095200000000000011",
  "epc": "https://id.gs1.org/00/095200000000000011",
  "element_string": "(00)095200000000000011"
}
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: SH-2026-0042",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/shipments/{code}/sscc

Set or allocate a container load's SSCC

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: lot_write · setShipmentSscc

#161: while the shipment is open. Its departure event then names the SSCC as its EPC, after the load's aggregation event (the pallets and the loose cartons of the lot into the load). Unique within the company. Same roles as the other shipment writes. Audited (shipment.sscc.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.

Tham số

TênVị tríKiểuMô tả
code
bắt buộc
pathstring

Shipment code.

Nội dung yêu cầu

SsccChange (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "sscc": "106141411234567897"
}

Phản hồi

Mã trạng tháiKiểuMô tả
200ShipmentSscc
application/json

The load's SSCC.

400Error
application/json

A body other than {"sscc": <18 digits>} or {"allocate": true}, an SSCC whose check digit is wrong or that carries the platform's prefix, 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 shipment 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 shipment departed, the SSCC is in use by the company, or no GS1 company prefix is configured.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Header của phản hồi

TênMã trạng tháiKiểuMô tả
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.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "shipment": "SH-2026-0042",
  "sscc": "106141411234567897",
  "epc": "https://id.gs1.org/00/106141411234567897",
  "element_string": "(00)106141411234567897"
}
Phản hồi 400 · application/json · invalid_body
{
  "error": "invalid body: {\"sscc\": \"<18 digits>\"} or {\"allocate\": true}",
  "code": "invalid_body"
}
Phản hồi 400 · application/json · invalid_sscc
{
  "error": "invalid sscc: 18 digits with a valid GS1 check digit",
  "code": "invalid_sscc"
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 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: SH-2026-0042",
  "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 · departed
{
  "error": "shipment departed: its container load keeps its sscc",
  "code": "shipment_departed"
}
Phản hồi 409 · application/json · sscc
{
  "error": "sscc already in use by the company",
  "code": "sscc_already_in_use_by_the_company"
}
Phản hồi 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"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}