CropPath 开发者

API 参考

support

4 个操作

GET /v1/help

What the staff shell's Help shows: announcements and the status page

身份验证:cookie · getHelp

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

SELF-2-7 (#196). The platform announcements showing now (the staff shell's banner; never shown on a public page) and CropPath's status page address (AGRITRACE_STATUS_PAGE_URL; null when the deployment has none, and the console hides the link). Any signed-in user, whatever the roles.

响应

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

The announcements and the status page.

400Error
application/json

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

401Error
application/json

No valid session cookie.

403Error
application/json

The caller is refused: tenant not allowed (X-Tenant). Session routes are open to every role.

405Error
application/json

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

500Error
application/json

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

响应头

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

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

Cache-Control200string

private, 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.

响应示例

响应 200 · application/json
{
  "status_page_url": "https://status.croppath.example",
  "announcements": [
    {
      "id": 3,
      "text": "Planned maintenance on Sunday 22:00 to 23:00 (Vietnam time): the console may be slow.",
      "level": "warning",
      "starts_at": 1790000000.5,
      "ends_at": 1790086400.5
    }
  ]
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "not authenticated",
  "code": "not_authenticated"
}
响应 403 · application/json
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/support-requests

List the company's support requests

身份验证:cookie · listSupportRequests

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

SELF-2-7 (#196). The selected company's (X-Tenant) support requests, newest first, with their status and CropPath's reply: every request of the company for tenant_admin and platform_admin, only the caller's own for operators and auditors. Allowed for only tenant_admin, operator, auditor and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused; lab users are refused (403).

参数

名称位置类型说明
limit
可选
queryinteger

1 to 200 (default 50).

cursor
可选
querystring

The previous page's next_cursor.

响应

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

One page of requests.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin, operator, auditor and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused; lab users are refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods).

405Error
application/json

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

500Error
application/json

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

响应头

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

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

响应示例

响应 200 · application/json
{
  "items": [
    {
      "id": 12,
      "tenant": "coop-dl",
      "user": {
        "id": 7,
        "email": "op@coop.example",
        "display_name": "Lan"
      },
      "subject": "Scale at line A1 shows no weight",
      "body": "Since this morning the scale at line A1 shows 0 kg for every fruit.",
      "record_id": "LOT-2026-001",
      "status": "answered",
      "reply": "Please restart the scale; it reconnects in a minute.",
      "created_at": 1790000000.5,
      "updated_at": 1790003600.5
    }
  ],
  "next_cursor": null
}
响应 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
响应 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/support-requests

Send CropPath a support request

身份验证:cookie · createSupportRequest

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

SELF-2-7 (#196). Sends CropPath a request from the caller in the selected company (X-Tenant): a subject, a text and optionally the id of the record it is about. It lands in the platform's queue with the company and the user; there is no email, so the answer comes back as the request's status and reply. Stored as plain text exactly as typed (trimmed), never as HTML or markdown. At most 5 requests per person per hour, 10 per person per day and 30 per company per day (429). Audited (support_request.create, in the same transaction; never the text). Allowed for only tenant_admin, operator, auditor and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused; lab users are refused (403).

参数

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

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

请求体

SupportRequestCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "subject": "Scale at line A1 shows no weight",
  "body": "Since this morning the scale at line A1 shows 0 kg for every fruit.",
  "record_id": "LOT-2026-001"
}

响应

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

The request, as the company sees it.

400Error
application/json

Invalid JSON, an unknown field or a value outside the limits, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin, operator, auditor and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused; lab users are refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only once the company has left CropPath; during its 30-day read-only window this stays open (owner decision A).

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

429Error
application/json

Too many requests sent: at most 5 per person per hour, 10 per person per day and 30 per company per day. Nothing was stored; retry after Retry-After seconds.

500Error
application/json

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

响应头

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

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id429string

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

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

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

响应示例

响应 201 · application/json
{
  "id": 12,
  "tenant": "coop-dl",
  "user": {
    "id": 7,
    "email": "op@coop.example",
    "display_name": "Lan"
  },
  "subject": "Scale at line A1 shows no weight",
  "body": "Since this morning the scale at line A1 shows 0 kg for every fruit.",
  "record_id": "LOT-2026-001",
  "status": "open",
  "reply": null,
  "created_at": 1790000000.5,
  "updated_at": 1790000000.5
}
响应 400 · application/json · subject
{
  "error": "invalid subject: required, text of at most 200 characters",
  "code": "invalid_subject"
}
响应 400 · application/json · body
{
  "error": "invalid body: required, text of at most 5000 characters",
  "code": "invalid_body"
}
响应 400 · application/json · record_id
{
  "error": "invalid record_id: at most 100 letters, digits and . _ : / # -, such as LOT-2026-001",
  "code": "invalid_record_id"
}
响应 400 · application/json · unknown
{
  "error": "unknown field: priority",
  "code": "unknown_field"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 429 · application/json
{
  "error": "too many support requests: at most 5 per person per hour",
  "code": "too_many_support_requests"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/support-requests/{id}

Read one of the company's support requests

身份验证:cookie · getSupportRequest

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

SELF-2-7 (#196). One support request of the selected company (X-Tenant): any of the company's for tenant_admin and platform_admin, only the caller's own for operators and auditors. Another company's request, or another person's for an operator or auditor, answers 404 like a missing one. Allowed for only tenant_admin, operator, auditor and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused; lab users are refused (403).

参数

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

The request id.

响应

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

The request.

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 (only tenant_admin, operator, auditor and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused; lab users are refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods).

404Error
application/json

No request with this id that the caller may read (another company's, or another person's).

405Error
application/json

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

500Error
application/json

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

响应头

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

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

响应示例

响应 200 · application/json
{
  "id": 12,
  "tenant": "coop-dl",
  "user": {
    "id": 7,
    "email": "op@coop.example",
    "display_name": "Lan"
  },
  "subject": "Scale at line A1 shows no weight",
  "body": "Since this morning the scale at line A1 shows 0 kg for every fruit.",
  "record_id": "LOT-2026-001",
  "status": "answered",
  "reply": "Please restart the scale; it reconnects in a minute.",
  "created_at": 1790000000.5,
  "updated_at": 1790003600.5
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}