CropPath 开发者

API 参考

agronomy

14 个操作

GET /v1/agronomists

List the agronomist registry

身份验证:cookie · listAgronomists

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

#351. The platform's agronomist registry, newest first: every row for a platform admin; for an agronomist, their own row only. Personal data: no-store. Read-only and not audited. Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

名称位置类型说明
status
可选
query"pending" | "verified" | "suspended"

Only rows of this status.

before
可选
querystring

Only rows with a smaller id: the previous page's next_before.

limit
可选
queryinteger

At most this many items (1 to 200; 100 by default).

响应

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

A page of rows.

400Error
application/json

Invalid JSON, a bad status, before or limit, 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 (platform_admin or agronomist, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in).

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

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
{
  "items": [
    {
      "id": 3,
      "user_id": 41,
      "email": "agronomist@coop.example",
      "legal_name": "Nguyễn Văn An",
      "organisation": "Viện Khoa học Kỹ thuật Nông nghiệp miền Nam",
      "qualification": "Kỹ sư nông học",
      "contact": "agronomist@coop.example",
      "note": null,
      "status": "verified",
      "created_at": 1790000000.5,
      "updated_at": 1790003600.5,
      "verified_by": "support@croppath.example",
      "verified_at": 1790003600.5,
      "suspended_by": null,
      "suspended_at": null,
      "suspend_reason": null
    }
  ],
  "next_before": null
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · status
{
  "error": "invalid status: one of pending, verified, suspended",
  "code": "invalid_status"
}
响应 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/agronomists

Register an agronomist (pending)

身份验证:cookie · createAgronomist

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

#351. A platform admin registers the account of email as an agronomist, pending until verified (POST .../verify) after an identity and qualification check made outside the platform. Audited (agronomist.create: the row, the account and the status; never the legal name or contact). Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

名称位置类型说明
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.

请求体

AgronomistCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "email": "agronomist@coop.example",
  "legal_name": "Nguyễn Văn An",
  "organisation": "Viện Khoa học Kỹ thuật Nông nghiệp miền Nam",
  "qualification": "Kỹ sư nông học"
}

响应

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

The row as stored.

400Error
application/json

Invalid JSON, an unknown field or a bad value, 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 (platform_admin, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), company read-only (SELF-2-4, #193: the company is leaving CropPath or has left).

404Error
application/json

No account has this email.

405Error
application/json

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

409Error
application/json

The account already has a registry row. Or the Idempotency-Key's first request is still running, or its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

响应头

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

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

Cache-Control201string

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-Id409string

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

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

响应示例

响应 201 · application/json
{
  "id": 3,
  "user_id": 41,
  "email": "agronomist@coop.example",
  "legal_name": "Nguyễn Văn An",
  "organisation": "Viện Khoa học Kỹ thuật Nông nghiệp miền Nam",
  "qualification": "Kỹ sư nông học",
  "contact": "agronomist@coop.example",
  "note": null,
  "status": "pending",
  "created_at": 1790000000.5,
  "updated_at": 1790003600.5,
  "verified_by": null,
  "verified_at": null,
  "suspended_by": null,
  "suspended_at": null,
  "suspend_reason": null
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field: status",
  "code": "unknown_field"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
响应 404 · application/json
{
  "error": "not found: user",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · already_registered
{
  "error": "already registered: this account already has an agronomist record",
  "code": "already_registered"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/agronomists/{id}

Read an agronomist's registry row

身份验证:cookie · getAgronomist

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

#351. One row: a platform admin any; an agronomist only their own (another answers 404). no-store. Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

The record id.

响应

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

The row.

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 (platform_admin or agronomist, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in).

404Error
application/json

No such row (or not the caller'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.

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.

响应示例

响应 200 · application/json
{
  "id": 3,
  "user_id": 41,
  "email": "agronomist@coop.example",
  "legal_name": "Nguyễn Văn An",
  "organisation": "Viện Khoa học Kỹ thuật Nông nghiệp miền Nam",
  "qualification": "Kỹ sư nông học",
  "contact": "agronomist@coop.example",
  "note": null,
  "status": "verified",
  "created_at": 1790000000.5,
  "updated_at": 1790003600.5,
  "verified_by": "support@croppath.example",
  "verified_at": 1790003600.5,
  "suspended_by": null,
  "suspended_at": null,
  "suspend_reason": null
}
响应 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · 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: 3",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/agronomists/{id}/verify

Verify an agronomist

身份验证:cookie · verifyAgronomist

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

#351. A platform admin verifies the row (pending or suspended) once they checked the person's identity and qualification outside the platform: from then on the person may sign their companies' sheets. Four eyes: the platform admin who registered the row, the row's own account, and the platform admin whose reset of the account's two-step sign-in sent the row back to pending (its suspended_by), never verify it (409 four_eyes_required); another platform admin does. Needs a recent password and second-factor proof (#87 step-up). Audited (agronomist.verify: the row, the account and the status before and after). Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

The record id.

Idempotency-Key
可选
headerstring

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

请求体

AgronomistVerify (必填)

媒体类型: application/json

请求示例 · application/json
{
  "note": "Identity card and degree checked on 2026-10-20"
}

响应

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

The row as decided.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token. Or a session of an account with two-step sign-in whose code was last confirmed more than 5 minutes ago, or its password more than 10 minutes ago (mfa_step_up_required, #87: confirm both with POST /v1/auth/reauth, then repeat the request; nothing was done and no audit row was written).

403Error
application/json

The caller is known but refused: role not permitted (platform_admin, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), company read-only (SELF-2-4, #193: the company is leaving CropPath or has left).

404Error
application/json

No such row.

405Error
application/json

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

409Error
application/json

The row already has this status, or the caller registered the row or is its account (four eyes). Or the Idempotency-Key's first request is still running, or its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

响应头

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

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

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-Id409string

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

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

响应示例

响应 200 · application/json
{
  "id": 3,
  "user_id": 41,
  "email": "agronomist@coop.example",
  "legal_name": "Nguyễn Văn An",
  "organisation": "Viện Khoa học Kỹ thuật Nông nghiệp miền Nam",
  "qualification": "Kỹ sư nông học",
  "contact": "agronomist@coop.example",
  "note": null,
  "status": "verified",
  "created_at": 1790000000.5,
  "updated_at": 1790003600.5,
  "verified_by": "support@croppath.example",
  "verified_at": 1790003600.5,
  "suspended_by": null,
  "suspended_at": null,
  "suspend_reason": null
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field: status",
  "code": "unknown_field"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 401 · application/json · step_up
{
  "error": "mfa step-up required: confirm your password and a code from your authenticator app with POST /v1/auth/reauth",
  "code": "mfa_step_up_required"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
响应 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · already_verified
{
  "error": "already verified: this agronomist is verified",
  "code": "already_verified"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · four_eyes_required
{
  "error": "four eyes required: another platform admin verifies an agronomist, never the one who registered them, the one who reset their two-step sign-in, nor the agronomist themselves",
  "code": "four_eyes_required"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/agronomists/{id}/suspend

Suspend an agronomist

身份验证:cookie · suspendAgronomist

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

#351. A platform admin suspends the row, with a reason: the person signs nothing from then on; sheets they signed stay signed, and any admin of their company may revoke them. Needs a recent password and second-factor proof (#87 step-up). Audited (agronomist.suspend: the row, the account and the status before and after). Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

The record id.

Idempotency-Key
可选
headerstring

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

请求体

AgronomistSuspend (必填)

媒体类型: application/json

请求示例 · application/json
{
  "reason": "Qualification withdrawn"
}

响应

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

The row as decided.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token. Or a session of an account with two-step sign-in whose code was last confirmed more than 5 minutes ago, or its password more than 10 minutes ago (mfa_step_up_required, #87: confirm both with POST /v1/auth/reauth, then repeat the request; nothing was done and no audit row was written).

403Error
application/json

The caller is known but refused: role not permitted (platform_admin, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), company read-only (SELF-2-4, #193: the company is leaving CropPath or has left).

404Error
application/json

No such row.

405Error
application/json

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

409Error
application/json

The row already has this status. Or the Idempotency-Key's first request is still running, or its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

响应头

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

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

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-Id409string

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

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

响应示例

响应 200 · application/json
{
  "id": 3,
  "user_id": 41,
  "email": "agronomist@coop.example",
  "legal_name": "Nguyễn Văn An",
  "organisation": "Viện Khoa học Kỹ thuật Nông nghiệp miền Nam",
  "qualification": "Kỹ sư nông học",
  "contact": "agronomist@coop.example",
  "note": null,
  "status": "suspended",
  "created_at": 1790000000.5,
  "updated_at": 1790003600.5,
  "verified_by": "support@croppath.example",
  "verified_at": 1790003600.5,
  "suspended_by": "support@croppath.example",
  "suspended_at": 1790090000.5,
  "suspend_reason": "Qualification withdrawn"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · unknown_field
{
  "error": "unknown field: status",
  "code": "unknown_field"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 401 · application/json · step_up
{
  "error": "mfa step-up required: confirm your password and a code from your authenticator app with POST /v1/auth/reauth",
  "code": "mfa_step_up_required"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
响应 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · already_suspended
{
  "error": "already suspended: this agronomist is suspended",
  "code": "already_suspended"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/agronomy-sheets

List the company's agronomic input sheets

身份验证:cookie · listAgronomySheets

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

#351. The company's sheets, newest first, without their bodies. Read-only and not audited. Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

Only sheets of this crop code.

status
可选
query"draft" | "signed" | "superseded" | "revoked"

Only sheets of this status.

before
可选
querystring

Only rows with a smaller id: the previous page's next_before.

limit
可选
queryinteger

At most this many items (1 to 200; 100 by default).

响应

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

A page of sheets.

400Error
application/json

Invalid JSON, a bad crop, status, before or limit, 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 (tenant_admin, auditor, agronomist or operator of the company, or platform_admin acting for it, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in).

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": 7,
      "series_key": "durian:Ri6:82",
      "crop": "durian",
      "variety": "Ri6",
      "province_code": "82",
      "version": 2,
      "status": "draft",
      "valid_from": "2027-01-01",
      "valid_to": "2027-06-30",
      "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
      "created_at": 1790000000.5,
      "updated_at": 1790000600.5,
      "signed_at": null,
      "superseded_at": null,
      "revoked_at": null,
      "signed_by": null
    }
  ],
  "next_before": null
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · status
{
  "error": "invalid status: one of draft, signed, superseded, revoked",
  "code": "invalid_status"
}
响应 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/agronomy-sheets

Create a draft agronomic input sheet

身份验证:cookie · createAgronomySheet

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

#351. A draft of the series the body names (crop of the crop registry, variety or *, province code or *), with that series' next version. Every value is optional in a draft and none has a default (CropPath ships no agronomic number); a value outside its sanity bounds, an unknown member and any member named g_per_l are refused. Audited (agronomy_sheet.create: the series, version and hash). Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

名称位置类型说明
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.

请求体

AgronomySheetCreate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "crop": "durian",
  "variety": "Ri6",
  "province_code": "82",
  "valid_from": "2027-01-01",
  "valid_to": "2027-06-30",
  "body": {
    "stages": [
      {
        "code": "flowering",
        "name": {
          "vi": "Ra hoa",
          "en": "Flowering",
          "zh-Hans": "开花期"
        },
        "start": "2027-01-01",
        "end": "2027-02-15"
      }
    ],
    "references": [
      {
        "title": "Agronomist's field notes, season 2027"
      }
    ]
  }
}

响应

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

The draft as stored.

400Error
application/json

Invalid JSON, an unknown field, a bad value or an unknown crop, or a bad X-Request-Id. Or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (tenant_admin or agronomist of the company, or platform_admin acting for it, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), company read-only (SELF-2-4, #193: the company is leaving CropPath or has left).

404Error
application/json

The company does not exist (a platform admin may name any with X-Tenant).

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

响应头

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

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

ETag201string

The sheet's body_sha256, quoted: send it back in If-Match to edit the draft.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

响应示例

响应 201 · application/json
{
  "id": 7,
  "series_key": "durian:Ri6:82",
  "crop": "durian",
  "variety": "Ri6",
  "province_code": "82",
  "version": 1,
  "status": "draft",
  "valid_from": "2027-01-01",
  "valid_to": "2027-06-30",
  "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
  "created_by": "agronomist@coop.example",
  "created_at": 1790000000.5,
  "updated_by": "agronomist@coop.example",
  "updated_at": 1790000600.5,
  "copied_from_id": null,
  "supersedes_id": null,
  "superseded_by_id": null,
  "signed_at": null,
  "superseded_at": null,
  "revoked_at": null,
  "revoked_by": null,
  "revoke_reason": null,
  "body": {
    "stages": [
      {
        "code": "flowering",
        "name": {
          "vi": "Ra hoa",
          "en": "Flowering",
          "zh-Hans": "开花期"
        },
        "start": "2027-01-01",
        "end": "2027-02-15"
      }
    ],
    "references": [
      {
        "title": "Agronomist's field notes, season 2027"
      }
    ]
  },
  "attestation": null
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · invalid_body
{
  "error": "invalid body: stages[0].kc: 3 is outside the sanity bounds 0 to 2",
  "code": "invalid_body"
}
响应 400 · application/json · g_per_l_refused
{
  "error": "g per l refused: salinity is electrical conductivity in mS/cm only; g/L is never used or converted",
  "code": "g_per_l_refused"
}
响应 400 · application/json · unknown_crop
{
  "error": "unknown crop: not in the crop registry",
  "code": "unknown_crop"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
响应 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/agronomy-sheets/{id}

Read an agronomic input sheet

身份验证:cookie · getAgronomySheet

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

#351. One sheet with its body and its signature (null until signed); its ETag is the quoted body_sha256. Read-only and not audited. Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

The record id.

响应

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

The sheet.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (tenant_admin, auditor, agronomist or operator of the company, or platform_admin acting for it, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in).

404Error
application/json

No such sheet of this company: another company's answers exactly like a missing one.

405Error
application/json

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

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.

ETag200string

The sheet's body_sha256, quoted: send it back in If-Match to edit the draft.

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": 7,
  "series_key": "durian:Ri6:82",
  "crop": "durian",
  "variety": "Ri6",
  "province_code": "82",
  "version": 2,
  "status": "signed",
  "valid_from": "2027-01-01",
  "valid_to": "2027-06-30",
  "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
  "created_by": "agronomist@coop.example",
  "created_at": 1790000000.5,
  "updated_by": "agronomist@coop.example",
  "updated_at": 1790000600.5,
  "copied_from_id": null,
  "supersedes_id": 4,
  "superseded_by_id": null,
  "signed_at": 1790007200.5,
  "superseded_at": null,
  "revoked_at": null,
  "revoked_by": null,
  "revoke_reason": null,
  "body": {
    "stages": [
      {
        "code": "flowering",
        "name": {
          "vi": "Ra hoa",
          "en": "Flowering",
          "zh-Hans": "开花期"
        },
        "start": "2027-01-01",
        "end": "2027-02-15"
      }
    ],
    "references": [
      {
        "title": "Agronomist's field notes, season 2027"
      }
    ]
  },
  "attestation": {
    "id": 5,
    "agronomist_id": 3,
    "user_id": 41,
    "legal_name": "Nguyễn Văn An",
    "organisation": "Viện Khoa học Kỹ thuật Nông nghiệp miền Nam",
    "statement_version": "1",
    "statement_text_sha256": "9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a",
    "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
    "signed_at": 1790007200.5,
    "second_factor_at": 1790007000.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: 7",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/agronomy-sheets/{id}

Edit a draft agronomic input sheet

身份验证:cookie · updateAgronomySheet

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

#351. A draft's validity and body (each member given replaces it), under If-Match: the sheet's body_sha256 as last read. A signed, superseded or revoked sheet never changes (409; the database refuses it too): copy it into a new draft instead. Audited (agronomy_sheet.update: the fields and the hash before and after). Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

The record id.

If-Match
必填
headerstring

The sheet's body_sha256 as the caller last read it (its ETag, quoted or not): an edit made since answers 412 and changes nothing. A strong tag only: If-Match compares strongly (RFC 9110), so a weak tag (W/"...") never matches and answers 412.

请求体

AgronomySheetUpdate (必填)

媒体类型: application/json

请求示例 · application/json
{
  "valid_to": "2027-07-31",
  "body": {
    "stages": [
      {
        "code": "flowering",
        "name": {
          "vi": "Ra hoa",
          "en": "Flowering",
          "zh-Hans": "开花期"
        },
        "start": "2027-01-01",
        "end": "2027-02-15"
      }
    ],
    "references": [
      {
        "title": "Agronomist's field notes, season 2027"
      }
    ]
  }
}

响应

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

The draft as stored.

400Error
application/json

Invalid JSON, an unknown field or a bad value, 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 (tenant_admin or agronomist of the company, or platform_admin acting for it, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), company read-only (SELF-2-4, #193: the company is leaving CropPath or has left).

404Error
application/json

No such sheet of this company: another company's answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The sheet is not a draft.

412Error
application/json

If-Match is not the sheet's hash: it changed since it was read, or the tag was sent weak (W/); nothing was changed.

413Error
application/json

The request body is over 1 MiB.

428Error
application/json

No If-Match header.

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.

ETag200string

The sheet's body_sha256, quoted: send it back in If-Match to edit the draft.

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-Id412string

Request id: the 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-Id428string

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

X-Request-Id500string

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

响应示例

响应 200 · application/json
{
  "id": 7,
  "series_key": "durian:Ri6:82",
  "crop": "durian",
  "variety": "Ri6",
  "province_code": "82",
  "version": 2,
  "status": "draft",
  "valid_from": "2027-01-01",
  "valid_to": "2027-06-30",
  "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
  "created_by": "agronomist@coop.example",
  "created_at": 1790000000.5,
  "updated_by": "agronomist@coop.example",
  "updated_at": 1790000600.5,
  "copied_from_id": 6,
  "supersedes_id": null,
  "superseded_by_id": null,
  "signed_at": null,
  "superseded_at": null,
  "revoked_at": null,
  "revoked_by": null,
  "revoke_reason": null,
  "body": {
    "stages": [
      {
        "code": "flowering",
        "name": {
          "vi": "Ra hoa",
          "en": "Flowering",
          "zh-Hans": "开花期"
        },
        "start": "2027-01-01",
        "end": "2027-02-15"
      }
    ],
    "references": [
      {
        "title": "Agronomist's field notes, season 2027"
      }
    ]
  },
  "attestation": null
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · invalid_body
{
  "error": "invalid body: stages[0].kc: 3 is outside the sanity bounds 0 to 2",
  "code": "invalid_body"
}
响应 400 · application/json · g_per_l_refused
{
  "error": "g per l refused: salinity is electrical conductivity in mS/cm only; g/L is never used or converted",
  "code": "g_per_l_refused"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
响应 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json
{
  "error": "not draft: only a draft sheet is edited or signed",
  "code": "not_draft"
}
响应 412 · application/json · precondition_failed
{
  "error": "precondition failed: the sheet's hash is not the one in If-Match; read it again",
  "code": "precondition_failed"
}
响应 412 · application/json · weak_etag
{
  "error": "precondition failed: a weak entity tag (W/) never matches, as If-Match compares strongly (RFC 9110); send the sheet's body_sha256",
  "code": "precondition_failed"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 428 · application/json
{
  "error": "if-match required: send the sheet's body_sha256 in If-Match",
  "code": "if_match_required"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/agronomy-sheets/{id}/document

Read the document a signature covers

身份验证:cookie · getAgronomySheetDocument

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

#351. The RFC 8785 (JCS) text of {spec, tenant, series_key, version, valid_from, valid_to, body}, its SHA-256 (the sheet's body_sha256) and the statement an agronomist agrees to when signing, with its SHA-256. Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

The record id.

响应

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

The document.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (tenant_admin, auditor, agronomist or operator of the company, or platform_admin acting for it, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in).

404Error
application/json

No such sheet of this company: another company's answers exactly like a missing one.

405Error
application/json

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

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": 7,
  "spec": "agritrace.agronomy-sheet/1",
  "document": "{\"body\":{},\"series_key\":\"durian:Ri6:82\",\"spec\":\"agritrace.agronomy-sheet/1\",\"tenant\":\"coop-dl\",\"valid_from\":\"2027-01-01\",\"valid_to\":\"2027-06-30\",\"version\":2}",
  "sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
  "statement": {
    "version": "1",
    "text": {
      "vi": "Tôi, kỹ sư nông học có tên dưới đây, ...",
      "en": "I, the agronomist named here, ...",
      "zh-Hans": "本人(下列署名的农艺师)..."
    },
    "sha256": "9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a"
  }
}
响应 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: 7",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/agronomy-sheets/{id}/sign

Sign a draft agronomic input sheet

身份验证:cookie · signAgronomySheet

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

#351 (ADR 0014). A verified agronomist of the company signs a draft: an in-app attestation over the document's SHA-256, not a detached digital signature. The caller holds the role agronomist and no admin role in the company (separation of duties), has two-step sign-in on and proved a password and a code recently (#87 step-up), and CropPath verified them (the registry). The body names the hash the agronomist saw and the statement version they agree to; the server recomputes the hash (409 sheet_changed when the sheet changed) and checks the sheet is complete (stages, values given in every stage, windows and sections whole, inside the validity) and not over. In one transaction: the series' signed version becomes superseded, the sheet signed and its attestation and audit row (agronomy_sheet.sign) written. Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

The record id.

Idempotency-Key
可选
headerstring

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

请求体

AgronomySheetSign (必填)

媒体类型: application/json

请求示例 · application/json
{
  "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
  "statement_version": "1"
}

响应

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

The signed sheet with its attestation.

400Error
application/json

Invalid JSON, an unknown field or a bad hash, or a bad X-Request-Id. Or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token. Or a session of an account with two-step sign-in whose code was last confirmed more than 5 minutes ago, or its password more than 10 minutes ago (mfa_step_up_required, #87: confirm both with POST /v1/auth/reauth, then repeat the request; nothing was done and no audit row was written).

403Error
application/json

The caller is known but refused: role not permitted (agronomist, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), company read-only (SELF-2-4, #193: the company is leaving CropPath or has left); separation of duties; agronomist not verified.

404Error
application/json

No such sheet of this company: another company's answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The sheet changed since it was read, is not a draft, is incomplete or over, a later version of its series is signed, or the statement version is not the current one. Or the Idempotency-Key's first request is still running, or its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

响应头

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

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

响应示例

响应 200 · application/json
{
  "id": 7,
  "series_key": "durian:Ri6:82",
  "crop": "durian",
  "variety": "Ri6",
  "province_code": "82",
  "version": 2,
  "status": "signed",
  "valid_from": "2027-01-01",
  "valid_to": "2027-06-30",
  "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
  "created_by": "agronomist@coop.example",
  "created_at": 1790000000.5,
  "updated_by": "agronomist@coop.example",
  "updated_at": 1790000600.5,
  "copied_from_id": null,
  "supersedes_id": 4,
  "superseded_by_id": null,
  "signed_at": 1790007200.5,
  "superseded_at": null,
  "revoked_at": null,
  "revoked_by": null,
  "revoke_reason": null,
  "body": {
    "stages": [
      {
        "code": "flowering",
        "name": {
          "vi": "Ra hoa",
          "en": "Flowering",
          "zh-Hans": "开花期"
        },
        "start": "2027-01-01",
        "end": "2027-02-15"
      }
    ],
    "references": [
      {
        "title": "Agronomist's field notes, season 2027"
      }
    ]
  },
  "attestation": {
    "id": 5,
    "agronomist_id": 3,
    "user_id": 41,
    "legal_name": "Nguyễn Văn An",
    "organisation": "Viện Khoa học Kỹ thuật Nông nghiệp miền Nam",
    "statement_version": "1",
    "statement_text_sha256": "9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a",
    "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
    "signed_at": 1790007200.5,
    "second_factor_at": 1790007000.5
  }
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · invalid_body_sha256
{
  "error": "invalid body_sha256: the SHA-256 of the sheet's document in lower-case hex",
  "code": "invalid_body_sha256"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 401 · application/json · step_up
{
  "error": "mfa step-up required: confirm your password and a code from your authenticator app with POST /v1/auth/reauth",
  "code": "mfa_step_up_required"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
响应 403 · application/json · separation_of_duties
{
  "error": "separation of duties: an admin of the company enables what an agronomist signed, never signs",
  "code": "separation_of_duties"
}
响应 403 · application/json · agronomist_not_verified
{
  "error": "agronomist not verified: CropPath has not verified this agronomist, or suspended them",
  "code": "agronomist_not_verified"
}
响应 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · sheet_changed
{
  "error": "sheet changed: the sheet's hash is not the one sent; read it again before signing",
  "code": "sheet_changed"
}
响应 409 · application/json · not_draft
{
  "error": "not draft: only a draft sheet is edited or signed",
  "code": "not_draft"
}
响应 409 · application/json · sheet_incomplete
{
  "error": "sheet incomplete: stages[1].kc (given in another stage)",
  "code": "sheet_incomplete"
}
响应 409 · application/json · sheet_expired
{
  "error": "sheet expired: its last valid day has passed",
  "code": "sheet_expired"
}
响应 409 · application/json · newer_version_signed
{
  "error": "newer version signed: a later version of this series is signed already",
  "code": "newer_version_signed"
}
响应 409 · application/json · unknown_statement_version
{
  "error": "unknown statement version: sign the current statement",
  "code": "unknown_statement_version"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/agronomy-sheets/{id}/revoke

Revoke a signed agronomic input sheet

身份验证:cookie · revokeAgronomySheet

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

#351. A signed or superseded sheet is revoked, with a reason, by an admin of the company or by the agronomist who signed it (another agronomist: 403 not_signer); final. Needs a recent password and second-factor proof (#87 step-up). Audited (agronomy_sheet.revoke: the series, version and reason). Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

The record id.

Idempotency-Key
可选
headerstring

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

请求体

AgronomySheetRevoke (必填)

媒体类型: application/json

请求示例 · application/json
{
  "reason": "Wrong province"
}

响应

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

The revoked sheet.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token. Or a session of an account with two-step sign-in whose code was last confirmed more than 5 minutes ago, or its password more than 10 minutes ago (mfa_step_up_required, #87: confirm both with POST /v1/auth/reauth, then repeat the request; nothing was done and no audit row was written).

403Error
application/json

The caller is known but refused: role not permitted (tenant_admin or the signing agronomist of the company, or platform_admin acting for it, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), company read-only (SELF-2-4, #193: the company is leaving CropPath or has left); not signer.

404Error
application/json

No such sheet of this company: another company's answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

The sheet is not signed or superseded. Or the Idempotency-Key's first request is still running, or its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

响应头

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

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

响应示例

响应 200 · application/json
{
  "id": 7,
  "series_key": "durian:Ri6:82",
  "crop": "durian",
  "variety": "Ri6",
  "province_code": "82",
  "version": 2,
  "status": "revoked",
  "valid_from": "2027-01-01",
  "valid_to": "2027-06-30",
  "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
  "created_by": "agronomist@coop.example",
  "created_at": 1790000000.5,
  "updated_by": "agronomist@coop.example",
  "updated_at": 1790000600.5,
  "copied_from_id": null,
  "supersedes_id": 4,
  "superseded_by_id": null,
  "signed_at": 1790007200.5,
  "superseded_at": null,
  "revoked_at": 1790010800.5,
  "revoked_by": "admin@coop.example",
  "revoke_reason": "Wrong province",
  "body": {
    "stages": [
      {
        "code": "flowering",
        "name": {
          "vi": "Ra hoa",
          "en": "Flowering",
          "zh-Hans": "开花期"
        },
        "start": "2027-01-01",
        "end": "2027-02-15"
      }
    ],
    "references": [
      {
        "title": "Agronomist's field notes, season 2027"
      }
    ]
  },
  "attestation": {
    "id": 5,
    "agronomist_id": 3,
    "user_id": 41,
    "legal_name": "Nguyễn Văn An",
    "organisation": "Viện Khoa học Kỹ thuật Nông nghiệp miền Nam",
    "statement_version": "1",
    "statement_text_sha256": "9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a",
    "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
    "signed_at": 1790007200.5,
    "second_factor_at": 1790007000.5
  }
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · invalid_reason
{
  "error": "invalid reason: text of 1 to 500 characters",
  "code": "invalid_reason"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 401 · application/json · step_up
{
  "error": "mfa step-up required: confirm your password and a code from your authenticator app with POST /v1/auth/reauth",
  "code": "mfa_step_up_required"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
响应 403 · application/json · not_signer
{
  "error": "not signer: only the agronomist who signed a sheet, or an admin of the company, revokes it",
  "code": "not_signer"
}
响应 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · not_signed
{
  "error": "not signed: only a signed or superseded sheet is revoked",
  "code": "not_signed"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/agronomy-sheets/{id}/copy

Copy a sheet into a new draft

身份验证:cookie · copyAgronomySheet

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

#351. A new draft of the sheet's series with the series' next version, the sheet's validity and body: how a signed sheet gets a new version. Audited (agronomy_sheet.copy: the new sheet, its source, series and version). Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

参数

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

The record id.

Idempotency-Key
可选
headerstring

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

响应

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

The new draft.

400Error
application/json

The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (tenant_admin or agronomist of the company, or platform_admin acting for it, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), company read-only (SELF-2-4, #193: the company is leaving CropPath or has left).

404Error
application/json

No such sheet of this company: another company's answers exactly like a missing one.

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

响应头

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

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

ETag201string

The sheet's body_sha256, quoted: send it back in If-Match to edit the draft.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

响应示例

响应 201 · application/json
{
  "id": 7,
  "series_key": "durian:Ri6:82",
  "crop": "durian",
  "variety": "Ri6",
  "province_code": "82",
  "version": 2,
  "status": "draft",
  "valid_from": "2027-01-01",
  "valid_to": "2027-06-30",
  "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
  "created_by": "agronomist@coop.example",
  "created_at": 1790000000.5,
  "updated_by": "agronomist@coop.example",
  "updated_at": 1790000600.5,
  "copied_from_id": 6,
  "supersedes_id": null,
  "superseded_by_id": null,
  "signed_at": null,
  "superseded_at": null,
  "revoked_at": null,
  "revoked_by": null,
  "revoke_reason": null,
  "body": {
    "stages": [
      {
        "code": "flowering",
        "name": {
          "vi": "Ra hoa",
          "en": "Flowering",
          "zh-Hans": "开花期"
        },
        "start": "2027-01-01",
        "end": "2027-02-15"
      }
    ],
    "references": [
      {
        "title": "Agronomist's field notes, season 2027"
      }
    ]
  },
  "attestation": null
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
响应 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
响应 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
响应 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
响应 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
响应 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
响应 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
响应 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
响应 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
响应 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
响应 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/agronomy/home

Read the agronomist's home

身份验证:cookie · getAgronomyHome

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

#351. For an agronomist of the selected company: Now (the drafts waiting for a signature, oldest first), Today (today's control work: empty until wave 2 of #243, which the answer says) and Status (whether the caller can sign: registry status, two-step sign-in, step-up window; their signed sheets whose last valid day is within 30 days). Computed at most every 10 seconds per company and person (a draft just signed may be listed that long); the step-up window is the session's. no-store. Read-only and not audited. Through a signed-in session only: an API token, an API client or the legacy token is refused (403); an agronomist acts as a person (ADR 0014). Not part of the partner SDK clients (x-not-in-sdk): an operation of the agronomy console.

响应

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

The home.

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 (agronomist, through a signed-in session only), tenant not allowed (X-Tenant), two-factor required (the company requires two-step sign-in).

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

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
{
  "generated_at": 1790007200.5,
  "now": {
    "drafts_waiting": 1,
    "drafts": [
      {
        "id": 7,
        "series_key": "durian:Ri6:82",
        "crop": "durian",
        "variety": "Ri6",
        "province_code": "82",
        "version": 2,
        "status": "draft",
        "valid_from": "2027-01-01",
        "valid_to": "2027-06-30",
        "body_sha256": "4f1c0a3e9b2d7c6e5a8f0b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e",
        "created_at": 1790000000.5,
        "updated_at": 1790000600.5,
        "signed_at": null,
        "superseded_at": null,
        "revoked_at": null,
        "signed_by": null
      }
    ]
  },
  "today": {
    "state": "available",
    "reason": "the programs composed today from sheets the caller signed, and the zones of their rules on fallback",
    "programs": [
      {
        "id": 31,
        "device_id": "irr-ph7-01",
        "status": "proposed",
        "proposed_at": 1790007300.5,
        "sheets": [
          {
            "id": 7,
            "version": 2,
            "series_key": "durian:Ri6:82"
          }
        ]
      }
    ],
    "fallback_zones": [
      {
        "rule_id": 12,
        "rule_name": "Block A moisture",
        "device_id": "irr-ph7-01",
        "zones": [
          1,
          2
        ],
        "reason": "frozen"
      }
    ]
  },
  "status": {
    "registry": "verified",
    "two_factor": true,
    "expiring_days": 30,
    "expiring": [],
    "step_up": {
      "fresh": false,
      "until": null
    },
    "can_sign": true
  }
}
响应 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"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}