settings
54 个操作
GET /v1/company/profileRead the selected company's profilePUT /v1/company/profileSave the selected company's profileGET /v1/company/profile/public-identityRead how the selected company is named on public outputsPUT /v1/company/profile/public-identitySet how the selected company is named on public outputsGET /v1/company/securityRead the company's sign-in securityPUT /v1/company/securityRequire two-step sign-in for the company, or stopGET /v1/company/onboardingRead the company's getting-started checklistPUT /v1/company/onboardingHide the company's getting-started checklist, or show it againGET /v1/company/exportsList the company's full data exportsPOST /v1/company/exportsRequest a full data export of the companyGET /v1/company/exports/{id}/downloadDownload a ready full data exportGET /v1/notificationsList the caller's notificationsGET /v1/notifications/unread-countCount the caller's unread notificationsPOST /v1/notifications/read-allMark all of the caller's notifications readPOST /v1/notifications/{id}/readMark one of the caller's notifications readGET /v1/company/usageRead the company's usage and limitsGET /v1/company/overviewRead the selected company's overviewGET /v1/company/logoDownload the selected company's logoPUT /v1/company/logoSet the selected company's logoGET /v1/membersList the company's membersPATCH /v1/members/{user_id}Change a member's role or facilitiesPOST /v1/members/{user_id}/disableTurn a member off for this companyPOST /v1/members/{user_id}/enableTurn a member back on for this companyPOST /v1/members/{user_id}/password-linkCreate a new password link for a member (shown once)POST /v1/members/{user_id}/two-factor/resetRemove a member's two-step sign-in (a lost phone)POST /v1/members/{user_id}/sessions/revokeSign a member out everywhere (a lost phone)POST /v1/members/{user_id}/unlockClear a member's sign-in lockoutGET /v1/invitationsList the company's invitations and password linksPOST /v1/invitationsInvite a colleague (link shown once)POST /v1/invitations/{id}/revokeRevoke a pending invitation or password linkGET /v1/api-tokensThe tenant's API tokensPOST /v1/api-tokensCreate an API token (shown once)POST /v1/api-tokens/{id}/revokeRevoke an API tokenGET /v1/oauth-clientsThe tenant's OAuth2 API clientsPOST /v1/oauth-clientsRegister an OAuth2 API client (secret shown once)POST /v1/oauth-clients/{id}/revokeRevoke an OAuth2 API clientGET /v1/oauth-clients/detailsThe tenant's OAuth2 API clients with expiry, sources and last usePOST /v1/oauth-clients/{id}/renewRenew an OAuth2 API clientPUT /v1/oauth-clients/{id}/allowed-ipsSet the source networks an OAuth2 API client may call fromGET /v1/account/personal-dataSee the personal data held about me in this companyGET /v1/account/personal-data-requestsList my requests about my personal dataPOST /v1/account/personal-data-requestsAsk my company to show more of or correct my personal dataGET /v1/personal-data-requestsList the company's personal data requestsPOST /v1/personal-data-requests/{id}/handledMark a personal data request handledGET /v1/company/offboardingWhether the company is leaving CropPathGET /v1/company/four-eyesRead the company's second admin approval settingPUT /v1/company/four-eyesRequire a second admin for critical actions, or stopGET /v1/approval-requestsList the company's second admin approval requestsPOST /v1/approval-requestsAsk a second admin to approve a critical actionPOST /v1/approval-requests/{id}/approveApprove another admin's request: the action runsPOST /v1/approval-requests/{id}/rejectReject another admin's requestGET /v1/company/identity-providerRead the company's identity providerPUT /v1/company/identity-providerSet up or change the company's identity providerDELETE /v1/company/identity-providerRemove the company's identity provider
GET /v1/company/profile
Read the selected company's profile
身份验证: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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
admin_units可选 | query | "0" | "1" | #273: |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyProfileapplication/json | The company's profile. |
| 400 | Errorapplication/json |
|
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/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. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · bad_admin_units
{
"error": "bad admin_units",
"code": "bad_admin_units"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/company/profile
Save the selected company's profile
身份验证: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.
请求体
CompanyProfileUpdate (必填)
媒体类型: application/json
请求示例 · 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"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyProfileapplication/json | Saved; the profile as stored. |
| 400 | Errorapplication/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 ( |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/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. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/json | #273: |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Deprecation | 200 | string | #273: sent only when the request gave the address in Viet Nam as text only ( |
Sunset | 200 | string | #273: sent only when the request gave the address in Viet Nam as text only ( |
Link | 200 | string | #273: sent only when the request gave the address in Viet Nam as text only ( |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
响应示例
响应 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"
}响应 400 · application/json · invalid_legal_name
{
"error": "invalid legal_name: required, a string of 1 to 200 characters",
"code": "invalid_legal_name"
}响应 400 · application/json · invalid_country
{
"error": "invalid country: an ISO 3166-1 alpha-2 code in capital letters, such as VN",
"code": "invalid_country"
}响应 400 · application/json · invalid_website
{
"error": "invalid website: an https:// address such as https://example.com",
"code": "invalid_website"
}响应 400 · application/json · unknown_field
{
"error": "unknown field: tenant",
"code": "unknown_field"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 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"
}响应 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"
}响应 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"
}响应 400 · application/json · invalid_province
{
"error": "invalid province: absent or null with the codes, the server writes the official name",
"code": "invalid_province"
}响应 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"
}响应 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"
}响应 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"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf_token_missing_or_invalid
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin_not_allowed
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}响应 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
身份验证: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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
admin_units可选 | query | "0" | "1" | #273: |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyPublicIdentityapplication/json | The company's public identity. |
| 400 | Errorapplication/json |
|
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/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. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · bad_admin_units
{
"error": "bad admin_units",
"code": "bad_admin_units"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/company/profile/public-identity
Set how the selected company is named on public outputs
身份验证: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.
请求体
CompanyPublicIdentityUpdate (必填)
媒体类型: application/json
请求示例 · application/json
{
"household_business": true,
"public_full_address": false,
"public_legal_name": false
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyPublicIdentityapplication/json | Saved; the public identity as stored. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/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. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The company has not saved its profile yet: save the profile first. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}
}响应 400 · application/json · invalid_household_business
{
"error": "invalid household_business: required, true or false",
"code": "invalid_household_business"
}响应 400 · application/json · invalid_public_full_address
{
"error": "invalid public_full_address: required, true or false",
"code": "invalid_public_full_address"
}响应 400 · application/json · invalid_public_legal_name
{
"error": "invalid public_legal_name: required, true or false",
"code": "invalid_public_legal_name"
}响应 400 · application/json · unknown_field
{
"error": "unknown field: legal_name",
"code": "unknown_field"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf_token_missing_or_invalid
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin_not_allowed
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json
{
"error": "no company profile: save the company profile before its public identity",
"code": "no_company_profile"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/security
Read the company's sign-in security
身份验证:cookie · getCompanySecurity
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanySecurityapplication/json | The company's sign-in security. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such company: a platform admin named one (X-Tenant) that does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/company/security
Require two-step sign-in for the company, or stop
身份验证:cookie · updateCompanySecurity
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
请求体
媒体类型: application/json
请求示例 · application/json
{
"require_two_factor": true
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanySecurityapplication/json | The company's sign-in security. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, or |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such company: a platform admin named one (X-Tenant) that does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | Turning it on while the caller's own two-step sign-in is off. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · missing
{
"error": "require_two_factor is required",
"code": "require_two_factor_is_required"
}响应 400 · application/json · type
{
"error": "require_two_factor must be true or false",
"code": "require_two_factor_must_be_true_or_false"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json
{
"error": "set up two-step sign-in for yourself first",
"code": "set_up_two_step_sign_in_for_yourself_first"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/onboarding
Read the company's getting-started checklist
身份验证:cookie · getCompanyOnboarding
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Onboardingapplication/json | The company's checklist. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such company: a platform admin named one (X-Tenant) that does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}
]
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/company/onboarding
Hide the company's getting-started checklist, or show it again
身份验证:cookie · updateCompanyOnboarding
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
请求体
OnboardingUpdate (必填)
媒体类型: application/json
请求示例 · application/json
{
"hidden": true
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Onboardingapplication/json | The company's checklist. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, or |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such company: a platform admin named one (X-Tenant) that does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}
]
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · hidden
{
"error": "hidden must be true or false",
"code": "hidden_must_be_true_or_false"
}响应 400 · application/json · unknown
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/exports
List the company's full data exports
身份验证:cookie · listCompanyExports
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyExportListapplication/json | The company's export requests. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/company/exports
Request a full data export of the company
身份验证:cookie · requestCompanyExport
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
Idempotency-Key可选 | header | string | 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 202 | CompanyExportapplication/json | The export is queued. |
| 400 | Errorapplication/json | Invalid JSON, a body with any field, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such company: a platform admin named one (X-Tenant) that does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | An export of the company is already waiting or being built. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 429 | Errorapplication/json | The company already requested 3 exports in the last 24 hours; |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 202 | string | Request id: the caller's |
Idempotent-Replayed | 202 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown_fields
{
"error": "unknown fields: format",
"code": "unknown_fields"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · export_in_progress
{
"error": "export in progress: an export of the company is already being prepared",
"code": "export_in_progress"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 429 · application/json
{
"error": "too many exports: at most 3 in 24 hours",
"code": "too_many_exports"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/exports/{id}/download
Download a ready full data export
身份验证:cookie · downloadCompanyExport
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The export's id. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | stringapplication/zip | The ZIP archive. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such export of the selected company (another company's export answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The export is still being prepared, or its build failed (request a new one). |
| 410 | Errorapplication/json | The export's 24 hours are over and its file is deleted: request a new one. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Content-Disposition | 200 | string |
|
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 410 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/zip
(binary ZIP bytes, starting 50 4B 03 04)响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 404 · application/json
{
"error": "not found: 12",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · not_ready
{
"error": "export not ready: it is still being prepared",
"code": "export_not_ready"
}响应 409 · application/json · failed
{
"error": "export failed: request a new one",
"code": "export_failed"
}响应 410 · application/json
{
"error": "export expired: request a new one",
"code": "export_expired"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/notifications
List the caller's notifications
身份验证:cookie · listNotifications
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
unread可选 | query | "true" | "false" |
|
limit可选 | query | integer | 1 to 100 (default 20). |
cursor可选 | query | string | The previous page's |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | NotificationPageapplication/json | One page of the caller's notifications ( |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · unread
{
"error": "unread must be true or false",
"code": "unread_must_be_true_or_false"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/notifications/unread-count
Count the caller's unread notifications
身份验证:cookie · getNotificationUnreadCount
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | NotificationUnreadCountapplication/json | The unread count ( |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"unread": 3
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/notifications/read-all
Mark all of the caller's notifications read
身份验证:cookie · markAllNotificationsRead
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
Idempotency-Key可选 | header | string | 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | NotificationsMarkedReadapplication/json | How many were marked read, and how many are unread now. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The Idempotency-Key's first request is still running (retry after |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"marked": 3,
"unread": 0
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/notifications/{id}/read
Mark one of the caller's notifications read
身份验证:cookie · markNotificationRead
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The notification id (from listNotifications). |
Idempotency-Key可选 | header | string | 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Notificationapplication/json | The notification, read. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No notification of the caller in this company with this id (another user's, another company's, purged or never created). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The Idempotency-Key's first request is still running (retry after |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 404 · application/json
{
"error": "not found: 41",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/usage
Read the company's usage and limits
身份验证:cookie · getCompanyUsage
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyUsageapplication/json | The company's usage of its limits, its API calls per day and its quotas. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such company: a platform admin named one (X-Tenant) that does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/overview
Read the selected company's overview
身份验证:cookie · getCompanyOverview
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#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.
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyOverviewapplication/json | The company's overview. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such company: a platform admin named one (X-Tenant) that does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}
]
}
}
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/logo
Download the selected company's logo
身份验证:cookie, bearer · getCompanyLogo
SELF-1-5 (#186). Readers as for the profile. Staff only: no public page shows the logo yet. The Content-Type is sniffed from the bytes (PNG or JPEG), never taken from the upload.
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | stringimage/png, image/jpeg | The logo's bytes. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | The company has no logo (or does not exist). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Content-Type-Options | 200 | string | Always |
Content-Disposition | 200 | string | Always |
Content-Security-Policy | 200 | string | Always |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · image/png
(binary PNG bytes, starting 89 50 4E 47 0D 0A 1A 0A)响应 200 · image/jpeg
(binary JPEG bytes, starting FF D8 FF)响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 404 · application/json
{
"error": "not found: logo",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/company/logo
Set the selected company's logo
身份验证:cookie, bearer · putCompanyLogo
SELF-1-5 (#186). Company admins; a platform admin through X-Tenant. The body is the image itself: PNG or JPEG (never SVG), at most 256 KiB and 1024 x 1024 pixels. The type is checked by the file's magic bytes, which must match the Content-Type; the bytes must hash to sha256. Stored as an attachment of the company (the attachments store). The profile must be saved first. Audited (company.logo.update: the hash, media type, size and dimensions, never the bytes).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
sha256必填 | query | string | SHA-256 of the body: exactly 64 lowercase hex characters. |
请求体
string (binary) (必填)
媒体类型: image/png, image/jpeg
请求示例 · image/png
(binary PNG bytes, starting 89 50 4E 47 0D 0A 1A 0A)请求示例 · image/jpeg
(binary JPEG bytes, starting FF D8 FF)响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyLogoStoredapplication/json | Stored; the profile now names this logo. |
| 400 | Errorapplication/json | A malformed sha256, an image whose header cannot be read or that is larger than 1024 x 1024 pixels, a missing or malformed Content-Length, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/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. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The company has no saved profile yet: save it first. |
| 413 | Errorapplication/json | The logo is over 256 KiB (or the body over 1 MiB). |
| 415 | Errorapplication/json | A Content-Type other than image/png or image/jpeg, or bytes whose magic is not that type's. |
| 422 | Errorapplication/json | The body does not hash to |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 415 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"media_type": "image/png",
"size": 20480,
"width": 512,
"height": 256
}响应 400 · application/json · invalid_hash
{
"error": "invalid hash: sha256 is 64 lowercase hex characters",
"code": "invalid_hash"
}响应 400 · application/json · invalid_logo
{
"error": "invalid logo: at most 1024 x 1024 pixels",
"code": "invalid_logo"
}响应 400 · application/json · bad_content_length
{
"error": "bad content length",
"code": "bad_content_length"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf_token_missing_or_invalid
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin_not_allowed
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json
{
"error": "no company profile: save the company profile before its logo",
"code": "no_company_profile"
}响应 413 · application/json · logo_too_large
{
"error": "logo too large: at most 256 KiB",
"code": "logo_too_large"
}响应 413 · application/json · body_too_large
{
"error": "body too large",
"code": "body_too_large"
}响应 415 · application/json · unsupported_media_type
{
"error": "unsupported media type: a logo is image/png or image/jpeg",
"code": "unsupported_media_type"
}响应 415 · application/json · content_does_not_match_the_media_type
{
"error": "content does not match the media type",
"code": "content_does_not_match_the_media_type"
}响应 422 · application/json
{
"error": "hash mismatch",
"code": "hash_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/members
List the company's members
身份验证:cookie · listMembers
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | MemberListapplication/json | The members. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PATCH /v1/members/{user_id}
Change a member's role or facilities
身份验证:cookie · updateMember
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
user_id必填 | path | string | The member's account id (from listMembers). |
请求体
MemberUpdate (必填)
媒体类型: application/json
请求示例 · application/json
{
"role": "operator",
"facilities": [
"VN-TGPH-021"
]
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Memberapplication/json | The member, changed. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/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 ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The change would leave the company without an active admin. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · role
{
"error": "invalid role: one of tenant_admin, operator, auditor",
"code": "invalid_role"
}响应 400 · application/json · facility
{
"error": "unknown facility: VN-TGPH-999",
"code": "unknown_facility"
}响应 400 · application/json · unknown
{
"error": "unknown fields: email",
"code": "unknown_fields"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json
{
"error": "last admin: a company needs at least one active admin",
"code": "last_admin"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/members/{user_id}/disable
Turn a member off for this company
身份验证:cookie · disableMember
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
user_id必填 | path | string | The member's account id (from listMembers). |
Idempotency-Key可选 | header | string | 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Memberapplication/json | The member. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/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) ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No member of this company with a role it manages (tenant_admin, operator or auditor). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The last-admin rule (turning off the company's only active admin). Or the Idempotency-Key's first request is still running ( |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · last_admin
{
"error": "last admin: a company needs at least one active admin",
"code": "last_admin"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/members/{user_id}/enable
Turn a member back on for this company
身份验证:cookie · enableMember
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
user_id必填 | path | string | The member's account id (from listMembers). |
Idempotency-Key可选 | header | string | 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Memberapplication/json | The member. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/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 ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No member of this company with a role it manages (tenant_admin, operator or auditor). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The company has its maximum of 200 active members and pending invitations. Or the Idempotency-Key's first request is still running ( |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · too_many_members
{
"error": "too many members: at most 200 active members and pending invitations per company",
"code": "too_many_members"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/members/{user_id}/password-link
Create a new password link for a member (shown once)
身份验证:cookie · createMemberPasswordLink
仅限登录会话——API 令牌和 OAuth 客户端不可调用
SELF-1-4 (#185). A one-time link (24 hours) with which the member chooses a new password; accepting it ends every session of the account and opens a new one (POST /v1/auth/links/accept). Returned once (no-store); only the SHA-256 of its token is stored. It never shows or changes two-step sign-in. Refused with 409 reset_by_support unless every active membership of the account is in this company and the account is no platform admin or lab user (the answer names no other company). Needs a password confirmed within the last 10 minutes (SELF-1-2). Audited (account_link.create, in the same transaction: purpose reset, 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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
user_id必填 | path | string | The member's account id (from listMembers). |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | AccountLinkCreatedapplication/json | The link, shown this once. |
| 400 | Errorapplication/json | A bad X-Request-Id; or an Idempotency-Key header, which this operation refuses: its response holds the link, whose token is never stored. |
| 401 | Errorapplication/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) ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No active member of this company with a role it manages. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | Only CropPath support may reset this account, or a company cap is reached (at most 50 pending links, and 30 new links an hour). |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Cache-Control | 201 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 201 · application/json
{
"id": 13,
"link": "https://txng.theio.vn/login#reset=agr_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGxl",
"expires_at": 1790086400.5,
"emailed": true
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · idempotency_key_not_supported
{
"error": "idempotency key not supported",
"code": "idempotency_key_not_supported"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · reset_by_support
{
"error": "reset by support: this account can only be reset by CropPath support",
"code": "reset_by_support"
}响应 409 · application/json · pending
{
"error": "too many pending links: at most 50 per company",
"code": "too_many_pending_links"
}响应 409 · application/json · hourly
{
"error": "too many links: at most 30 per company per hour",
"code": "too_many_links"
}响应 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)
身份验证:cookie · resetMemberTwoFactor
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
user_id必填 | path | string | The member's account id (from listMembers). |
Idempotency-Key可选 | header | string | 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 |
请求体
TwoFactorReset (可选)
媒体类型: application/json
请求示例 · application/json
{
"reason": "Lost phone, confirmed by Zalo call with the company director"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | TwoFactorResetResultapplication/json | Reset. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No member of this company with that id (another company's member answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/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. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"user_id": 7,
"two_factor": false,
"sessions_revoked": 1
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · reason_required
{
"error": "reason is required",
"code": "reason_is_required"
}响应 400 · application/json · reason
{
"error": "invalid reason: 1 to 200 characters on one line",
"code": "invalid_reason"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · reset_by_support
{
"error": "reset by support: this account can only be reset by CropPath support",
"code": "reset_by_support"
}响应 409 · application/json · in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/members/{user_id}/sessions/revoke
Sign a member out everywhere (a lost phone)
身份验证:cookie · revokeMemberSessions
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
user_id必填 | path | string | The member's account id (from listMembers). |
Idempotency-Key可选 | header | string | 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 |
请求体
MemberSessionsRevoke (可选)
媒体类型: application/json
请求示例 · application/json
{
"reason": "Phone lost at the collection point, confirmed by the company director"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | MemberSessionsRevokedapplication/json | Signed out everywhere. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No member of this company with that id (another company's member answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/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. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"user_id": 7,
"sessions_revoked": 2
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · reason_required
{
"error": "reason is required",
"code": "reason_is_required"
}响应 400 · application/json · reason
{
"error": "invalid reason: 1 to 200 characters on one line",
"code": "invalid_reason"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · sign_out_by_support
{
"error": "sign out by support: only CropPath support can end this account's sessions",
"code": "sign_out_by_support"
}响应 409 · application/json · in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/members/{user_id}/unlock
Clear a member's sign-in lockout
身份验证:cookie · unlockMember
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
user_id必填 | path | string | The member's account id (from listMembers). |
Idempotency-Key可选 | header | string | 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | MemberUnlockResultapplication/json | Unlocked. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No member of this company with that id (another company's member answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/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. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"user_id": 7,
"locked": false,
"was_locked": true
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · unlock_by_support
{
"error": "unlock by support: only CropPath support can unlock this account",
"code": "unlock_by_support"
}响应 409 · application/json · in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/invitations
List the company's invitations and password links
身份验证:cookie · listInvitations
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
status可选 | query | "pending" | "used" | "expired" | "revoked" | Only the links in this state. |
limit可选 | query | integer | 1 to 200 (default 100). |
cursor可选 | query | string | The previous page's |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | InvitationListapplication/json | The invitations and password links. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · status
{
"error": "invalid status: one of pending, used, expired, revoked",
"code": "invalid_status"
}响应 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/invitations
Invite a colleague (link shown once)
身份验证:cookie · createInvitation
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
请求体
InvitationCreate (必填)
媒体类型: application/json
请求示例 · application/json
{
"email": "new.colleague@coop-dl.example",
"role": "operator",
"facilities": null,
"display_name": "Anh Minh"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | AccountLinkCreatedapplication/json | The link, shown this once. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/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 ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such company (a platform admin's X-Tenant names none). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The email is already an active member, or a company cap is reached. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Cache-Control | 201 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 201 · application/json
{
"id": 12,
"link": "https://txng.theio.vn/login#invite=agi_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGxl",
"expires_at": 1790259200.5,
"emailed": true
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · email
{
"error": "invalid email",
"code": "invalid_email"
}响应 400 · application/json · role
{
"error": "invalid role: one of tenant_admin, operator, auditor",
"code": "invalid_role"
}响应 400 · application/json · facility
{
"error": "unknown facility: VN-TGPH-999",
"code": "unknown_facility"
}响应 400 · application/json · unknown
{
"error": "unknown fields: reason",
"code": "unknown_fields"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · idempotency_key_not_supported
{
"error": "idempotency key not supported",
"code": "idempotency_key_not_supported"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: coop-new",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · already_a_member
{
"error": "already a member: this email is already an active member of the company",
"code": "already_a_member"
}响应 409 · application/json · too_many_members
{
"error": "too many members: at most 200 active members and pending invitations per company",
"code": "too_many_members"
}响应 409 · application/json · pending
{
"error": "too many pending links: at most 50 per company",
"code": "too_many_pending_links"
}响应 409 · application/json · hourly
{
"error": "too many links: at most 30 per company per hour",
"code": "too_many_links"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/invitations/{id}/revoke
Revoke a pending invitation or password link
身份验证:cookie · revokeInvitation
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The link id (from listInvitations). |
Idempotency-Key可选 | header | string | 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | InvitationRevokedapplication/json | The link, revoked. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The Idempotency-Key's first request is still running (retry after |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"id": 12,
"status": "revoked"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 12",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/api-tokens
The tenant's API tokens
身份验证:cookie · listApiTokens
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
limit可选 | query | integer | 1 to 200 (default 50). |
cursor可选 | query | string | The previous page's |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | ApiTokenPageapplication/json | One page of tokens. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/api-tokens
Create an API token (shown once)
身份验证:cookie · createApiToken
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
请求体
ApiTokenCreate (必填)
媒体类型: application/json
请求示例 · application/json
{
"name": "erp-sync",
"role": "operator",
"expires_in_days": 90
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | ApiTokenCreatedapplication/json | The token, with the secret shown this once. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The tenant already holds 100 live tokens: revoke one first. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Cache-Control | 201 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · name
{
"error": "invalid name: a letter or digit, then up to 63 letters, digits, '.', '_' or '-'",
"code": "invalid_name"
}响应 400 · application/json · role
{
"error": "invalid role: one of tenant_admin, operator, auditor",
"code": "invalid_role"
}响应 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"
}响应 400 · application/json · unknown
{
"error": "unknown fields: tenant",
"code": "unknown_fields"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · idempotency_key_not_supported
{
"error": "idempotency key not supported",
"code": "idempotency_key_not_supported"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json
{
"error": "token limit reached: at most 100 live tokens per tenant",
"code": "token_limit_reached"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/api-tokens/{id}/revoke
Revoke an API token
身份验证:cookie · revokeApiToken
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The token id. |
Idempotency-Key可选 | header | string | 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 |
请求体
ApiTokenRevoke (必填)
媒体类型: application/json
请求示例 · application/json
{
"reason": "leaked in a CI log"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | ApiTokenapplication/json | The token, revoked. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such token of this tenant (another tenant's answers like a missing one). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The token is already revoked. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · reason
{
"error": "invalid reason: 1 to 200 characters on one line",
"code": "invalid_reason"
}响应 400 · application/json · unknown
{
"error": "unknown fields: role",
"code": "unknown_fields"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · token_already_revoked
{
"error": "token already revoked",
"code": "token_already_revoked"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/oauth-clients
The tenant's OAuth2 API clients
身份验证:cookie · listOAuthClients
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
limit可选 | query | integer | 1 to 200 (default 50). |
cursor可选 | query | string | The previous page's |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | OAuthClientPageapplication/json | One page of clients. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token, OAuth2 access token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/oauth-clients
Register an OAuth2 API client (secret shown once)
身份验证:cookie · createOAuthClient
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
请求体
OAuthClientCreate (必填)
媒体类型: application/json
请求示例 · application/json
{
"name": "erp-sync",
"role": "operator",
"scopes": [
"lot_read",
"lot_write"
],
"facilities": [
"VN-TGPH-021"
]
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | OAuthClientCreatedapplication/json | The client, with its secret shown this once. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/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 ( |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The tenant already holds 50 live clients. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Cache-Control | 201 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · scopes
{
"error": "invalid scopes: not a permission the auditor role can be granted: review",
"code": "invalid_scopes"
}响应 400 · application/json · facilities
{
"error": "invalid facilities: not a facility of the tenant",
"code": "invalid_facilities"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json
{
"error": "client limit reached: at most 50 live API clients per tenant",
"code": "client_limit_reached"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/oauth-clients/{id}/revoke
Revoke an OAuth2 API client
身份验证:cookie · revokeOAuthClient
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The client's row id ( |
Idempotency-Key可选 | header | string | 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 |
请求体
OAuthClientRevoke (必填)
媒体类型: application/json
请求示例 · application/json
{
"reason": "contract ended"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | OAuthClientapplication/json | The client, revoked. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field or a missing, blank, multi-line or longer than 200 characters reason, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token, OAuth2 access token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such client of this tenant (another tenant's answers like a missing one). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The client is already revoked. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · reason
{
"error": "invalid reason: 1 to 200 characters on one line",
"code": "invalid_reason"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 3",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · client_already_revoked
{
"error": "client already revoked",
"code": "client_already_revoked"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/oauth-clients/details
The tenant's OAuth2 API clients with expiry, sources and last use
身份验证:cookie · listOAuthClientDetails
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
limit可选 | query | integer | 1 to 200 (default 50). |
cursor可选 | query | string | The previous page's |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | OAuthClientDetailPageapplication/json | One page of clients. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token, OAuth2 access token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/oauth-clients/{id}/renew
Renew an OAuth2 API client
身份验证:cookie · renewOAuthClient
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The client's row id ( |
Idempotency-Key可选 | header | string | 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 |
请求体
OAuthClientRenew (必填)
媒体类型: application/json
请求示例 · application/json
{
"expires_in_days": 365
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | OAuthClientDetailapplication/json | The client, renewed. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, |
| 401 | Errorapplication/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 ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such client of this tenant (another tenant's answers like a missing one). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The client is revoked. Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 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"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 3",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · client_revoked
{
"error": "client revoked",
"code": "client_revoked"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/oauth-clients/{id}/allowed-ips
Set the source networks an OAuth2 API client may call from
身份验证:cookie · setOAuthClientAllowedIps
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The client's row id ( |
请求体
媒体类型: application/json
请求示例 · application/json
{
"allowed_ips": [
"203.0.113.0/24",
"2001:db8::/32"
]
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | OAuthClientDetailapplication/json | The client with its new allowed sources. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/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 ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such client of this tenant (another tenant's answers like a missing one). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The client is revoked. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 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"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 3",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json
{
"error": "client revoked",
"code": "client_revoked"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/account/personal-data
See the personal data held about me in this company
身份验证:cookie · getMyPersonalData
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
agronomist可选 | query | "0" | "1" | #351: |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | PersonalDataapplication/json | The member's personal data in this company. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | The caller has no membership in the selected company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
]
}响应 400 · application/json · bad_agronomist
{
"error": "bad agronomist: 0 or 1",
"code": "bad_agronomist"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 404 · application/json
{
"error": "not found: membership",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/account/personal-data-requests
List my requests about my personal data
身份验证:cookie · listMyPersonalDataRequests
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
limit可选 | query | integer | 1 to 200 (default 50). |
cursor可选 | query | string | The previous page's |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | PersonalDataRequestPageapplication/json | One page of requests. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/account/personal-data-requests
Ask my company to show more of or correct my personal data
身份验证:cookie · createPersonalDataRequest
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
Idempotency-Key可选 | header | string | 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 |
请求体
PersonalDataRequestCreate (必填)
媒体类型: application/json
请求示例 · application/json
{
"kind": "correction",
"text": "My name is spelled Nguyễn Văn An, not Nguyen Van A."
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | PersonalDataRequestapplication/json | The request, as the member sees it. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | The caller has no active membership in the selected company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The Idempotency-Key's first request is still running (retry after |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 429 | Errorapplication/json | Too many requests sent: at most 5 per person per day (code |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 429 | string | Request id: the caller's |
Retry-After | 429 | string | Seconds to wait before retrying. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · kind
{
"error": "invalid kind: one of access, correction",
"code": "invalid_kind"
}响应 400 · application/json · text
{
"error": "invalid text: required, text of at most 2000 characters",
"code": "invalid_text"
}响应 400 · application/json · unknown
{
"error": "unknown field: email",
"code": "unknown_field"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: membership",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 429 · application/json · person
{
"error": "too many personal data requests: at most 5 per person per day",
"code": "too_many_personal_data_requests"
}响应 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"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/personal-data-requests
List the company's personal data requests
身份验证:cookie · listCompanyPersonalDataRequests
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
status可选 | query | "open" | "handled" | Only requests of this status. |
limit可选 | query | integer | 1 to 200 (default 50). |
cursor可选 | query | string | The previous page's |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyPersonalDataRequestPageapplication/json | One page of requests. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · status
{
"error": "invalid status: one of open, handled",
"code": "invalid_status"
}响应 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/personal-data-requests/{id}/handled
Mark a personal data request handled
身份验证:cookie · markPersonalDataRequestHandled
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The request id. |
Idempotency-Key可选 | header | string | 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyPersonalDataRequestapplication/json | The request, handled. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No personal data request with this id in the selected company. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The request was already handled; or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: 4",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · handled
{
"error": "already handled: this request was already marked handled",
"code": "already_handled"
}响应 409 · application/json · idempotency
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/offboarding
Whether the company is leaving CropPath
身份验证:cookie · getCompanyOffboarding
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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).
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CompanyOffboardingapplication/json | The company's departure state. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/four-eyes
Read the company's second admin approval setting
身份验证:cookie · getCompanyFourEyes
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | FourEyesStateapplication/json | The setting. |
| 400 | Errorapplication/json | A bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"require_second_admin": true,
"admins": 2,
"pending": 1,
"expires_after_s": 259200
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/company/four-eyes
Require a second admin for critical actions, or stop
身份验证:cookie · updateCompanyFourEyes
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
请求体
FourEyesUpdate (必填)
媒体类型: application/json
请求示例 · application/json
{
"require_second_admin": true
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | FourEyesStateapplication/json | The setting, as stored. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, or |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/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. |
| 404 | Errorapplication/json | No such company: a platform admin named one (X-Tenant) that does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"require_second_admin": true,
"admins": 2,
"pending": 1,
"expires_after_s": 259200
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown_fields
{
"error": "unknown fields: required",
"code": "unknown_fields"
}响应 400 · application/json · type
{
"error": "require_second_admin must be true or false",
"code": "require_second_admin_must_be_true_or_false"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 403 · application/json · 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"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/approval-requests
List the company's second admin approval requests
身份验证:cookie · listApprovalRequests
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
status可选 | query | "pending" | "all" |
|
limit可选 | query | integer | 1 to 100 (default 50). |
cursor可选 | query | string | The previous page's |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | ApprovalRequestPageapplication/json | One page of requests. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · status
{
"error": "status must be pending or all",
"code": "status_must_be_pending_or_all"
}响应 400 · application/json · limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/approval-requests
Ask a second admin to approve a critical action
身份验证:cookie · createApprovalRequest
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
Idempotency-Key可选 | header | string | 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 |
请求体
媒体类型: application/json
请求示例 · 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"
}
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | ApprovalRequestapplication/json | The request, pending. |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session whose password was last confirmed more than 10 minutes ago ( |
| 403 | Errorapplication/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. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/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 ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown_fields
{
"error": "unknown fields: query",
"code": "unknown_fields"
}响应 400 · application/json · invalid_action
{
"error": "invalid action: method and path of a critical action",
"code": "invalid_action"
}响应 400 · application/json · invalid_body
{
"error": "invalid body: the action's JSON object",
"code": "invalid_body"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · 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"
}响应 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"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/approval-requests/{id}/approve
Approve another admin's request: the action runs
身份验证:cookie · approveApprovalRequest
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The approval request id. |
Idempotency-Key可选 | header | string | 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | ApprovalRequestApprovedapplication/json | Approved: the request and the action's answer. |
| 400 | Errorapplication/json | A body with any field, invalid JSON, a bad X-Request-Id or Idempotency-Key header; or the action's own 400. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session that must confirm its password ( |
| 403 | Errorapplication/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. |
| 404 | Errorapplication/json | No approval request of this company has this id (another company's answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/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 ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/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 |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
响应示例
响应 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"
}
}响应 400 · application/json · unknown_field
{
"error": "unknown field: an approval takes no input",
"code": "unknown_field"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 401 · application/json · step_up
{
"error": "mfa step-up required: confirm your password and a code from your authenticator app with POST /v1/auth/reauth",
"code": "mfa_step_up_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 403 · application/json · same_admin
{
"error": "same admin: another admin of the company must decide this request",
"code": "same_admin"
}响应 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"
}响应 404 · application/json
{
"error": "not found: 17",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · approval_request_not_pending
{
"error": "approval request not pending: it was already approved or rejected",
"code": "approval_request_not_pending"
}响应 409 · application/json · approval_request_expired
{
"error": "approval request expired: ask for the action again",
"code": "approval_request_expired"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}响应 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
身份验证:cookie · rejectApprovalRequest
仅限登录会话——API 令牌和 OAuth 客户端不可调用
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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The approval request id. |
Idempotency-Key可选 | header | string | 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 |
请求体
媒体类型: application/json
请求示例 · application/json
{
"reason": "Not our gateway."
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | ApprovalRequestapplication/json | Rejected. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, an empty or too long reason; or a bad X-Request-Id or Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session that must confirm its password ( |
| 403 | Errorapplication/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. |
| 404 | Errorapplication/json | No approval request of this company has this id (another company's answers the same). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The request was already approved or rejected, or it expired (72 hours). Or the Idempotency-Key's first request is still running ( |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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."
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown_fields
{
"error": "unknown fields: note",
"code": "unknown_fields"
}响应 400 · application/json · invalid_reason
{
"error": "invalid reason: a string of 1 to 500 characters",
"code": "invalid_reason"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 401 · application/json · step_up
{
"error": "mfa step-up required: confirm your password and a code from your authenticator app with POST /v1/auth/reauth",
"code": "mfa_step_up_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 403 · application/json · same_admin
{
"error": "same admin: another admin of the company must decide this request",
"code": "same_admin"
}响应 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"
}响应 404 · application/json
{
"error": "not found: 17",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · approval_request_not_pending
{
"error": "approval request not pending: it was already approved or rejected",
"code": "approval_request_not_pending"
}响应 409 · application/json · approval_request_expired
{
"error": "approval request expired: ask for the action again",
"code": "approval_request_expired"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/company/identity-provider
Read the company's identity provider
身份验证:cookie · getCompanyIdentityProvider
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#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.
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | IdentityProviderStateapplication/json | The provider. |
| 400 | Errorapplication/json | A bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 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
}
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/company/identity-provider
Set up or change the company's identity provider
身份验证:cookie · updateCompanyIdentityProvider
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#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.
请求体
媒体类型: application/json
请求示例 · application/json
{
"issuer": "https://login.coop.example",
"client_id": "croppath-console",
"client_secret": "s3cret-from-the-idp",
"enabled": true
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | IdentityProviderStateapplication/json | Saved. |
| 400 | Errorapplication/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, |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session that must confirm its password ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | The company does not exist. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
| 503 | Errorapplication/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. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
X-Request-Id | 503 | string | Request id: the caller's |
响应示例
响应 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
}
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown_fields
{
"error": "unknown fields: extra",
"code": "unknown_fields"
}响应 400 · application/json · issuer
{
"error": "invalid issuer: its host is not allowed",
"code": "invalid_issuer"
}响应 400 · application/json · secret
{
"error": "client_secret is required",
"code": "client_secret_is_required"
}响应 400 · application/json · not_usable
{
"error": "identity provider not usable: issuer_mismatch",
"code": "identity_provider_not_usable"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 401 · application/json · step_up
{
"error": "mfa step-up required: confirm your password and a code from your authenticator app with POST /v1/auth/reauth",
"code": "mfa_step_up_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: company",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}响应 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
身份验证:cookie · removeCompanyIdentityProvider
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#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.
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 204 | Removed. | |
| 400 | Errorapplication/json | A bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token; or a session that must confirm its password ( |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | The company has no identity provider. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 204 | string | Request id: the caller's |
Cache-Control | 204 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json · credentials
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 401 · application/json · reauthentication
{
"error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
"code": "reauthentication_required"
}响应 401 · application/json · step_up
{
"error": "mfa step-up required: confirm your password and a code from your authenticator app with POST /v1/auth/reauth",
"code": "mfa_step_up_required"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · two_factor
{
"error": "two-factor required: set up two-step sign-in for this account",
"code": "two_factor_required"
}响应 403 · application/json · read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}响应 404 · application/json
{
"error": "not found: identity provider",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}