CropPath for developers

API reference

settings

54 operations

GET /v1/company/profile

Read the selected company's profile

Authentication: cookie, bearer · getCompanyProfile

SELF-1-5 (#186). The legal name, address, tax or registration number, contact person, website and logo of the company the caller acts for (X-Tenant). Admins, auditors and operators (operators print labels), tenant-wide; a lab is refused. Not available to API clients (OAuth2): company account management. A company that never saved a profile answers its display name and empty fields.

Parameters

NameInTypeDescription
admin_units
optional
query"0" | "1"

#273: 1 adds the address by official code (province_code, commune_code, admin_units_version, address_status, address_before_reform, address_candidates, commune); 0 or none leaves them out and answers exactly as before; any other value is refused (400 bad admin_units).

Responses

StatusTypeDescription
200CompanyProfile
application/json

The company's profile.

400Error
application/json

admin_units is not 0 or 1, or the X-Request-Id header is malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such company: a platform admin named a company (X-Tenant) that does not exist. A member names only its own companies (any other is 403 tenant not allowed), so another company's profile is never reached.

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "tenant": "coop-dl",
  "name": "Coop DL",
  "legal_name": "Hợp tác xã Sầu riêng Đắk Lắk",
  "trading_name": "Durian DL",
  "address": "12 Nguyễn Tất Thành",
  "province": "Đắk Lắk",
  "district": "Buôn Ma Thuột",
  "country": "VN",
  "tax_id": "6001234567",
  "contact_name": "Nguyễn Văn A",
  "contact_phone": "+84 912 345 678",
  "contact_email": "a.nguyen@coop.example",
  "website": "https://coop.example",
  "logo": {
    "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
    "media_type": "image/png",
    "size": 20480
  },
  "updated_at": 1791000000,
  "updated_by": "admin@coop.example"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · bad_admin_units
{
  "error": "bad admin_units",
  "code": "bad_admin_units"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/company/profile

Save the selected company's profile

Authentication: cookie, bearer · putCompanyProfile

SELF-1-5 (#186). Company admins; a platform admin edits any company through X-Tenant. Replaces the whole profile (the logo is kept). tenants.name stays the short display name. Audited (company.profile.update): the prior profile's hash and the NAMES of the fields that changed, never a value (contact details are personal data). Lots already sealed keep the details they were sealed with. #273: the address in Viet Nam is given by official code, province_code and commune_code from getAdminUnits; the server writes the official names (district null). The text fields province and district of a profile in Viet Nam are deprecated (sunset 1 May 2027): a text-only address is still accepted, stores the record as not yet coded and answers with the Deprecation, Sunset and Link headers. In another country the codes are refused and the text stays the region and locality, not deprecated.

Request body

CompanyProfileUpdate (required)

Media type: application/json

Example request · application/json
{
  "legal_name": "Hợp tác xã Sầu riêng Đắk Lắk",
  "trading_name": "Durian DL",
  "address": "12 Nguyễn Tất Thành",
  "province_code": "66",
  "commune_code": "24133",
  "country": "VN",
  "tax_id": "6001234567",
  "contact_name": "Nguyễn Văn A",
  "contact_phone": "+84 912 345 678",
  "contact_email": "a.nguyen@coop.example",
  "website": "https://coop.example"
}

Responses

StatusTypeDescription
200CompanyProfile
application/json

Saved; the profile as stored.

400Error
application/json

A field outside its rules (the code names the field), an unknown field, a body that is not a JSON object, or a bad X-Request-Id. #273: also a code that is not in the administrative units list in force (admin_unit_unknown), a commune that the list places in another province (commune_not_in_province), a district (district_with_codes) or a province name sent with the codes (invalid_province), or a malformed code or one code without the other (invalid_province_code, invalid_commune_code), or codes for a profile in another country (invalid_country).

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such company: a platform admin named a company (X-Tenant) that does not exist. A member names only its own companies (any other is 403 tenant not allowed), so another company's profile is never reached.

405Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

503Error
application/json

#273: province_code and commune_code were sent but the server has no administrative units list in force to check them (administrative_units_catalog_unavailable); nothing was written. A text-only address is not refused this way.

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Deprecation200string

#273: sent only when the request gave the address in Viet Nam as text only (province or district, without province_code and commune_code; for a company profile, country VN or absent), on every answer, errors included. Not sent when a successful update sends the record's own stored text back unchanged (compared after Unicode NFC normalisation and trimming): that changes no address, the record keeps its codes, status and candidates. @1792195200 (RFC 9745): the text-only address was deprecated at the start of 17 October 2026, UTC.

Sunset200string

#273: sent only when the request gave the address in Viet Nam as text only (province or district, without province_code and commune_code; for a company profile, country VN or absent), on every answer, errors included. Not sent when a successful update sends the record's own stored text back unchanged (compared after Unicode NFC normalisation and trimming): that changes no address, the record keeps its codes, status and candidates. Sat, 01 May 2027 00:00:00 GMT (RFC 8594): from then a text-only address in Viet Nam may be refused.

Link200string

#273: sent only when the request gave the address in Viet Nam as text only (province or district, without province_code and commune_code; for a company profile, country VN or absent), on every answer, errors included. Not sent when a successful update sends the record's own stored text back unchanged (compared after Unicode NFC normalisation and trimming): that changes no address, the record keeps its codes, status and candidates. <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="deprecation", <https://txng.theio.vn/developers/downloads/CHANGELOG.md#text-only-addresses-of-facilities-growing-areas-and-company-profiles-deprecated-273>; rel="sunset": the changelog entry that says what to send instead.

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

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

X-Request-Id500string

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

X-Request-Id503string

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

Example responses

Response 200 · application/json
{
  "tenant": "coop-dl",
  "name": "Coop DL",
  "legal_name": "Hợp tác xã Sầu riêng Đắk Lắk",
  "trading_name": "Durian DL",
  "address": "12 Nguyễn Tất Thành",
  "province": "Tỉnh Đắk Lắk",
  "district": null,
  "country": "VN",
  "tax_id": "6001234567",
  "contact_name": "Nguyễn Văn A",
  "contact_phone": "+84 912 345 678",
  "contact_email": "a.nguyen@coop.example",
  "website": "https://coop.example",
  "logo": {
    "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
    "media_type": "image/png",
    "size": 20480
  },
  "updated_at": 1791000000,
  "updated_by": "admin@coop.example"
}
Response 400 · application/json · invalid_legal_name
{
  "error": "invalid legal_name: required, a string of 1 to 200 characters",
  "code": "invalid_legal_name"
}
Response 400 · application/json · invalid_country
{
  "error": "invalid country: an ISO 3166-1 alpha-2 code in capital letters, such as VN",
  "code": "invalid_country"
}
Response 400 · application/json · invalid_website
{
  "error": "invalid website: an https:// address such as https://example.com",
  "code": "invalid_website"
}
Response 400 · application/json · unknown_field
{
  "error": "unknown field: tenant",
  "code": "unknown_field"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · admin_unit_unknown
{
  "error": "admin unit unknown: commune 99999 is not in the official list vn-2026-10-17",
  "code": "admin_unit_unknown"
}
Response 400 · application/json · commune_not_in_province
{
  "error": "commune not in province: commune 00004 (Phường Ba Đình) is in province 01 (Thành phố Hà Nội), not in 82 (Tỉnh Đồng Tháp)",
  "code": "commune_not_in_province"
}
Response 400 · application/json · district_with_codes
{
  "error": "district with codes: Viet Nam has no district level since 2025-07-01; send it null",
  "code": "district_with_codes"
}
Response 400 · application/json · invalid_province
{
  "error": "invalid province: absent or null with the codes, the server writes the official name",
  "code": "invalid_province"
}
Response 400 · application/json · invalid_province_code
{
  "error": "invalid province_code: the official code, 2 digits as a string, sent with commune_code",
  "code": "invalid_province_code"
}
Response 400 · application/json · invalid_commune_code
{
  "error": "invalid commune_code: the official code, 5 digits as a string, sent with province_code",
  "code": "invalid_commune_code"
}
Response 400 · application/json · codes_outside_vietnam
{
  "error": "invalid country: province_code and commune_code apply to an address in Viet Nam (VN)",
  "code": "invalid_country"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf_token_missing_or_invalid
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin_not_allowed
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Response 503 · application/json
{
  "error": "administrative units catalog unavailable",
  "code": "administrative_units_catalog_unavailable"
}

GET /v1/company/profile/public-identity

Read how the selected company is named on public outputs

Authentication: cookie, bearer · getCompanyPublicIdentity

#208. Whether the company the caller acts for (X-Tenant) is a household business (hộ kinh doanh), its two opt-ins, and public_producer: the producer exactly as the lot's public customs file shows it now. For a company: its legal name and full address. For a household business, whose legal name is a person's name and whose address is often a home: its trading name (or 'Hộ kinh doanh' alone when it has none, never its tax number) and its province only, unless it opted in. Labels, the company's own export and the profile keep the legal name and full address. Readers as for the profile. Kept apart from the profile so the profile's body stays what SDK 0.2.0 decodes. A company that never saved a profile answers false for every flag and a null public_producer. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.

Parameters

NameInTypeDescription
admin_units
optional
query"0" | "1"

#273: 1 adds public_producer.commune, the company's commune (official name; null for a household business that has not opted in to its full address); 0 or none leaves it out and answers exactly as before; any other value is refused (400 bad admin_units).

Responses

StatusTypeDescription
200CompanyPublicIdentity
application/json

The company's public identity.

400Error
application/json

admin_units is not 0 or 1, or the X-Request-Id header is malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such company: a platform admin named a company (X-Tenant) that does not exist. A member names only its own companies (any other is 403 tenant not allowed), so another company's public identity is never reached.

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "household_business": true,
  "public_full_address": false,
  "public_legal_name": false,
  "public_producer": {
    "legal_name": "Sầu riêng Bảy Tân Phú",
    "address": null,
    "district": null,
    "province": "Tiền Giang",
    "country": "VN"
  }
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · bad_admin_units
{
  "error": "bad admin_units",
  "code": "bad_admin_units"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/company/profile/public-identity

Set how the selected company is named on public outputs

Authentication: cookie, bearer · putCompanyPublicIdentity

#208. Company admins; a platform admin through X-Tenant. Sets whether the company is a household business and its two opt-ins; every flag is required. The opt-ins apply to a household business only and are stored false for a company. The profile's fields are not changed, and saving the profile never changes these flags. The profile must be saved first. Audited (company.public_identity.update): the prior profile's hash and the NAMES of the flags that changed, never a value. Lots already sealed are not changed; the public customs file reads the profile when it is opened, so it shows the change after the edge cache (at most 60 s). Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.

Request body

CompanyPublicIdentityUpdate (required)

Media type: application/json

Example request · application/json
{
  "household_business": true,
  "public_full_address": false,
  "public_legal_name": false
}

Responses

StatusTypeDescription
200CompanyPublicIdentity
application/json

Saved; the public identity as stored.

400Error
application/json

A flag that is missing or not true or false (the code names it), an unknown field, a body that is not a JSON object, 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 not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such company: a platform admin named a company (X-Tenant) that does not exist. A member names only its own companies (any other is 403 tenant not allowed), so another company's public identity is never reached.

405Error
application/json

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

409Error
application/json

The company has not saved its profile yet: save the profile first.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "household_business": true,
  "public_full_address": false,
  "public_legal_name": false,
  "public_producer": {
    "legal_name": "Sầu riêng Bảy Tân Phú",
    "address": null,
    "district": null,
    "province": "Tiền Giang",
    "country": "VN"
  }
}
Response 400 · application/json · invalid_household_business
{
  "error": "invalid household_business: required, true or false",
  "code": "invalid_household_business"
}
Response 400 · application/json · invalid_public_full_address
{
  "error": "invalid public_full_address: required, true or false",
  "code": "invalid_public_full_address"
}
Response 400 · application/json · invalid_public_legal_name
{
  "error": "invalid public_legal_name: required, true or false",
  "code": "invalid_public_legal_name"
}
Response 400 · application/json · unknown_field
{
  "error": "unknown field: legal_name",
  "code": "unknown_field"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role_not_permitted
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant_not_allowed
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf_token_missing_or_invalid
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin_not_allowed
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json
{
  "error": "no company profile: save the company profile before its public identity",
  "code": "no_company_profile"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/company/security

Read the company's sign-in security

Authentication: cookie · getCompanySecurity

Session only — not available to API tokens or OAuth clients

SELF-1-6 (#187). Whether the selected company (X-Tenant) requires two-step sign-in, how many active members have it on, and the date from which company admins must use it. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403).

Responses

StatusTypeDescription
200CompanySecurity
application/json

The company's sign-in security.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

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

404Error
application/json

No such company: a platform admin named one (X-Tenant) that does not exist.

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "require_two_factor": true,
  "members": 12,
  "members_with_two_factor": 9,
  "admin_deadline": 1795270400,
  "updated_at": 1790086400.5,
  "updated_by": "admin@coop.example"
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/company/security

Require two-step sign-in for the company, or stop

Authentication: cookie · updateCompanySecurity

Session only — not available to API tokens or OAuth clients

SELF-1-6 (#187). When require_two_factor is on, a member of this company whose session has not proved a second factor can call only the session routes (/v1/auth/*) and gets 403 two_factor_required on every route of this company, until they set up the app. Turning it on needs the caller's own two-step sign-in (409 otherwise). Needs a password confirmed within the last 10 minutes (SELF-1-2). Audited (company.security.update, in the same transaction). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403). Second admin approval (INTEGRITY-3, #203): while the company requires a second admin (PUT /v1/company/four-eyes), a direct call answers 403 second_admin_approval_required before anything is done (no audit row, no Idempotency-Key used): ask for it with POST /v1/approval-requests, and another admin of the company approves it.

Request body

CompanySecurityUpdate (required)

Media type: application/json

Example request · application/json
{
  "require_two_factor": true
}

Responses

StatusTypeDescription
200CompanySecurity
application/json

The company's sign-in security.

400Error
application/json

Invalid JSON, an unknown field, or require_two_factor missing or not true or false; or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such company: a platform admin named one (X-Tenant) that does not exist.

405Error
application/json

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

409Error
application/json

Turning it on while the caller's own two-step sign-in is off.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "require_two_factor": true,
  "members": 12,
  "members_with_two_factor": 9,
  "admin_deadline": 1795270400,
  "updated_at": 1790086400.5,
  "updated_by": "admin@coop.example"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · missing
{
  "error": "require_two_factor is required",
  "code": "require_two_factor_is_required"
}
Response 400 · application/json · type
{
  "error": "require_two_factor must be true or false",
  "code": "require_two_factor_must_be_true_or_false"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json
{
  "error": "set up two-step sign-in for yourself first",
  "code": "set_up_two_step_sign_in_for_yourself_first"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/company/onboarding

Read the company's getting-started checklist

Authentication: cookie · getCompanyOnboarding

Session only — not available to API tokens or OAuth clients

SELF-1-8 (#189). The steps that take the selected company (X-Tenant) from an empty workspace to its first labelled lot, in order, each done, to_do or waiting_for_platform, computed from the company's own records (counts only; another company's records never count). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403).

Responses

StatusTypeDescription
200Onboarding
application/json

The company's checklist.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

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

404Error
application/json

No such company: a platform admin named one (X-Tenant) that does not exist.

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "tenant": "coop-dl",
  "complete": false,
  "hidden": false,
  "hidden_at": null,
  "steps": [
    {
      "id": "profile",
      "required": true,
      "status": "done",
      "count": 3,
      "total": 3,
      "link": "/admin/settings#profile"
    },
    {
      "id": "second_admin",
      "required": true,
      "status": "to_do",
      "count": 1,
      "total": null,
      "link": "/admin/settings#team"
    },
    {
      "id": "admin_two_factor",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": 1,
      "link": "/admin/settings#security"
    },
    {
      "id": "facility",
      "required": true,
      "status": "waiting_for_platform",
      "count": 0,
      "total": 1,
      "link": "/admin/facilities"
    },
    {
      "id": "growing_areas",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": 0,
      "link": "/admin/growing-areas"
    },
    {
      "id": "operators",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": null,
      "link": "/admin/settings#team"
    },
    {
      "id": "issuer_keys",
      "required": true,
      "status": "waiting_for_platform",
      "count": 0,
      "total": 0,
      "link": "/admin/settings/issuer-keys"
    },
    {
      "id": "devices",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": 0,
      "link": "/admin/devices"
    },
    {
      "id": "first_lot",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": null,
      "link": "/console/lots/new"
    },
    {
      "id": "first_sealed_lot",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": null,
      "link": "/console"
    },
    {
      "id": "first_label",
      "required": true,
      "status": "to_do",
      "count": null,
      "total": null,
      "link": "/console"
    },
    {
      "id": "integrations",
      "required": false,
      "status": "to_do",
      "count": 0,
      "total": null,
      "link": "/admin/settings/api-tokens"
    }
  ]
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/company/onboarding

Hide the company's getting-started checklist, or show it again

Authentication: cookie · updateCompanyOnboarding

Session only — not available to API tokens or OAuth clients

SELF-1-8 (#189). hidden true hides the checklist for every admin of the selected company (X-Tenant); false shows it again. Hiding an already hidden checklist keeps the first time. The only thing the checklist stores. Audited (company.onboarding.update, in the same transaction). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403).

Request body

OnboardingUpdate (required)

Media type: application/json

Example request · application/json
{
  "hidden": true
}

Responses

StatusTypeDescription
200Onboarding
application/json

The company's checklist.

400Error
application/json

Invalid JSON, an unknown field, or hidden missing or not true or false; or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused; operators and auditors are refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such company: a platform admin named one (X-Tenant) that does not exist.

405Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

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

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "tenant": "coop-dl",
  "complete": false,
  "hidden": true,
  "hidden_at": 1790086400.5,
  "steps": [
    {
      "id": "profile",
      "required": true,
      "status": "done",
      "count": 3,
      "total": 3,
      "link": "/admin/settings#profile"
    },
    {
      "id": "second_admin",
      "required": true,
      "status": "to_do",
      "count": 1,
      "total": null,
      "link": "/admin/settings#team"
    },
    {
      "id": "admin_two_factor",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": 1,
      "link": "/admin/settings#security"
    },
    {
      "id": "facility",
      "required": true,
      "status": "waiting_for_platform",
      "count": 0,
      "total": 1,
      "link": "/admin/facilities"
    },
    {
      "id": "growing_areas",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": 0,
      "link": "/admin/growing-areas"
    },
    {
      "id": "operators",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": null,
      "link": "/admin/settings#team"
    },
    {
      "id": "issuer_keys",
      "required": true,
      "status": "waiting_for_platform",
      "count": 0,
      "total": 0,
      "link": "/admin/settings/issuer-keys"
    },
    {
      "id": "devices",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": 0,
      "link": "/admin/devices"
    },
    {
      "id": "first_lot",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": null,
      "link": "/console/lots/new"
    },
    {
      "id": "first_sealed_lot",
      "required": true,
      "status": "to_do",
      "count": 0,
      "total": null,
      "link": "/console"
    },
    {
      "id": "first_label",
      "required": true,
      "status": "to_do",
      "count": null,
      "total": null,
      "link": "/console"
    },
    {
      "id": "integrations",
      "required": false,
      "status": "to_do",
      "count": 0,
      "total": null,
      "link": "/admin/settings/api-tokens"
    }
  ]
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · hidden
{
  "error": "hidden must be true or false",
  "code": "hidden_must_be_true_or_false"
}
Response 400 · application/json · unknown
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/company/exports

List the company's full data exports

Authentication: cookie · listCompanyExports

Session only — not available to API tokens or OAuth clients

SELF-2-3 (#192). The selected company's (X-Tenant) 20 newest export requests, newest first, with their state, and how many may be requested a day. Never another company's. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403).

Responses

StatusTypeDescription
200CompanyExportList
application/json

The company's export requests.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), or two-factor required (this session must prove a second factor before acting for the company).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 13,
      "status": "queued",
      "requested_by": "admin@coop.example",
      "requested_at": 1790090000,
      "started_at": null,
      "finished_at": null,
      "expires_at": null,
      "size": null,
      "sha256": null,
      "file_name": null,
      "error": null
    },
    {
      "id": 12,
      "status": "ready",
      "requested_by": "admin@coop.example",
      "requested_at": 1790000000.5,
      "started_at": 1790000030,
      "finished_at": 1790000041.25,
      "expires_at": 1790086441.25,
      "size": 1843211,
      "sha256": "9f2c4a7d1e0b6c3f8a5d2e7b4c1f9a6d3e0b7c4f1a8d5e2b9c6f3a0d7e4b1c8f",
      "file_name": "croppath-export-coop-dl-20260921T143320Z.zip",
      "error": null
    }
  ],
  "max_per_day": 3,
  "download_hours": 24
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/company/exports

Request a full data export of the company

Authentication: cookie · requestCompanyExport

Session only — not available to API tokens or OAuth clients

SELF-2-3 (#192). Queues a dated archive (ZIP of CSV and JSON files) of everything the selected company (X-Tenant) holds: profile, facilities, growing areas, growers, devices, lots, device events, cartons, shipments, lab reports and results, members (never a password, two-step secret, backup code, token, webhook secret or private key) and the activity log. A background job builds it within minutes; GET /v1/company/exports shows when it is ready, and it can be downloaded for 24 hours. One export per company at a time (409 export_in_progress) and at most 3 requests in any 24 hours (429 too_many_exports, with Retry-After). Send no body (or {}). Needs a password confirmed within the last 10 minutes (SELF-1-2). Audited (export.company.request, in the same transaction). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403).

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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

Responses

StatusTypeDescription
202CompanyExport
application/json

The export is queued.

400Error
application/json

Invalid JSON, a body with any field, 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 whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it 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 (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required, origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods).

404Error
application/json

No such company: a platform admin named one (X-Tenant) that does not exist.

405Error
application/json

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

409Error
application/json

An export of the company is already waiting or being built. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but 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.

429Error
application/json

The company already requested 3 exports in the last 24 hours; Retry-After says when the next one may be requested.

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id202string

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

Idempotent-Replayed202"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id429string

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

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

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

Example responses

Response 202 · application/json
{
  "id": 13,
  "status": "queued",
  "requested_by": "admin@coop.example",
  "requested_at": 1790090000,
  "started_at": null,
  "finished_at": null,
  "expires_at": null,
  "size": null,
  "sha256": null,
  "file_name": null,
  "error": null
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_fields
{
  "error": "unknown fields: format",
  "code": "unknown_fields"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · export_in_progress
{
  "error": "export in progress: an export of the company is already being prepared",
  "code": "export_in_progress"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 429 · application/json
{
  "error": "too many exports: at most 3 in 24 hours",
  "code": "too_many_exports"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/company/exports/{id}/download

Download a ready full data export

Authentication: cookie · downloadCompanyExport

Session only — not available to API tokens or OAuth clients

SELF-2-3 (#192). The archive of the selected company's (X-Tenant) export id as application/zip, streamed from the stored file, for 24 hours after it was ready. Another company's export answers 404 like one that does not exist. The archive layout (files, columns, encoding, times) is documented at /developers/downloads/company-export.md. Needs a password confirmed within the last 10 minutes (SELF-1-2). An audited read (export.company: the archive's size and SHA-256); never cached. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403).

Parameters

NameInTypeDescription
id
required
pathstring

The export's id.

Responses

StatusTypeDescription
200string
application/zip

The ZIP archive.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it 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 (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), or two-factor required (this session must prove a second factor before acting for the company).

404Error
application/json

No such export of the selected company (another company's export answers the same).

405Error
application/json

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

409Error
application/json

The export is still being prepared, or its build failed (request a new one).

410Error
application/json

The export's 24 hours are over and its file is deleted: request a new one.

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Content-Disposition200string

attachment; filename="<file_name>", the export's file_name.

Cache-Control200string

private, no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-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-Id410string

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

X-Request-Id500string

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

Example responses

Response 200 · application/zip
(binary ZIP bytes, starting 50 4B 03 04)
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · not_ready
{
  "error": "export not ready: it is still being prepared",
  "code": "export_not_ready"
}
Response 409 · application/json · failed
{
  "error": "export failed: request a new one",
  "code": "export_failed"
}
Response 410 · application/json
{
  "error": "export expired: request a new one",
  "code": "export_expired"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/notifications

List the caller's notifications

Authentication: cookie · listNotifications

Session only — not available to API tokens or OAuth clients

SELF-2-6 (#195). The caller's own in-app notifications in the selected company (X-Tenant), newest first, one page, with the number still unread. Each is a kind and its params (identifiers, names and times, never rendered text): the console words it in the reader's language. Company admins receive them (and a platform admin who invited a company's first admin, under that company): an invitation accepted or expiring within a day, a webhook turned off after repeated failures, an API token expiring within 14 days, a facility approved or refused, a growing area approved, a public mismatch report (at most one per lot and day), a facility with lots still open and no signing key. There is no email. Read notifications are deleted 90 days after they were created. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403).

Parameters

NameInTypeDescription
unread
optional
query"true" | "false"

true: only the unread ones (default false).

limit
optional
queryinteger

1 to 100 (default 20).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200NotificationPage
application/json

One page of the caller's notifications (Cache-Control: no-store).

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused) or tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 41,
      "kind": "api_token_expiring",
      "params": {
        "token_id": 7,
        "name": "erp-sync",
        "expires_at": 1797776000.5
      },
      "created_at": 1797000000.5,
      "read_at": null
    }
  ],
  "unread": 1,
  "next_cursor": null
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · unread
{
  "error": "unread must be true or false",
  "code": "unread_must_be_true_or_false"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/notifications/unread-count

Count the caller's unread notifications

Authentication: cookie · getNotificationUnreadCount

Session only — not available to API tokens or OAuth clients

SELF-2-6 (#195). How many of the caller's notifications in the selected company are unread: the bell's badge in the console's top bar. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403).

Responses

StatusTypeDescription
200NotificationUnreadCount
application/json

The unread count (Cache-Control: no-store).

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused) or tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "unread": 3
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/notifications/read-all

Mark all of the caller's notifications read

Authentication: cookie · markAllNotificationsRead

Session only — not available to API tokens or OAuth clients

SELF-2-6 (#195). Marks every unread notification of the caller in the selected company read; another user's and another company's stay as they are. Not audited: it changes only the reader's own view of their list (each notification records when it was read). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403).

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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

Responses

StatusTypeDescription
200NotificationsMarkedRead
application/json

How many were marked read, and how many are unread now.

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 (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods).

405Error
application/json

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

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

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-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-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "marked": 3,
  "unread": 0
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/notifications/{id}/read

Mark one of the caller's notifications read

Authentication: cookie · markNotificationRead

Session only — not available to API tokens or OAuth clients

SELF-2-6 (#195). Marks the notification read (a read one keeps its first read_at). Another user's notification, or one of another company, answers 404 like a missing one. Not audited: it changes only the reader's own view of their list. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403).

Parameters

NameInTypeDescription
id
required
pathstring

The notification id (from listNotifications).

Idempotency-Key
optional
headerstring

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

Responses

StatusTypeDescription
200Notification
application/json

The notification, read.

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 (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods).

404Error
application/json

No notification of the caller in this company with this id (another user's, another company's, purged or never created).

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

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "id": 41,
  "kind": "api_token_expiring",
  "params": {
    "token_id": 7,
    "name": "erp-sync",
    "expires_at": 1797776000.5
  },
  "created_at": 1797000000.5,
  "read_at": 1797000600.5
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: 41",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/company/usage

Read the company's usage and limits

Authentication: cookie · getCompanyUsage

Session only — not available to API tokens or OAuth clients

SELF-2-5 (#194). For the selected company (X-Tenant): how much of each per-company limit it uses, counted by the same query the limit checks before a create, against the limit the backend enforces, and its API calls on each of the last 14 UTC days. Counts only; another company's records never count. An entry warns from warn_percent of its limit and is reached at the limit (the next create is refused). An API call is a request authenticated by an API token or an API client's access token of the company, whatever its answer; console requests are not calls. Calls are counted in memory and written every few seconds, so the current day can lag slightly. #134: quotas gives the company's API calls per minute and per UTC day (enforced: over either, an API call answers 429 with Retry-After) with today's calls, and its device ingest rate and burst with the messages waiting in its ingest backlog; stored gives what the company keeps: its envelopes, the public scans of its fruits, its stored files (device attachments and uploaded documents) and their bytes. Allowed for tenant_admin, auditor and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators are refused (403).

Responses

StatusTypeDescription
200CompanyUsage
application/json

The company's usage of its limits, its API calls per day and its quotas.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin, auditor and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused; operators are refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company).

404Error
application/json

No such company: a platform admin named one (X-Tenant) that does not exist.

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "tenant": "coop-dl",
  "warn_percent": 80,
  "limits": [
    {
      "id": "members",
      "used": 12,
      "limit": 200,
      "warning": false,
      "reached": false
    },
    {
      "id": "pending_links",
      "used": 2,
      "limit": 50,
      "warning": false,
      "reached": false
    },
    {
      "id": "devices",
      "used": 7,
      "limit": null,
      "warning": false,
      "reached": false
    },
    {
      "id": "api_tokens",
      "used": 3,
      "limit": 100,
      "warning": false,
      "reached": false
    },
    {
      "id": "api_clients",
      "used": 1,
      "limit": 50,
      "warning": false,
      "reached": false
    },
    {
      "id": "webhooks",
      "used": 17,
      "limit": 20,
      "warning": true,
      "reached": false
    }
  ],
  "api_calls": [
    {
      "day": "2026-10-11",
      "calls": 1520
    },
    {
      "day": "2026-10-10",
      "calls": 1873
    },
    {
      "day": "2026-10-09",
      "calls": 0
    }
  ],
  "quotas": {
    "api_per_minute": 1200,
    "api_per_day": 500000,
    "api_calls_today": 1520,
    "api_day_warning": false,
    "api_day_reached": false,
    "ingest_per_second": 100,
    "ingest_burst": 3000,
    "ingest_backlog": 0
  },
  "stored": {
    "envelopes": 184220,
    "scans": 52310,
    "attachments": 1730,
    "storage_bytes": 412876800
  }
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/company/overview

Read the selected company's overview

Authentication: cookie · getCompanyOverview

Session only — not available to API tokens or OAuth clients

#274. For the selected company (X-Tenant): the counts its admins monitor on the admin home (open alerts, messages waiting for review, recalls, devices and gateways, calibrations and certifications ending, requests and changes waiting, today's work in the Vietnam calendar day, lots by status, shipments, its people and its usage), each section with state. Counts and the company's own codes only; another company's records never count. Computed at most every 30 seconds: the server serves one answer for max_age_s seconds after generated_at. Read-only and not audited (a read). no-store. Allowed for tenant_admin, auditor (view auditor: without the sections only admins may open) and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and lab users are refused (403). Not part of the partner SDK clients (x-not-in-sdk): an operation of the console's admin home.

Responses

StatusTypeDescription
200CompanyOverview
application/json

The company's overview.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

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

404Error
application/json

No such company: a platform admin named one (X-Tenant) that does not exist.

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "tenant": "coop-dl",
  "generated_at": "2026-10-17T07:32:05Z",
  "max_age_s": 30,
  "day": {
    "date": "2026-10-17",
    "starts_at": "2026-10-16T17:00:00Z",
    "time_zone": "Asia/Ho_Chi_Minh"
  },
  "view": "admin",
  "sections": {
    "alerts": {
      "state": "ok",
      "open": 7,
      "open_high": 2
    },
    "quarantine": {
      "state": "ok",
      "waiting": 3,
      "capped": false,
      "oldest_received_at": "2026-10-16T22:10:00Z"
    },
    "recalls": {
      "state": "ok",
      "recalled": 0,
      "withdrawn": 1,
      "notices_pending": 0
    },
    "fleet": {
      "state": "ok",
      "devices_active": 42,
      "devices_ready": 39,
      "devices_not_ready": 3,
      "devices_pending_approval": 1,
      "gateways_active": 4,
      "gateways_silent": 0,
      "calibrations_expired": 0,
      "calibrations_expiring": 2,
      "harvest_keys_pending": 0
    },
    "certifications": {
      "state": "ok",
      "expired": 0,
      "expiring": 1
    },
    "today": {
      "state": "ok",
      "lots_created": 6,
      "lots_capped": false,
      "harvest_kg": 1840.5,
      "harvest_areas": 3,
      "messages": 51230,
      "messages_capped": false,
      "sessions_count": 1,
      "sessions_open": [
        {
          "id": "ses-01",
          "lot": "L-2026-0412",
          "facility": "ph1",
          "line": "1"
        }
      ]
    },
    "lots": {
      "state": "ok",
      "by_status": {
        "draft": 1,
        "open": 2,
        "paused": 0,
        "closed": 5,
        "packed": 9,
        "shipped": 120,
        "recalled": 0,
        "withdrawn": 1
      }
    },
    "shipments": {
      "state": "ok",
      "open": 2,
      "departed_7d": 5,
      "recent_open": [
        {
          "code": "SHP-0091",
          "created_at": "2026-10-16T03:00:00Z"
        }
      ]
    },
    "requests": {
      "state": "ok",
      "public_reports_open": 0,
      "grower_requests_open": 1,
      "grower_requests_due_soon": 0,
      "personal_data_open": 0
    },
    "approvals": {
      "state": "ok",
      "second_admin_waiting": 0
    },
    "team": {
      "state": "ok",
      "members_active": 9,
      "invitations_pending": 2,
      "invitations_expiring": 1
    },
    "integrations": {
      "state": "ok",
      "webhooks_disabled": 0
    },
    "email": {
      "state": "ok",
      "failed_24h": 0,
      "failed_kinds": []
    },
    "usage": {
      "state": "ok",
      "limits": [
        {
          "id": "members",
          "used": 9,
          "limit": 200,
          "warning": false,
          "reached": false
        }
      ],
      "quotas": {
        "api_per_day": 500000,
        "api_calls_today": 1200,
        "api_day_warning": false,
        "api_day_reached": false
      },
      "api_calls": [
        {
          "day": "2026-10-17",
          "calls": 1200
        }
      ]
    }
  }
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/members

List the company's members

Authentication: cookie · listMembers

Session only — not available to API tokens or OAuth clients

SELF-1-4 (#185). Everyone who belongs to the selected company, by email: their role here (and an operator's facilities), platform-managed roles shown read-only, whether the company turned them off, the account status, the last sign-in and when they joined; and how many active admins the company has. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403), so no integration manages people.

Responses

StatusTypeDescription
200MemberList
application/json

The members.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "user_id": 7,
      "email": "lan@coop-dl.example",
      "display_name": "Chi Lan",
      "role": "operator",
      "facilities": [
        "VN-TGPH-021"
      ],
      "other_roles": [],
      "lab_id": null,
      "status": "active",
      "account_status": "active",
      "last_sign_in_at": 1790086400.5,
      "joined_at": 1789000000,
      "two_factor": false,
      "locked": false
    }
  ],
  "active_admins": 1
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PATCH /v1/members/{user_id}

Change a member's role or facilities

Authentication: cookie · updateMember

Session only — not available to API tokens or OAuth clients

SELF-1-4 (#185). One role per member in this company: saving replaces the member's memberships of the roles tenant_admin, operator and auditor here with one (lab and platform admin memberships are never changed; an account with only those is not a member here and answers 404: it joins the company through an invitation); the member's status here, when they joined and their notice acceptance are kept. An operator may be limited to facilities of the company. Takes effect on the member's next request. A change that takes the tenant_admin role away revokes every pending invitation and password link of this company that the member created. Changing a role to or from tenant_admin needs a password confirmed within the last 10 minutes (SELF-1-2). The last-admin rule: a change that would leave the company with no active company admin whose account is active is 409 last_admin. Audited (member.update, in the same transaction: the new role and facilities and the previous ones). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403), so no integration manages people.

Parameters

NameInTypeDescription
user_id
required
pathstring

The member's account id (from listMembers).

Request body

MemberUpdate (required)

Media type: application/json

Example request · application/json
{
  "role": "operator",
  "facilities": [
    "VN-TGPH-021"
  ]
}

Responses

StatusTypeDescription
200Member
application/json

The member, changed.

400Error
application/json

Invalid JSON, an unknown field, a missing or unknown role, facilities for a role other than operator or a facility the company does not have, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago while the change involves the company admin role (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such member of this company: no role tenant_admin, operator or auditor here (a lab-only account, or another company's member, answers like a missing one).

405Error
application/json

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

409Error
application/json

The change would leave the company without an active admin.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "user_id": 7,
  "email": "lan@coop-dl.example",
  "display_name": "Chi Lan",
  "role": "operator",
  "facilities": [
    "VN-TGPH-021"
  ],
  "other_roles": [],
  "lab_id": null,
  "status": "active",
  "account_status": "active",
  "last_sign_in_at": 1790086400.5,
  "joined_at": 1789000000,
  "two_factor": false,
  "locked": false
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · role
{
  "error": "invalid role: one of tenant_admin, operator, auditor",
  "code": "invalid_role"
}
Response 400 · application/json · facility
{
  "error": "unknown facility: VN-TGPH-999",
  "code": "unknown_facility"
}
Response 400 · application/json · unknown
{
  "error": "unknown fields: email",
  "code": "unknown_fields"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json
{
  "error": "last admin: a company needs at least one active admin",
  "code": "last_admin"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/members/{user_id}/disable

Turn a member off for this company

Authentication: cookie · disableMember

Session only — not available to API tokens or OAuth clients

SELF-1-4 (#185). Turns the member's memberships of the roles tenant_admin, operator and auditor in this company off: from the next request on they cannot act for this company and it leaves their company picker; every other company they belong to is unchanged, and the account itself (managed by CropPath) too. When they have no active membership left anywhere, their sessions end. Every pending invitation and password link of this company that they created is revoked in the same change. Needs a password confirmed within the last 10 minutes (SELF-1-2). The last-admin rule applies (409 last_admin). Audited (member.disable, in the same transaction). Repeating it changes nothing (200). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403), so no integration manages people.

Parameters

NameInTypeDescription
user_id
required
pathstring

The member's account id (from listMembers).

Idempotency-Key
optional
headerstring

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

Responses

StatusTypeDescription
200Member
application/json

The member.

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; or a session whose password was last confirmed more than 10 minutes ago (always asked here) (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No member of this company with a role it manages (tenant_admin, operator or auditor).

405Error
application/json

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

409Error
application/json

The last-admin rule (turning off the company's only active admin). Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "user_id": 7,
  "email": "lan@coop-dl.example",
  "display_name": "Chi Lan",
  "role": "operator",
  "facilities": [
    "VN-TGPH-021"
  ],
  "other_roles": [],
  "lab_id": null,
  "status": "disabled",
  "account_status": "active",
  "last_sign_in_at": 1790086400.5,
  "joined_at": 1789000000,
  "two_factor": false,
  "locked": false
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · last_admin
{
  "error": "last admin: a company needs at least one active admin",
  "code": "last_admin"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/members/{user_id}/enable

Turn a member back on for this company

Authentication: cookie · enableMember

Session only — not available to API tokens or OAuth clients

SELF-1-4 (#185). Turns the member's memberships in this company back on, as they were (role and facilities). Turning a company admin back on gives the admin role again, so it needs a password confirmed within the last 10 minutes (SELF-1-2), as inviting an admin does. Audited (member.enable, in the same transaction). Repeating it changes nothing (200). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403), so no integration manages people.

Parameters

NameInTypeDescription
user_id
required
pathstring

The member's account id (from listMembers).

Idempotency-Key
optional
headerstring

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

Responses

StatusTypeDescription
200Member
application/json

The member.

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; or, for a company admin, a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No member of this company with a role it manages (tenant_admin, operator or auditor).

405Error
application/json

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

409Error
application/json

The company has its maximum of 200 active members and pending invitations. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "user_id": 7,
  "email": "lan@coop-dl.example",
  "display_name": "Chi Lan",
  "role": "operator",
  "facilities": [
    "VN-TGPH-021"
  ],
  "other_roles": [],
  "lab_id": null,
  "status": "active",
  "account_status": "active",
  "last_sign_in_at": 1790086400.5,
  "joined_at": 1789000000,
  "two_factor": false,
  "locked": false
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · too_many_members
{
  "error": "too many members: at most 200 active members and pending invitations per company",
  "code": "too_many_members"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/members/{user_id}/two-factor/reset

Remove a member's two-step sign-in (a lost phone)

Authentication: cookie · resetMemberTwoFactor

Session only — not available to API tokens or OAuth clients

SELF-1-6 (#187). Removes the member's authenticator app, backup codes and pending sign-ins and ends every session of theirs; they sign in with the password alone and set the app up again. A company admin may reset a member who belongs to this company only and holds no platform admin or lab role (409 reset_by_support otherwise: CropPath support resets those); a platform admin acting for the company (CropPath support) may reset any member of it and must give a reason, kept in the company's activity log. Repeating it changes nothing (200). Needs a password confirmed within the last 10 minutes (SELF-1-2). Audited (auth.two_factor.reset, in the same transaction): one row in this company's activity log and, when the account belongs to other companies too (a platform admin's reset), one more row in each of their logs, which does not name this company. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403).

Parameters

NameInTypeDescription
user_id
required
pathstring

The member's account id (from listMembers).

Idempotency-Key
optional
headerstring

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

Request body

TwoFactorReset (optional)

Media type: application/json

Example request · application/json
{
  "reason": "Lost phone, confirmed by Zalo call with the company director"
}

Responses

StatusTypeDescription
200TwoFactorResetResult
application/json

Reset.

400Error
application/json

Invalid JSON, an unknown field, a platform admin without a reason or a reason that is not one line of 1 to 200 characters, or a bad Idempotency-Key; or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No member of this company with that id (another company's member answers the same).

405Error
application/json

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

409Error
application/json

Only CropPath support may reset this account (it belongs to another company too, or holds a platform admin or lab role); or the Idempotency-Key is in use.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "user_id": 7,
  "two_factor": false,
  "sessions_revoked": 1
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · reason_required
{
  "error": "reason is required",
  "code": "reason_is_required"
}
Response 400 · application/json · reason
{
  "error": "invalid reason: 1 to 200 characters on one line",
  "code": "invalid_reason"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · reset_by_support
{
  "error": "reset by support: this account can only be reset by CropPath support",
  "code": "reset_by_support"
}
Response 409 · application/json · in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/members/{user_id}/sessions/revoke

Sign a member out everywhere (a lost phone)

Authentication: cookie · revokeMemberSessions

Session only — not available to API tokens or OAuth clients

SELF-2-1 (#190). Ends every session of the member, on every device; they sign in again with their password (and the second step, when on). Sessions belong to the person, not to a company, so this signs them out of every company they work for: a company admin may do it only for a member who belongs to this company alone and holds no platform admin or lab role (409 sign_out_by_support otherwise, which never names the other company: CropPath support does it); a platform admin acting for the company (CropPath support) may do it for any member of it and must give a reason, kept in the company's activity log. Another company's person answers 404 like a missing one. Repeating it ends nothing more (200). Needs a password confirmed within the last 10 minutes (SELF-1-2). Audited (member.sessions.revoke, in the same transaction, with how many were ended). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403).

Parameters

NameInTypeDescription
user_id
required
pathstring

The member's account id (from listMembers).

Idempotency-Key
optional
headerstring

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

Request body

MemberSessionsRevoke (optional)

Media type: application/json

Example request · application/json
{
  "reason": "Phone lost at the collection point, confirmed by the company director"
}

Responses

StatusTypeDescription
200MemberSessionsRevoked
application/json

Signed out everywhere.

400Error
application/json

Invalid JSON, an unknown field, a platform admin without a reason or a reason that is not one line of 1 to 200 characters, or a bad Idempotency-Key; or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No member of this company with that id (another company's member answers the same).

405Error
application/json

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

409Error
application/json

Only CropPath support may sign this account out (it belongs to another company too, or holds a platform admin or lab role); or the Idempotency-Key is in use.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "user_id": 7,
  "sessions_revoked": 2
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · reason_required
{
  "error": "reason is required",
  "code": "reason_is_required"
}
Response 400 · application/json · reason
{
  "error": "invalid reason: 1 to 200 characters on one line",
  "code": "invalid_reason"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · sign_out_by_support
{
  "error": "sign out by support: only CropPath support can end this account's sessions",
  "code": "sign_out_by_support"
}
Response 409 · application/json · in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/members/{user_id}/unlock

Clear a member's sign-in lockout

Authentication: cookie · unlockMember

Session only — not available to API tokens or OAuth clients

SELF-2-10 (#199). Clears the login lockout of the member's email: wrong passwords and wrong two-step codes count together (10 in a row lock sign-in for 15 minutes), so one unlock clears both, and the count starts afresh. Nothing else changes: no session is opened or ended, a used-up sign-in step is not brought back (the person signs in with the password again), and a member turned off for this company stays turned off. The lockout belongs to the email, so it is shared by every company of the account: a company admin may unlock a member who belongs to this company only and holds no platform admin or lab role (409 unlock_by_support otherwise: CropPath support unlocks those); a platform admin acting for the company (CropPath support) may unlock any member of it. Repeating it changes nothing (200, was_locked false). Needs a password confirmed within the last 10 minutes (SELF-1-2). Audited (member.unlock, in the same transaction, one row in this company's activity log; never the email or a failure count). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403).

Parameters

NameInTypeDescription
user_id
required
pathstring

The member's account id (from listMembers).

Idempotency-Key
optional
headerstring

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

Responses

StatusTypeDescription
200MemberUnlockResult
application/json

Unlocked.

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; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No member of this company with that id (another company's member answers the same).

405Error
application/json

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

409Error
application/json

Only CropPath support may unlock this account (it belongs to another company too, or holds a platform admin or lab role); or the Idempotency-Key is in use.

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "user_id": 7,
  "locked": false,
  "was_locked": true
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · unlock_by_support
{
  "error": "unlock by support: only CropPath support can unlock this account",
  "code": "unlock_by_support"
}
Response 409 · application/json · in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/invitations

List the company's invitations and password links

Authentication: cookie · listInvitations

Session only — not available to API tokens or OAuth clients

SELF-1-4 (#185). The company's invitation links and password links (purpose), newest first, one page: pending, used, expired and revoked, with who created them and when; never a link or its token. The platform's admin recovery links are not listed. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403), so no integration manages people.

Parameters

NameInTypeDescription
status
optional
query"pending" | "used" | "expired" | "revoked"

Only the links in this state.

limit
optional
queryinteger

1 to 200 (default 100).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200InvitationList
application/json

The invitations and password links.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 12,
      "purpose": "invite",
      "email": "new.colleague@coop-dl.example",
      "role": "operator",
      "facilities": null,
      "display_name": "Anh Minh",
      "status": "pending",
      "created_by": "boss@coop-dl.example",
      "created_at": 1790000000,
      "expires_at": 1790259200,
      "used_at": null,
      "used_by": null,
      "revoked_at": null,
      "revoked_by": null
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · status
{
  "error": "invalid status: one of pending, used, expired, revoked",
  "code": "invalid_status"
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/invitations

Invite a colleague (link shown once)

Authentication: cookie · createInvitation

Session only — not available to API tokens or OAuth clients

SELF-1-4 (#185). A one-time link (72 hours) with which the person chooses a password and joins the company in role (or, when the email has a CropPath account, signs in with it and joins: the answer is the same either way). Returned once (no-store); only the SHA-256 of its token is stored. An email that is already an active member of this company is 409 already_a_member. Inviting a company admin needs a password confirmed within the last 10 minutes (SELF-1-2). The company holds at most 200 active members and pending invitations, 50 pending links and 30 new links an hour. Audited (account_link.create, in the same transaction: purpose invite, role, expiry; never the link). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403), so no integration manages people.

Request body

InvitationCreate (required)

Media type: application/json

Example request · application/json
{
  "email": "new.colleague@coop-dl.example",
  "role": "operator",
  "facilities": null,
  "display_name": "Anh Minh"
}

Responses

StatusTypeDescription
201AccountLinkCreated
application/json

The link, shown this once.

400Error
application/json

Invalid JSON, an unknown field, a bad email, role, display name or facility, facilities for a role other than operator, or a bad X-Request-Id; or an Idempotency-Key header, which this operation refuses: its response holds the link, whose token is never stored.

401Error
application/json

No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago while inviting a company admin (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such company (a platform admin's X-Tenant names none).

405Error
application/json

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

409Error
application/json

The email is already an active member, or a company cap is reached.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Response headers

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

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

Example responses

Response 201 · application/json
{
  "id": 12,
  "link": "https://txng.theio.vn/login#invite=agi_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGxl",
  "expires_at": 1790259200.5,
  "emailed": true
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · email
{
  "error": "invalid email",
  "code": "invalid_email"
}
Response 400 · application/json · role
{
  "error": "invalid role: one of tenant_admin, operator, auditor",
  "code": "invalid_role"
}
Response 400 · application/json · facility
{
  "error": "unknown facility: VN-TGPH-999",
  "code": "unknown_facility"
}
Response 400 · application/json · unknown
{
  "error": "unknown fields: reason",
  "code": "unknown_fields"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · idempotency_key_not_supported
{
  "error": "idempotency key not supported",
  "code": "idempotency_key_not_supported"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: coop-new",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · already_a_member
{
  "error": "already a member: this email is already an active member of the company",
  "code": "already_a_member"
}
Response 409 · application/json · too_many_members
{
  "error": "too many members: at most 200 active members and pending invitations per company",
  "code": "too_many_members"
}
Response 409 · application/json · pending
{
  "error": "too many pending links: at most 50 per company",
  "code": "too_many_pending_links"
}
Response 409 · application/json · hourly
{
  "error": "too many links: at most 30 per company per hour",
  "code": "too_many_links"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/invitations/{id}/revoke

Revoke a pending invitation or password link

Authentication: cookie · revokeInvitation

Session only — not available to API tokens or OAuth clients

SELF-1-4 (#185). The invitation or password link stops working at once. Audited (account_link.revoke, in the same transaction, with the link's purpose). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403), so no integration manages people.

Parameters

NameInTypeDescription
id
required
pathstring

The link id (from listInvitations).

Idempotency-Key
optional
headerstring

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

Responses

StatusTypeDescription
200InvitationRevoked
application/json

The link, revoked.

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 (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No pending invitation or password link of this company with this id (used, revoked, the platform's admin recovery link, or another company's).

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

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "id": 12,
  "status": "revoked"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 12",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/api-tokens

The tenant's API tokens

Authentication: cookie · listApiTokens

Session only — not available to API tokens or OAuth clients

Newest first, one page (limit, default 50, at most 200; cursor from the previous page), every status. Never returns a token or its hash. Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a session only. Not audited (a read). no-store.

Parameters

NameInTypeDescription
limit
optional
queryinteger

1 to 200 (default 50).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200ApiTokenPage
application/json

One page of tokens.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token or the legacy token is refused), tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 7,
      "name": "erp-sync",
      "role": "operator",
      "created_by": "admin@coop.example",
      "created_at": 1790000000.5,
      "last_used_at": null,
      "expires_at": 1797776000.5,
      "revoked_at": null,
      "revoke_reason": null,
      "revoked_by": null,
      "status": "active"
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/api-tokens

Create an API token (shown once)

Authentication: cookie · createApiToken

Session only — not available to API tokens or OAuth clients

Creates a token of the caller's tenant and returns it once, in secret (no-store); only its SHA-256 is stored, so no later read returns it. A tenant holds at most 100 live tokens. Audited (api_token.create, in the same transaction: the token id, name, role and expiry, never the token). Allowed for tenant_admin and platform_admin acting for the tenant, through a session only. A session must have confirmed its password within the last 10 minutes (SELF-1-2, #183), else 401 reauthentication_required before anything is done.

Request body

ApiTokenCreate (required)

Media type: application/json

Example request · application/json
{
  "name": "erp-sync",
  "role": "operator",
  "expires_in_days": 90
}

Responses

StatusTypeDescription
201ApiTokenCreated
application/json

The token, with the secret shown this once.

400Error
application/json

Invalid JSON, an unknown field, a bad name, role or expiry, or a bad X-Request-Id; or an Idempotency-Key header, which this operation refuses: its response holds the token secret, which is never stored.

401Error
application/json

No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

405Error
application/json

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

409Error
application/json

The tenant already holds 100 live tokens: revoke one first.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Response headers

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

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id500string

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

Example responses

Response 201 · application/json
{
  "token": {
    "id": 7,
    "name": "erp-sync",
    "role": "operator",
    "created_by": "admin@coop.example",
    "created_at": 1790000000.5,
    "last_used_at": null,
    "expires_at": 1797776000.5,
    "revoked_at": null,
    "revoke_reason": null,
    "revoked_by": null,
    "status": "active"
  },
  "secret": "agt_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGx"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · name
{
  "error": "invalid name: a letter or digit, then up to 63 letters, digits, '.', '_' or '-'",
  "code": "invalid_name"
}
Response 400 · application/json · role
{
  "error": "invalid role: one of tenant_admin, operator, auditor",
  "code": "invalid_role"
}
Response 400 · application/json · expiry
{
  "error": "invalid expires_in_days: a whole number of days from 1 to 3650, or null",
  "code": "invalid_expires_in_days"
}
Response 400 · application/json · unknown
{
  "error": "unknown fields: tenant",
  "code": "unknown_fields"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · idempotency_key_not_supported
{
  "error": "idempotency key not supported",
  "code": "idempotency_key_not_supported"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json
{
  "error": "token limit reached: at most 100 live tokens per tenant",
  "code": "token_limit_reached"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/api-tokens/{id}/revoke

Revoke an API token

Authentication: cookie · revokeApiToken

Session only — not available to API tokens or OAuth clients

Revokes one of the tenant's tokens with a reason; it stops authenticating at once. A revoked token stays listed (no DELETE). Audited (api_token.revoke, in the same transaction, with the reason). Allowed for tenant_admin and platform_admin acting for the tenant, through a session only; another tenant's token answers like a missing one.

Parameters

NameInTypeDescription
id
required
pathstring

The token id.

Idempotency-Key
optional
headerstring

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

Request body

ApiTokenRevoke (required)

Media type: application/json

Example request · application/json
{
  "reason": "leaked in a CI log"
}

Responses

StatusTypeDescription
200ApiToken
application/json

The token, revoked.

400Error
application/json

Invalid JSON, an unknown field or a missing, blank, multi-line or longer than 200 characters 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.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such token of this tenant (another tenant's answers like a missing one).

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "id": 7,
  "name": "erp-sync",
  "role": "operator",
  "created_by": "admin@coop.example",
  "created_at": 1790000000.5,
  "last_used_at": null,
  "expires_at": 1797776000.5,
  "revoked_at": 1790003600.5,
  "revoke_reason": "leaked in a CI log",
  "revoked_by": "admin@coop.example",
  "status": "revoked"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · reason
{
  "error": "invalid reason: 1 to 200 characters on one line",
  "code": "invalid_reason"
}
Response 400 · application/json · unknown
{
  "error": "unknown fields: role",
  "code": "unknown_fields"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · token_already_revoked
{
  "error": "token already revoked",
  "code": "token_already_revoked"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/oauth-clients

The tenant's OAuth2 API clients

Authentication: cookie · listOAuthClients

Session only — not available to API tokens or OAuth clients

Newest first, one page (limit, default 50, at most 200; cursor from the previous page), every status. Never returns a secret or its hash. Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a session only. Not audited (a read). no-store.

Parameters

NameInTypeDescription
limit
optional
queryinteger

1 to 200 (default 50).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200OAuthClientPage
application/json

One page of clients.

400Error
application/json

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

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an OAuth2 access token or the legacy token is refused), tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 3,
      "client_id": "agc_V2hhdCBhIGNsaWVudCBpZA",
      "name": "erp-sync",
      "role": "operator",
      "scopes": [
        "lot_read",
        "lot_write"
      ],
      "facilities": [
        "VN-TGPH-021"
      ],
      "created_by": "admin@coop.example",
      "created_at": 1790000000.5,
      "last_token_at": null,
      "revoked_at": null,
      "revoke_reason": null,
      "revoked_by": null,
      "status": "active"
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/oauth-clients

Register an OAuth2 API client (secret shown once)

Authentication: cookie · createOAuthClient

Session only — not available to API tokens or OAuth clients

Registers an API client of the caller's tenant and returns its secret once, in client_secret (no-store); only its SHA-256 is stored, so no later read returns it. scopes are permissions (the names of the API's route policies) the client's role can hold; facilities limits an operator client to some of the tenant's facilities. A tenant holds at most 50 live clients. Audited (oauth_client.create, in the same transaction: the client id, name, role, scopes and facilities, never the secret). Allowed for tenant_admin and platform_admin acting for the tenant, through a session only. An Idempotency-Key header is refused (400 idempotency_key_not_supported): the response would hold a secret. A session must have confirmed its password within the last 10 minutes (SELF-1-2, #183), else 401 reauthentication_required before anything is done. #205: the client expires 365 days after it is created (renew it with POST /v1/oauth-clients/{id}/renew), accepts any source address until PUT /v1/oauth-clients/{id}/allowed-ips limits it, and its scopes never change afterwards (a wider client is a new one, which again needs the recent password). The audit row also holds the expiry and broad_scope (whether a scope opens a write); GET /v1/oauth-clients/details shows both.

Request body

OAuthClientCreate (required)

Media type: application/json

Example request · application/json
{
  "name": "erp-sync",
  "role": "operator",
  "scopes": [
    "lot_read",
    "lot_write"
  ],
  "facilities": [
    "VN-TGPH-021"
  ]
}

Responses

StatusTypeDescription
201OAuthClientCreated
application/json

The client, with its secret shown this once.

400Error
application/json

Invalid JSON, an unknown field, a bad name or role, scopes the role cannot hold, facilities with a role other than operator or not of the tenant, or a bad X-Request-Id.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an OAuth2 access token or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

405Error
application/json

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

409Error
application/json

The tenant already holds 50 live clients.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Response headers

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

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id500string

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

Example responses

Response 201 · application/json
{
  "client": {
    "id": 3,
    "client_id": "agc_V2hhdCBhIGNsaWVudCBpZA",
    "name": "erp-sync",
    "role": "operator",
    "scopes": [
      "lot_read",
      "lot_write"
    ],
    "facilities": [
      "VN-TGPH-021"
    ],
    "created_by": "admin@coop.example",
    "created_at": 1790000000.5,
    "last_token_at": null,
    "revoked_at": null,
    "revoke_reason": null,
    "revoked_by": null,
    "status": "active"
  },
  "client_secret": "acs_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGx"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · scopes
{
  "error": "invalid scopes: not a permission the auditor role can be granted: review",
  "code": "invalid_scopes"
}
Response 400 · application/json · facilities
{
  "error": "invalid facilities: not a facility of the tenant",
  "code": "invalid_facilities"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json
{
  "error": "client limit reached: at most 50 live API clients per tenant",
  "code": "client_limit_reached"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/oauth-clients/{id}/revoke

Revoke an OAuth2 API client

Authentication: cookie · revokeOAuthClient

Session only — not available to API tokens or OAuth clients

Revokes one of the tenant's API clients with a reason: it gets no new token and every token it holds stops authenticating at once. A revoked client stays listed (no DELETE). Audited (oauth_client.revoke, in the same transaction, with the reason). Allowed for tenant_admin and platform_admin acting for the tenant, through a session only; another tenant's client answers like a missing one. #205: its live access tokens are marked revoked in the same transaction (the audit row holds how many, tokens_revoked).

Parameters

NameInTypeDescription
id
required
pathstring

The client's row id (id).

Idempotency-Key
optional
headerstring

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

Request body

OAuthClientRevoke (required)

Media type: application/json

Example request · application/json
{
  "reason": "contract ended"
}

Responses

StatusTypeDescription
200OAuthClient
application/json

The client, revoked.

400Error
application/json

Invalid JSON, an unknown field or a missing, blank, multi-line or longer than 200 characters reason, or a bad X-Request-Id.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an OAuth2 access token or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such client of this tenant (another tenant's answers like a missing one).

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "id": 3,
  "client_id": "agc_V2hhdCBhIGNsaWVudCBpZA",
  "name": "erp-sync",
  "role": "operator",
  "scopes": [
    "lot_read",
    "lot_write"
  ],
  "facilities": [
    "VN-TGPH-021"
  ],
  "created_by": "admin@coop.example",
  "created_at": 1790000000.5,
  "last_token_at": null,
  "revoked_at": 1790003600.5,
  "revoke_reason": "contract ended",
  "revoked_by": "admin@coop.example",
  "status": "revoked"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · reason
{
  "error": "invalid reason: 1 to 200 characters on one line",
  "code": "invalid_reason"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · client_already_revoked
{
  "error": "client already revoked",
  "code": "client_already_revoked"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/oauth-clients/details

The tenant's OAuth2 API clients with expiry, sources and last use

Authentication: cookie · listOAuthClientDetails

Session only — not available to API tokens or OAuth clients

#205. Newest first, one page (limit, default 50, at most 200; cursor from the previous page), every status, like GET /v1/oauth-clients plus each client's expiry (expires_at, expired), allowed source networks, last use (time, and a keyed hash of the source address, never the address) and write scopes (broad_scope). A use is recorded at most once a minute per client and shown within seconds. Never returns a secret or its hash. Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a signed-in session only: an API token, an API client or the legacy token is refused (403). Not audited (a read). no-store. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.

Parameters

NameInTypeDescription
limit
optional
queryinteger

1 to 200 (default 50).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200OAuthClientDetailPage
application/json

One page of clients.

400Error
application/json

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

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an OAuth2 access token or the legacy token is refused), tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 3,
      "client_id": "agc_V2hhdCBhIGNsaWVudCBpZA",
      "name": "erp-sync",
      "role": "operator",
      "scopes": [
        "lot_read",
        "lot_write"
      ],
      "facilities": [
        "VN-TGPH-021"
      ],
      "created_by": "admin@coop.example",
      "created_at": 1790000000.5,
      "last_token_at": 1790003600.5,
      "revoked_at": null,
      "revoke_reason": null,
      "revoked_by": null,
      "status": "active",
      "expires_at": 1821536000.5,
      "expired": false,
      "allowed_ips": [
        "203.0.113.0/24"
      ],
      "last_used_at": 1790003660.5,
      "last_used_ip_hash": "5b1f0c3e9a7d2b4c6e8f0a1b3c5d7e9f1a2b4c6d8e0f1a3b5c7d9e1f2a4b6c8d",
      "write_scopes": [
        "lot_write"
      ],
      "broad_scope": true
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/oauth-clients/{id}/renew

Renew an OAuth2 API client

Authentication: cookie · renewOAuthClient

Session only — not available to API tokens or OAuth clients

#205. Sets the client's expiry to expires_in_days (1 to 730, default 365) from now, whether or not it has expired; an expired client gets tokens again at once. It may also shorten the lifetime. A revoked client cannot be renewed (409). Audited (oauth_client.renew, in the same transaction: the previous and the new expiry). Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a signed-in session only: an API token, an API client or the legacy token is refused (403). Another tenant's client answers like a missing one. A session must have confirmed its password within the last 10 minutes (SELF-1-2, #183), else 401 reauthentication_required before anything is done. no-store. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.

Parameters

NameInTypeDescription
id
required
pathstring

The client's row id (id).

Idempotency-Key
optional
headerstring

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

Request body

OAuthClientRenew (required)

Media type: application/json

Example request · application/json
{
  "expires_in_days": 365
}

Responses

StatusTypeDescription
200OAuthClientDetail
application/json

The client, renewed.

400Error
application/json

Invalid JSON, an unknown field, expires_in_days not a whole number from 1 to 730, or a bad X-Request-Id or Idempotency-Key.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an OAuth2 access token or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such client of this tenant (another tenant's answers like a missing one).

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

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.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "id": 3,
  "client_id": "agc_V2hhdCBhIGNsaWVudCBpZA",
  "name": "erp-sync",
  "role": "operator",
  "scopes": [
    "lot_read",
    "lot_write"
  ],
  "facilities": [
    "VN-TGPH-021"
  ],
  "created_by": "admin@coop.example",
  "created_at": 1790000000.5,
  "last_token_at": 1790003600.5,
  "revoked_at": null,
  "revoke_reason": null,
  "revoked_by": null,
  "status": "active",
  "expires_at": 1821536000.5,
  "expired": false,
  "allowed_ips": [
    "203.0.113.0/24"
  ],
  "last_used_at": 1790003660.5,
  "last_used_ip_hash": "5b1f0c3e9a7d2b4c6e8f0a1b3c5d7e9f1a2b4c6d8e0f1a3b5c7d9e1f2a4b6c8d",
  "write_scopes": [
    "lot_write"
  ],
  "broad_scope": true
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · expires_in_days
{
  "error": "invalid expires_in_days: a whole number of days from 1 to 730",
  "code": "invalid_expires_in_days"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · client_revoked
{
  "error": "client revoked",
  "code": "client_revoked"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/oauth-clients/{id}/allowed-ips

Set the source networks an OAuth2 API client may call from

Authentication: cookie · setOAuthClientAllowedIps

Session only — not available to API tokens or OAuth clients

#205. Replaces the client's allowed source networks (allowed_ips: 1 to 20 distinct IPv4 or IPv6 networks in CIDR form, normalised; null: any source). The token endpoint, the revocation endpoint and every call made with the client's tokens check the address the API sees (CF-Connecting-IP from a trusted proxy, else the connection's; an IPv4-mapped IPv6 address also matches its IPv4 network): from any other source the client gets invalid_client and its tokens 401 missing_or_invalid_token, like a wrong credential, so a refusal never reveals the list. Its live tokens follow at once. A revoked client is 409. Audited (oauth_client.allowed_ips, in the same transaction: whether a list was and is set, how many networks and a keyed hash (an HMAC under the server's hash secret) of each list, never the networks). Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a signed-in session only: an API token, an API client or the legacy token is refused (403). Another tenant's client answers like a missing one. A session must have confirmed its password within the last 10 minutes (SELF-1-2, #183), else 401 reauthentication_required before anything is done. no-store. Not in SDK 0.2.0 (x-not-in-sdk): its bytes never change; a later SDK version adds it.

Parameters

NameInTypeDescription
id
required
pathstring

The client's row id (id).

Request body

OAuthClientAllowedIps (required)

Media type: application/json

Example request · application/json
{
  "allowed_ips": [
    "203.0.113.0/24",
    "2001:db8::/32"
  ]
}

Responses

StatusTypeDescription
200OAuthClientDetail
application/json

The client with its new allowed sources.

400Error
application/json

Invalid JSON, an unknown or missing field, a value that is not 1 to 20 distinct networks in CIDR form (or null), or a bad X-Request-Id.

401Error
application/json

No valid session, API token, OAuth2 access token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an OAuth2 access token or the legacy token is refused), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such client of this tenant (another tenant's answers like a missing one).

405Error
application/json

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

409Error
application/json

The client is revoked.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "id": 3,
  "client_id": "agc_V2hhdCBhIGNsaWVudCBpZA",
  "name": "erp-sync",
  "role": "operator",
  "scopes": [
    "lot_read",
    "lot_write"
  ],
  "facilities": [
    "VN-TGPH-021"
  ],
  "created_by": "admin@coop.example",
  "created_at": 1790000000.5,
  "last_token_at": 1790003600.5,
  "revoked_at": null,
  "revoke_reason": null,
  "revoked_by": null,
  "status": "active",
  "expires_at": 1821536000.5,
  "expired": false,
  "allowed_ips": [
    "203.0.113.0/24"
  ],
  "last_used_at": 1790003660.5,
  "last_used_ip_hash": "5b1f0c3e9a7d2b4c6e8f0a1b3c5d7e9f1a2b4c6d8e0f1a3b5c7d9e1f2a4b6c8d",
  "write_scopes": [
    "lot_write"
  ],
  "broad_scope": true
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · allowed_ips
{
  "error": "invalid allowed_ips: 1 to 20 distinct IPv4 or IPv6 networks in CIDR form, or null",
  "code": "invalid_allowed_ips"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json
{
  "error": "client revoked",
  "code": "client_revoked"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/account/personal-data

See the personal data held about me in this company

Authentication: cookie · getMyPersonalData

Session only — not available to API tokens or OAuth clients

SELF-2-9 (#198). What the platform holds about the caller in the selected company (X-Tenant): name and email, role (and an operator's facilities), membership and account status, when they joined and accepted the staff privacy notice, whether two-step sign-in is on and the times of the most recent sign-ins. Never a secret. Allowed for only tenant_admin, operator and auditor, through a signed-in session: an API token, an API client or the legacy token is refused; a lab user and a platform admin acting for the company are refused (403).

Parameters

NameInTypeDescription
agronomist
optional
query"0" | "1"

#351: 1 adds agronomist, the caller's row of the platform's agronomist registry (null without one); 0 or none leaves it out and answers exactly as before; any other value is refused (400 bad agronomist).

Responses

StatusTypeDescription
200PersonalData
application/json

The member's personal data in this company.

400Error
application/json

A bad agronomist (#351), or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

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

404Error
application/json

The caller has no membership in the selected company.

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "user_id": 7,
  "email": "op@coop.example",
  "display_name": "Lan",
  "company": {
    "id": "coop-dl",
    "name": "Coop DL"
  },
  "roles": [
    "operator"
  ],
  "facilities": [
    "VN-TGPH-021"
  ],
  "lab_id": null,
  "membership_status": "active",
  "account_status": "active",
  "account_created_at": 1789000000.5,
  "joined_at": 1789000000.5,
  "notice_accepted_at": 1789000000.5,
  "two_factor": true,
  "recent_sign_ins": [
    1790000000.5,
    1789900000.5
  ]
}
Response 400 · application/json · bad_agronomist
{
  "error": "bad agronomist: 0 or 1",
  "code": "bad_agronomist"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 404 · application/json
{
  "error": "not found: membership",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/account/personal-data-requests

List my requests about my personal data

Authentication: cookie · listMyPersonalDataRequests

Session only — not available to API tokens or OAuth clients

SELF-2-9 (#198). The requests the caller sent in the selected company (X-Tenant), newest first, with their status. Allowed for only tenant_admin, operator and auditor, through a signed-in session: an API token, an API client or the legacy token is refused; a lab user and a platform admin acting for the company are refused (403).

Parameters

NameInTypeDescription
limit
optional
queryinteger

1 to 200 (default 50).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200PersonalDataRequestPage
application/json

One page of requests.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

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

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 4,
      "kind": "correction",
      "text": "My name is spelled Nguyễn Văn An, not Nguyen Van A.",
      "status": "handled",
      "created_at": 1790000000.5,
      "handled_at": 1790003600.5
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/account/personal-data-requests

Ask my company to show more of or correct my personal data

Authentication: cookie · createPersonalDataRequest

Session only — not available to API tokens or OAuth clients

SELF-2-9 (#198). Sends the selected company's (X-Tenant) admins a request from the caller: access (show me more of the personal data you hold about me) or correction (correct it), with a plain-text message. The company is the controller of its members' data, so the request goes to its admins (the list on the Team screen), not to CropPath; there is no email. Stored as plain text exactly as typed (trimmed). At most 5 requests per person per day (across every company) and 50 per company per day (429). Audited (personal_data_request.create, in the same transaction; never the text). Allowed for only tenant_admin, operator and auditor, through a signed-in session: an API token, an API client or the legacy token is refused; a lab user and a platform admin acting for the company are refused (403).

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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

Request body

PersonalDataRequestCreate (required)

Media type: application/json

Example request · application/json
{
  "kind": "correction",
  "text": "My name is spelled Nguyễn Văn An, not Nguyen Van A."
}

Responses

StatusTypeDescription
201PersonalDataRequest
application/json

The request, as the member sees it.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

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

404Error
application/json

The caller has no active membership in the selected company.

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

429Error
application/json

Too many requests sent: at most 5 per person per day (code too_many_personal_data_requests) and 50 per company per day (code too_many_personal_data_requests_company, reached by the company's members together). Nothing was stored; retry after Retry-After seconds.

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id201string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-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-Id429string

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

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

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

Example responses

Response 201 · application/json
{
  "id": 4,
  "kind": "correction",
  "text": "My name is spelled Nguyễn Văn An, not Nguyen Van A.",
  "status": "open",
  "created_at": 1790000000.5,
  "handled_at": null
}
Response 400 · application/json · kind
{
  "error": "invalid kind: one of access, correction",
  "code": "invalid_kind"
}
Response 400 · application/json · text
{
  "error": "invalid text: required, text of at most 2000 characters",
  "code": "invalid_text"
}
Response 400 · application/json · unknown
{
  "error": "unknown field: email",
  "code": "unknown_field"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: membership",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 429 · application/json · person
{
  "error": "too many personal data requests: at most 5 per person per day",
  "code": "too_many_personal_data_requests"
}
Response 429 · application/json · company
{
  "error": "too many personal data requests (company): at most 50 per company per day",
  "code": "too_many_personal_data_requests_company"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/personal-data-requests

List the company's personal data requests

Authentication: cookie · listCompanyPersonalDataRequests

Session only — not available to API tokens or OAuth clients

SELF-2-9 (#198). Every request the selected company's (X-Tenant) members sent about their personal data, newest first, with who sent it; status narrows the list. Allowed for only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused (403).

Parameters

NameInTypeDescription
status
optional
query"open" | "handled"

Only requests of this status.

limit
optional
queryinteger

1 to 200 (default 50).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200CompanyPersonalDataRequestPage
application/json

One page of requests.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 4,
      "kind": "correction",
      "text": "My name is spelled Nguyễn Văn An, not Nguyen Van A.",
      "status": "handled",
      "created_at": 1790000000.5,
      "handled_at": 1790003600.5,
      "user": {
        "id": 7,
        "email": "op@coop.example",
        "display_name": "Lan"
      },
      "handled_by": "admin@coop.example"
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · status
{
  "error": "invalid status: one of open, handled",
  "code": "invalid_status"
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/personal-data-requests/{id}/handled

Mark a personal data request handled

Authentication: cookie · markPersonalDataRequestHandled

Session only — not available to API tokens or OAuth clients

SELF-2-9 (#198). A company admin marks a member's request handled once they have dealt with it; final. The member then sees the status and when it changed. Another company's request answers 404. Audited (personal_data_request.handle, in the same transaction; never the text). Allowed for only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused (403).

Parameters

NameInTypeDescription
id
required
pathstring

The request id.

Idempotency-Key
optional
headerstring

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

Responses

StatusTypeDescription
200CompanyPersonalDataRequest
application/json

The request, handled.

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 (only tenant_admin and platform_admin (acting for the company through X-Tenant), through a signed-in session: an API token, an API client or the legacy token is refused); tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only once the company has left CropPath; during its 30-day read-only window this stays open (owner decision A).

404Error
application/json

No personal data request with this id in the selected company.

405Error
application/json

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

409Error
application/json

The request was already handled; or the Idempotency-Key's first request is still running (Retry-After), or it ran but 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.

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

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.

Example responses

Response 200 · application/json
{
  "id": 4,
  "kind": "correction",
  "text": "My name is spelled Nguyễn Văn An, not Nguyen Van A.",
  "status": "handled",
  "created_at": 1790000000.5,
  "handled_at": 1790003600.5,
  "user": {
    "id": 7,
    "email": "op@coop.example",
    "display_name": "Lan"
  },
  "handled_by": "admin@coop.example"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 4",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · handled
{
  "error": "already handled: this request was already marked handled",
  "code": "already_handled"
}
Response 409 · application/json · idempotency
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/company/offboarding

Whether the company is leaving CropPath

Authentication: cookie · getCompanyOffboarding

Session only — not available to API tokens or OAuth clients

SELF-2-4 (#193). The selected company's (X-Tenant) departure state: active, leaving (with the end of its read-only window, for the banner every member of the company sees; its admins' links to the full data export) or left. Allowed for the company's tenant_admin, operator and auditor members and platform_admin (acting for the company through X-Tenant) through a signed-in session only: an API token, an API client or the legacy token is refused (403); a lab user is refused (403).

Responses

StatusTypeDescription
200CompanyOffboarding
application/json

The company's departure state.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin, operator, auditor and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), or two-factor required (this session must prove a second factor before acting for the company).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "status": "leaving",
  "retention_years": 5,
  "started_at": 1790000000.5,
  "window_ends_at": 1792592000.5,
  "left_at": null,
  "retention_ends_at": 1949858000.5,
  "steps_done": 0
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/company/four-eyes

Read the company's second admin approval setting

Authentication: cookie · getCompanyFourEyes

Session only — not available to API tokens or OAuth clients

INTEGRITY-3 (#203). Whether the selected company's critical actions wait for a second admin, its active company admins and the requests waiting for a decision. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant: CropPath support) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Responses

StatusTypeDescription
200FourEyesState
application/json

The setting.

400Error
application/json

A bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "require_second_admin": true,
  "admins": 2,
  "pending": 1,
  "expires_after_s": 259200
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/company/four-eyes

Require a second admin for critical actions, or stop

Authentication: cookie · updateCompanyFourEyes

Session only — not available to API tokens or OAuth clients

INTEGRITY-3 (#203). While require_second_admin is on, these actions of the company answer 403 second_admin_approval_required when called directly and change nothing: registering or rotating a device or gateway key (POST /v1/keys), approving a harvest app's key (POST /v1/harvest-keys/{kid}/approve), creating or rotating a facility's issuer key (POST /v1/facilities/{code}/issuer-keys), changing grading rules (PUT /v1/grading-rules/{variety}) and changing who must use two-step sign-in (PUT /v1/company/security). An admin asks for one with POST /v1/approval-requests and another admin approves it. Turning it on takes effect at once; turning it off while it is on is itself such an action (403 second_admin_approval_required: ask for {"require_second_admin": false} instead). Needs a password confirmed within the last 10 minutes. Audited (company.four_eyes.update, in the same transaction). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant: CropPath support) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Request body

FourEyesUpdate (required)

Media type: application/json

Example request · application/json
{
  "require_second_admin": true
}

Responses

StatusTypeDescription
200FourEyesState
application/json

The setting, as stored.

400Error
application/json

Invalid JSON, an unknown field, or require_second_admin missing or not true or false; or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left. Also second admin approval required: turning it off while it is on.

404Error
application/json

No such company: a platform admin named one (X-Tenant) that does not exist.

405Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

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

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "require_second_admin": true,
  "admins": 2,
  "pending": 1,
  "expires_after_s": 259200
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_fields
{
  "error": "unknown fields: required",
  "code": "unknown_fields"
}
Response 400 · application/json · type
{
  "error": "require_second_admin must be true or false",
  "code": "require_second_admin_must_be_true_or_false"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 403 · application/json · second_admin_approval_required
{
  "error": "second admin approval required: ask for this action with POST /v1/approval-requests, and another admin of the company approves it",
  "code": "second_admin_approval_required"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/approval-requests

List the company's second admin approval requests

Authentication: cookie · listApprovalRequests

Session only — not available to API tokens or OAuth clients

INTEGRITY-3 (#203). The selected company's approval requests, newest first, one page: those waiting for a decision (status=pending, the default) or every request (status=all, an undecided one past its time shown expired). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant: CropPath support) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Parameters

NameInTypeDescription
status
optional
query"pending" | "all"

pending (default) or all.

limit
optional
queryinteger

1 to 100 (default 50).

cursor
optional
querystring

The previous page's next_cursor.

Responses

StatusTypeDescription
200ApprovalRequestPage
application/json

One page of requests.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": 17,
      "action": "key.create",
      "method": "POST",
      "path": "/v1/keys",
      "body": {
        "kid": "gw-01-k2",
        "owner_type": "gateway",
        "owner_id": "gw-01",
        "public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n"
      },
      "status": "pending",
      "requested_by": "admin@coop.example",
      "requested_by_user_id": 12,
      "requested_at": 1797000000.5,
      "expires_at": 1797259200.5,
      "decided_by": null,
      "decided_as": null,
      "decided_at": null,
      "reason": null
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · status
{
  "error": "status must be pending or all",
  "code": "status_must_be_pending_or_all"
}
Response 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/approval-requests

Ask a second admin to approve a critical action

Authentication: cookie · createApprovalRequest

Session only — not available to API tokens or OAuth clients

INTEGRITY-3 (#203). Ask for one critical action (see PUT /v1/company/four-eyes): the method, path and JSON body the action takes when called directly. Nothing runs until another admin of the company approves it (POST /v1/approval-requests/{id}/approve) within 72 hours. The caller must hold the action's own role. At most 20 requests of a company wait at a time. Needs a password confirmed within the last 10 minutes. Audited (approval_request.create: the action and the expiry, never the body). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant: CropPath support) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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

Request body

ApprovalRequestCreate (required)

Media type: application/json

Example request · application/json
{
  "method": "POST",
  "path": "/v1/keys",
  "body": {
    "kid": "gw-01-k2",
    "owner_type": "gateway",
    "owner_id": "gw-01",
    "public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n"
  }
}

Responses

StatusTypeDescription
201ApprovalRequest
application/json

The request, pending.

400Error
application/json

Invalid JSON, an unknown field, a method and path that are not a critical action, a body that is not a JSON object (or, for PUT /v1/company/four-eyes, anything but turning it off); or a bad X-Request-Id or Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago (reauthentication_required: confirm it with POST /v1/auth/reauth, then repeat the request; nothing was done).

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left. Also role not permitted when the caller does not hold the action's own role.

405Error
application/json

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

409Error
application/json

The company does not require a second admin (call the action directly), or 20 requests already wait for a decision. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id201string

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

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 201 · application/json
{
  "id": 17,
  "action": "key.create",
  "method": "POST",
  "path": "/v1/keys",
  "body": {
    "kid": "gw-01-k2",
    "owner_type": "gateway",
    "owner_id": "gw-01",
    "public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n"
  },
  "status": "pending",
  "requested_by": "admin@coop.example",
  "requested_by_user_id": 12,
  "requested_at": 1797000000.5,
  "expires_at": 1797259200.5,
  "decided_by": null,
  "decided_as": null,
  "decided_at": null,
  "reason": null
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_fields
{
  "error": "unknown fields: query",
  "code": "unknown_fields"
}
Response 400 · application/json · invalid_action
{
  "error": "invalid action: method and path of a critical action",
  "code": "invalid_action"
}
Response 400 · application/json · invalid_body
{
  "error": "invalid body: the action's JSON object",
  "code": "invalid_body"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · second_admin_approval_not_required
{
  "error": "second admin approval not required: the company has it turned off, call the action directly",
  "code": "second_admin_approval_not_required"
}
Response 409 · application/json · too_many_approval_requests
{
  "error": "too many approval requests: at most 20 wait for a decision at a time",
  "code": "too_many_approval_requests"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/approval-requests/{id}/approve

Approve another admin's request: the action runs

Authentication: cookie · approveApprovalRequest

Session only — not available to API tokens or OAuth clients

INTEGRITY-3 (#203). Another admin of the company (or CropPath support, a platform admin acting for it: decided_as platform_support) approves a pending request. Its action runs now, exactly as if this admin had called it directly (with this admin's own role and facilities), in the action's own transaction together with the action's audit row and this approval's (approval_request.approve): all or nothing, and once only (a request decided meanwhile is 409 and the action is rolled back). The answer is the request and the action's own answer; an action that fails answers its own error and the request stays pending. The admin who asked cannot approve (403 same_admin). CropPath support approves only for a company with one admin (403 company_has_second_admin). Needs a password confirmed within the last 10 minutes and, for an account with two-step sign-in, a code confirmed within the last 5 (step-up, #87). An approval never raises a trust tier by itself. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant: CropPath support) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Parameters

NameInTypeDescription
id
required
pathstring

The approval request id.

Idempotency-Key
optional
headerstring

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

Responses

StatusTypeDescription
200ApprovalRequestApproved
application/json

Approved: the request and the action's answer.

400Error
application/json

A body with any field, invalid JSON, a bad X-Request-Id or Idempotency-Key header; or the action's own 400.

401Error
application/json

No valid session, API token or legacy token; or a session that must confirm its password (reauthentication_required) or, with two-step sign-in, its password and a code (mfa_step_up_required) with POST /v1/auth/reauth, then repeat the request; nothing was done.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left. Also same admin: the admin who asked cannot decide their own request. Also company has second admin: CropPath support (a platform admin acting for the company) decides only for a company with one active company admin.

404Error
application/json

No approval request of this company has this id (another company's answers the same).

405Error
application/json

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

409Error
application/json

The request was already approved or rejected, or it expired (72 hours); or the action's own 409. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

503Error
application/json

The approved action's own 503: an issuer key cannot be created because no key-encryption key is configured (AGRITRACE_ISSUER_KEK) or the store cannot be used; nothing changed and the request stays pending. Retry after Retry-After seconds once it is configured.

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

X-Request-Id503string

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

Seconds to wait before retrying.

Example responses

Response 200 · application/json
{
  "request": {
    "id": 17,
    "action": "key.create",
    "method": "POST",
    "path": "/v1/keys",
    "body": {
      "kid": "gw-01-k2",
      "owner_type": "gateway",
      "owner_id": "gw-01",
      "public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n"
    },
    "status": "approved",
    "requested_by": "admin@coop.example",
    "requested_by_user_id": 12,
    "requested_at": 1797000000.5,
    "expires_at": 1797259200.5,
    "decided_by": "second@coop.example",
    "decided_as": "company_admin",
    "decided_at": 1797003600.5,
    "reason": null
  },
  "result": {
    "kid": "gw-01-k2",
    "owner_type": "gateway"
  }
}
Response 400 · application/json · unknown_field
{
  "error": "unknown field: an approval takes no input",
  "code": "unknown_field"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 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"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 403 · application/json · same_admin
{
  "error": "same admin: another admin of the company must decide this request",
  "code": "same_admin"
}
Response 403 · application/json · company_has_second_admin
{
  "error": "company has second admin: CropPath support decides only for a company with one admin, another admin of the company must decide this request",
  "code": "company_has_second_admin"
}
Response 404 · application/json
{
  "error": "not found: 17",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · approval_request_not_pending
{
  "error": "approval request not pending: it was already approved or rejected",
  "code": "approval_request_not_pending"
}
Response 409 · application/json · approval_request_expired
{
  "error": "approval request expired: ask for the action again",
  "code": "approval_request_expired"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Response 503 · application/json
{
  "error": "issuer keys unavailable: AGRITRACE_ISSUER_KEK is not configured",
  "code": "issuer_keys_unavailable"
}

POST /v1/approval-requests/{id}/reject

Reject another admin's request

Authentication: cookie · rejectApprovalRequest

Session only — not available to API tokens or OAuth clients

INTEGRITY-3 (#203). Another admin of the company (or CropPath support) rejects a pending request, with an optional reason kept on the request: nothing runs. The admin who asked cannot reject (403 same_admin). CropPath support rejects only for a company with one admin (403 company_has_second_admin). Needs a password confirmed within the last 10 minutes and, for an account with two-step sign-in, a code confirmed within the last 5 (step-up, #87). Audited (approval_request.reject: the action and who asked, never the reason). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant: CropPath support) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Parameters

NameInTypeDescription
id
required
pathstring

The approval request id.

Idempotency-Key
optional
headerstring

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

Request body

ApprovalRequestRejection (optional)

Media type: application/json

Example request · application/json
{
  "reason": "Not our gateway."
}

Responses

StatusTypeDescription
200ApprovalRequest
application/json

Rejected.

400Error
application/json

Invalid JSON, an unknown field, an empty or too long reason; or a bad X-Request-Id or Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token; or a session that must confirm its password (reauthentication_required) or, with two-step sign-in, its password and a code (mfa_step_up_required) with POST /v1/auth/reauth, then repeat the request; nothing was done.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left. Also same admin: the admin who asked cannot decide their own request. Also company has second admin: CropPath support (a platform admin acting for the company) decides only for a company with one active company admin.

404Error
application/json

No approval request of this company has this id (another company's answers the same).

405Error
application/json

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

409Error
application/json

The request was already approved or rejected, or it expired (72 hours). Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "id": 17,
  "action": "key.create",
  "method": "POST",
  "path": "/v1/keys",
  "body": {
    "kid": "gw-01-k2",
    "owner_type": "gateway",
    "owner_id": "gw-01",
    "public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n"
  },
  "status": "rejected",
  "requested_by": "admin@coop.example",
  "requested_by_user_id": 12,
  "requested_at": 1797000000.5,
  "expires_at": 1797259200.5,
  "decided_by": "second@coop.example",
  "decided_as": "company_admin",
  "decided_at": 1797003600.5,
  "reason": "Not our gateway."
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_fields
{
  "error": "unknown fields: note",
  "code": "unknown_fields"
}
Response 400 · application/json · invalid_reason
{
  "error": "invalid reason: a string of 1 to 500 characters",
  "code": "invalid_reason"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 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"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 403 · application/json · same_admin
{
  "error": "same admin: another admin of the company must decide this request",
  "code": "same_admin"
}
Response 403 · application/json · company_has_second_admin
{
  "error": "company has second admin: CropPath support decides only for a company with one admin, another admin of the company must decide this request",
  "code": "company_has_second_admin"
}
Response 404 · application/json
{
  "error": "not found: 17",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · approval_request_not_pending
{
  "error": "approval request not pending: it was already approved or rejected",
  "code": "approval_request_not_pending"
}
Response 409 · application/json · approval_request_expired
{
  "error": "approval request expired: ask for the action again",
  "code": "approval_request_expired"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/company/identity-provider

Read the company's identity provider

Authentication: cookie · getCompanyIdentityProvider

Session only — not available to API tokens or OAuth clients

#87 (OpenID Connect). The selected company's identity provider for sign-in (never its client secret), the company's own redirect URI to register with it ({origin}/login/oidc/{company}), and whether this deployment allows such sign-in. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant: CropPath support) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Responses

StatusTypeDescription
200IdentityProviderState
application/json

The provider.

400Error
application/json

A bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company).

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Cache-Control200string

no-store on session responses.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 200 · application/json
{
  "available": true,
  "redirect_uri": "https://txng.theio.vn/login/oidc/coop-dl",
  "provider": {
    "issuer": "https://login.coop.example",
    "client_id": "croppath-console",
    "enabled": true,
    "created_at": 1790086400,
    "updated_at": 1790086400,
    "linked_accounts": 3
  }
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PUT /v1/company/identity-provider

Set up or change the company's identity provider

Authentication: cookie · updateCompanyIdentityProvider

Session only — not available to API tokens or OAuth clients

#87 (OpenID Connect). The company's people can then sign in with it (POST /v1/auth/oidc/start). The issuer must be an https:// URL on a host this deployment allows (AGRITRACE_OIDC_ALLOWED_HOSTS); its discovery document is fetched and checked first: it must name the issuer exactly, offer the authorization code flow, PKCE S256 (when it lists PKCE methods), RS256 or ES256 ID tokens and the client secret sent with HTTP Basic or in the form body, and its endpoints must be on allowed hosts. The client secret is stored only encrypted (AES-256-GCM under AGRITRACE_ISSUER_KEK) and never returned. A new issuer or client id removes the provider's account links and needs a new client secret (400 client_secret_is_required otherwise), so a stored secret is never sent to another provider. The discovery document is cached for an hour; after that a sign-in fetches it again and checks it by the same rules. Needs a password confirmed within the last 10 minutes and, for an account with two-step sign-in, a code within the last 5 (the step-up). Audited (company.identity_provider.update, in the same transaction; never the secret). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant: CropPath support) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Request body

IdentityProviderUpdate (required)

Media type: application/json

Example request · application/json
{
  "issuer": "https://login.coop.example",
  "client_id": "croppath-console",
  "client_secret": "s3cret-from-the-idp",
  "enabled": true
}

Responses

StatusTypeDescription
200IdentityProviderState
application/json

Saved.

400Error
application/json

Invalid JSON, an unknown field, a malformed or not allowed issuer, a malformed client id or secret, no client secret for a new provider, enabled not true or false, a provider whose discovery document could not be read or breaks the rules (identity_provider_not_usable, with a short reason), or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token; or a session that must confirm its password (reauthentication_required) or, with two-step sign-in, its password and a code (mfa_step_up_required) with POST /v1/auth/reauth, then repeat the request; nothing was done.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), or the company is leaving CropPath (read-only).

404Error
application/json

The company does not exist.

405Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

503Error
application/json

This deployment does not allow sign-in with an identity provider, or has no key-encryption key (AGRITRACE_ISSUER_KEK) to store the secret.

Response headers

NameStatusTypeDescription
X-Request-Id200string

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

Cache-Control200string

no-store on session responses.

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

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

X-Request-Id500string

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

X-Request-Id503string

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

Example responses

Response 200 · application/json
{
  "available": true,
  "redirect_uri": "https://txng.theio.vn/login/oidc/coop-dl",
  "provider": {
    "issuer": "https://login.coop.example",
    "client_id": "croppath-console",
    "enabled": true,
    "created_at": 1790086400,
    "updated_at": 1790086400,
    "linked_accounts": 3
  }
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_fields
{
  "error": "unknown fields: extra",
  "code": "unknown_fields"
}
Response 400 · application/json · issuer
{
  "error": "invalid issuer: its host is not allowed",
  "code": "invalid_issuer"
}
Response 400 · application/json · secret
{
  "error": "client_secret is required",
  "code": "client_secret_is_required"
}
Response 400 · application/json · not_usable
{
  "error": "identity provider not usable: issuer_mismatch",
  "code": "identity_provider_not_usable"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 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"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: company",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Response 503 · application/json · unavailable
{
  "error": "identity provider sign-in unavailable: no identity provider host is allowed (AGRITRACE_OIDC_ALLOWED_HOSTS)",
  "code": "identity_provider_sign_in_unavailable"
}

DELETE /v1/company/identity-provider

Remove the company's identity provider

Authentication: cookie · removeCompanyIdentityProvider

Session only — not available to API tokens or OAuth clients

#87 (OpenID Connect). Removes the provider and its account links; sign-ins in progress fail at their callback. The company's people sign in with their passwords (or passkeys) again. Sessions already open stay open. Needs a password confirmed within the last 10 minutes and, for an account with two-step sign-in, the step-up. Audited (company.identity_provider.remove, in the same transaction). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant: CropPath support) through a signed-in session only: an API token, an API client or the legacy token is refused (403); operators and auditors are refused (403). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Responses

StatusTypeDescription
204

Removed.

400Error
application/json

A bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token; or a session that must confirm its password (reauthentication_required) or, with two-step sign-in, its password and a code (mfa_step_up_required) with POST /v1/auth/reauth, then repeat the request; nothing was done.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin, through a signed-in session: an API token, an API client or the legacy token is refused), tenant not allowed (X-Tenant), two-factor required (this session must prove a second factor before acting for the company), or the company is leaving CropPath (read-only).

404Error
application/json

The company has no identity provider.

405Error
application/json

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

500Error
application/json

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

Response headers

NameStatusTypeDescription
X-Request-Id204string

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

no-store on session responses.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Example responses

Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Response 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"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · two_factor
{
  "error": "two-factor required: set up two-step sign-in for this account",
  "code": "two_factor_required"
}
Response 403 · application/json · read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: identity provider",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}