CropPath for developers

API reference

reports

3 operations

GET /v1/reports

The tenant's public mismatch reports (staff triage)

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: report_triage · listReports

Newest first, one page (limit, default 50, at most 200; cursor from the previous page), optionally only open or resolved ones and only one category, with the contact the visitor left (null once erased). Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant); other tenants' reports are never listed. Not audited (a read). no-store.

Parameters

NameInTypeDescription
status
optional
query"open" | "resolved"

open or resolved.

category
optional
queryReportCategory

Only reports of this category (ReportCategory).

limit
optional
queryinteger

1 to 200 (default 50).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200ReportPage
application/json

One page of reports.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods).

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.

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 12,
      "fruit": {
        "code": "Q-0928-014-0003",
        "public_id": "73879f17d0930440809333f141385eb6"
      },
      "lot": {
        "code": "LO-260928-014",
        "public_id": "5d0c7a3e9b1f4a2c8e6d0b4f7a9c3e1d"
      },
      "category": "label_peeled",
      "note": "Tem bị bóc ở cuống.",
      "contact": "zalo 0901 234 567",
      "status": "open",
      "outcome": null,
      "created_at": 1790000000.5,
      "resolved_at": null
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · status
{
  "error": "bad status",
  "code": "bad_status"
}
Response 400 · application/json · category
{
  "error": "bad category",
  "code": "bad_category"
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/reports/{id}/resolve

Resolve a public mismatch report

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: report_triage · resolveReport

Resolves one of the tenant's open reports with an outcome, once. When it was the lot's last open report, the lot's report hold clears: the lot is recomputed right after the commit and its pages leave under_review, with at most the sealed tier. Audited (report.resolve, in the same transaction; the contact is never in the audit row). Allowed for tenant_admin and platform_admin acting for the tenant; another tenant's report answers like a missing one.

Parameters

NameInTypeDescription
id
required
pathstring

The report id.

Idempotency-Key
optional
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.

Request body

ReportResolution (required)

Media type: application/json

Example request · application/json
{
  "outcome": "unfounded"
}

Responses

StatusTypeDescription
200Report
application/json

The report, resolved.

400Error
application/json

Invalid JSON, an unknown field or an outcome that is not one of ReportResolution's, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin), 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 report of this tenant (another tenant's answers 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 report is already resolved. 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.

Response headers

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

Example responses

Response 200 · application/json
{
  "id": 12,
  "fruit": {
    "code": "Q-0928-014-0003",
    "public_id": "73879f17d0930440809333f141385eb6"
  },
  "lot": {
    "code": "LO-260928-014",
    "public_id": "5d0c7a3e9b1f4a2c8e6d0b4f7a9c3e1d"
  },
  "category": "label_peeled",
  "note": "Tem bị bóc ở cuống.",
  "contact": "zalo 0901 234 567",
  "status": "resolved",
  "outcome": "unfounded",
  "created_at": 1790000000.5,
  "resolved_at": 1790003600.5
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · outcome
{
  "error": "invalid outcome",
  "code": "invalid_outcome"
}
Response 400 · application/json · unknown
{
  "error": "unknown fields: note",
  "code": "unknown_fields"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 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"
}
Response 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · report_already_resolved
{
  "error": "report already resolved",
  "code": "report_already_resolved"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/reports/{id}

One public mismatch report with its fruit's scan history (staff triage)

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: report_triage · getReport

The report as the list shows it, with the contact (null once erased), and the reported fruit's scan history (A8, #74; ReportDetail): the newest 50 scans, newest first, each its number, time, country, region, city and device class, never an address or its hash. A read with two bounded statements, not audited, no-store. Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant); another tenant's report answers like a missing one.

Parameters

NameInTypeDescription
id
required
pathstring

The report id.

Responses

StatusTypeDescription
200ReportDetail
application/json

The report and its fruit's scan history.

400Error
application/json

A bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods).

404Error
application/json

No such report of this tenant (another tenant's answers 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.

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Cache-Control200string

no-store.

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.

Example responses

Response 200 · application/json
{
  "id": 12,
  "fruit": {
    "code": "Q-0928-014-0003",
    "public_id": "73879f17d0930440809333f141385eb6"
  },
  "lot": {
    "code": "LO-260928-014",
    "public_id": "5d0c7a3e9b1f4a2c8e6d0b4f7a9c3e1d"
  },
  "category": "scanned_many",
  "note": "Mã đã bị quét ở nhiều nơi.",
  "contact": "zalo 0901 234 567",
  "status": "open",
  "outcome": null,
  "created_at": 1790000000.5,
  "resolved_at": null,
  "scans": {
    "total": 4,
    "truncated": false,
    "items": [
      {
        "scan_no": 4,
        "at": 1789999000,
        "country": "VN",
        "region": "Hà Nội",
        "city": "Hà Nội",
        "ua_class": "mobile"
      },
      {
        "scan_no": 3,
        "at": 1789990000,
        "country": "VN",
        "region": "Gia Lai",
        "city": "Pleiku",
        "ua_class": "mobile"
      },
      {
        "scan_no": 2,
        "at": 1789980000,
        "country": "VN",
        "region": "Đắk Lắk",
        "city": null,
        "ua_class": "desktop"
      },
      {
        "scan_no": 1,
        "at": 1789970000,
        "country": "VN",
        "region": "Đắk Lắk",
        "city": "Buôn Ma Thuột",
        "ua_class": "other"
      }
    ]
  }
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}