CropPath cho nhà phát triển

Tài liệu API

webhooks

7 thao tác

GET /v1/webhooks

The tenant's webhook subscriptions

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: webhook_admin · listWebhooks

Every subscription of the tenant (at most 20), by id; never a secret. Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a session or an API token of their role. Not audited (a read). no-store.

Phản hồi

Mã trạng tháiKiểuMô tả
200WebhookSubscriptionList
application/json

The subscriptions.

400Error
application/json

A bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin), tenant not allowed (X-Tenant).

405Error
application/json

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

500Error
application/json

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

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "items": [
    {
      "id": 3,
      "url": "https://erp.buyer.example/hooks/croppath",
      "description": "Buyer ERP",
      "event_types": [
        "lot.sealed",
        "shipment.departed"
      ],
      "status": "active",
      "disabled_reason": null,
      "disabled_at": null,
      "consecutive_failures": 0,
      "created_by": "admin@coop.example",
      "created_at": 1790000000.5,
      "updated_at": 1790000000.5
    }
  ]
}
Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/webhooks

Register a webhook subscription (secret shown once)

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: webhook_admin · createWebhook

Registers an HTTPS endpoint for the given event types; the server generates the signing secret, returns it in this response only and stores it encrypted under the deployment's key-encryption key. The URL must be https, without credentials or fragment, and every address its host resolves to must be public. Audited (webhook.create, in the same transaction, with the URL's host and the event types, never the secret). Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a session or an API token of their role. Every delivery is a POST of application/json to the subscription's URL with the Standard Webhooks headers webhook-id (the event id, the same on every attempt: deduplicate on it, delivery is at least once), webhook-timestamp (Unix seconds of this attempt) and webhook-signature (v1, + base64 of HMAC-SHA256 over {webhook-id}.{webhook-timestamp}.{body}, keyed with the base64-decoded part of the secret after whsec_). Verify the signature over the raw body with a constant-time comparison and refuse a timestamp more than 300 seconds from your clock. Answer 2xx within 10 seconds; any other answer (a redirect is not followed) or none is a failed attempt, retried with exponential backoff (1 minute doubling, at most 6 hours) for 12 attempts (about 21 hours). 50 failed attempts in a row disable the subscription.

Nội dung yêu cầu

WebhookSubscriptionCreate (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "url": "https://erp.buyer.example/hooks/croppath",
  "event_types": [
    "lot.sealed",
    "shipment.departed"
  ],
  "description": "Buyer ERP"
}

Phản hồi

Mã trạng tháiKiểuMô tả
201WebhookSecret
application/json

The subscription, with its secret shown this once.

400Error
application/json

Invalid JSON, an unknown field, a bad URL (not https, credentials, a fragment, a host that does not resolve or resolves to an address that is not public), bad event types or description, or a bad X-Request-Id; or an Idempotency-Key header, which this operation refuses: its response holds the signing secret, which is stored only encrypted.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

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

405Error
application/json

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

409Error
application/json

The tenant holds 20 subscriptions already.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

503Error
application/json

No key-encryption key is configured (AGRITRACE_ISSUER_KEK): a secret cannot be stored; nothing changed. Retry after Retry-After seconds once it is configured.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id201string

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

Cache-Control201string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

X-Request-Id413string

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

X-Request-Id500string

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

X-Request-Id503string

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

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 201 · application/json
{
  "subscription": {
    "id": 3,
    "url": "https://erp.buyer.example/hooks/croppath",
    "description": "Buyer ERP",
    "event_types": [
      "lot.sealed",
      "shipment.departed"
    ],
    "status": "active",
    "disabled_reason": null,
    "disabled_at": null,
    "consecutive_failures": 0,
    "created_by": "admin@coop.example",
    "created_at": 1790000000.5,
    "updated_at": 1790000000.5
  },
  "secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw3qdbLeXcY4o="
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · url
{
  "error": "invalid url: https:// only",
  "code": "invalid_url"
}
Phản hồi 400 · application/json · private
{
  "error": "invalid url: the host resolves to an address that is not a public one",
  "code": "invalid_url"
}
Phản hồi 400 · application/json · resolve
{
  "error": "invalid url: the host does not resolve",
  "code": "invalid_url"
}
Phản hồi 400 · application/json · event_types
{
  "error": "invalid event_types: a non-empty list of distinct types from lot.sealed, lot.recalled, lot.withdrawn, lab_result.recorded, shipment.departed, lot.trust_tier_changed, report.filed",
  "code": "invalid_event_types"
}
Phản hồi 400 · application/json · description
{
  "error": "invalid description: at most 200 characters on one line",
  "code": "invalid_description"
}
Phản hồi 400 · application/json · unknown
{
  "error": "unknown fields: secret",
  "code": "unknown_fields"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 400 · application/json · idempotency_key_not_supported
{
  "error": "idempotency key not supported",
  "code": "idempotency_key_not_supported"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 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"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json
{
  "error": "subscription limit reached: at most 20 per tenant",
  "code": "subscription_limit_reached"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json
{
  "error": "webhooks unavailable: no key-encryption key is configured",
  "code": "webhooks_unavailable"
}

GET /v1/webhooks/{id}

One webhook subscription

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: webhook_admin · getWebhook

Never its secret. Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a session or an API token of their role. Another tenant's answers like a missing one. no-store.

Tham số

TênVị tríKiểuMô tả
id
bắt buộc
pathstring

The subscription id.

Phản hồi

Mã trạng tháiKiểuMô tả
200WebhookSubscription
application/json

The subscription.

400Error
application/json

A bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin), tenant not allowed (X-Tenant).

404Error
application/json

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

405Error
application/json

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

500Error
application/json

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

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "id": 3,
  "url": "https://erp.buyer.example/hooks/croppath",
  "description": "Buyer ERP",
  "event_types": [
    "lot.sealed",
    "shipment.departed"
  ],
  "status": "active",
  "disabled_reason": null,
  "disabled_at": null,
  "consecutive_failures": 0,
  "created_by": "admin@coop.example",
  "created_at": 1790000000.5,
  "updated_at": 1790000000.5
}
Phản hồi 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PATCH /v1/webhooks/{id}

Change, disable or enable a webhook subscription

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: webhook_admin · updateWebhook

Changes the URL (checked as on create), the event types, the description, or enabled. Disabling fails the pending deliveries (subscription_disabled, redeliverable once enabled again); enabling resets the failure count. Audited (webhook.update, with the host, event types and status before and after). Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a session or an API token of their role.

Tham số

TênVị tríKiểuMô tả
id
bắt buộc
pathstring

The subscription id.

Nội dung yêu cầu

WebhookSubscriptionUpdate (bắt buộc)

Kiểu nội dung: application/json

Ví dụ yêu cầu · application/json
{
  "enabled": false
}

Phản hồi

Mã trạng tháiKiểuMô tả
200WebhookSubscription
application/json

The subscription as changed.

400Error
application/json

Invalid JSON, an empty body, an unknown field, a bad URL, event types, description or enabled, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

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

404Error
application/json

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

405Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

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

X-Request-Id500string

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

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "id": 3,
  "url": "https://erp.buyer.example/hooks/croppath",
  "description": "Buyer ERP",
  "event_types": [
    "lot.sealed",
    "shipment.departed"
  ],
  "status": "disabled",
  "disabled_reason": "manual",
  "disabled_at": 1790003600.5,
  "consecutive_failures": 0,
  "created_by": "admin@coop.example",
  "created_at": 1790000000.5,
  "updated_at": 1790003600.5
}
Phản hồi 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Phản hồi 400 · application/json · url
{
  "error": "invalid url: https:// only",
  "code": "invalid_url"
}
Phản hồi 400 · application/json · private
{
  "error": "invalid url: the host resolves to an address that is not a public one",
  "code": "invalid_url"
}
Phản hồi 400 · application/json · resolve
{
  "error": "invalid url: the host does not resolve",
  "code": "invalid_url"
}
Phản hồi 400 · application/json · event_types
{
  "error": "invalid event_types: a non-empty list of distinct types from lot.sealed, lot.recalled, lot.withdrawn, lab_result.recorded, shipment.departed, lot.trust_tier_changed, report.filed",
  "code": "invalid_event_types"
}
Phản hồi 400 · application/json · description
{
  "error": "invalid description: at most 200 characters on one line",
  "code": "invalid_description"
}
Phản hồi 400 · application/json · unknown
{
  "error": "unknown fields: secret",
  "code": "unknown_fields"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 400 · application/json · empty
{
  "error": "nothing to change: give url, event_types, description or enabled",
  "code": "nothing_to_change"
}
Phản hồi 400 · application/json · enabled
{
  "error": "invalid enabled: true or false",
  "code": "invalid_enabled"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 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"
}
Phản hồi 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/webhooks/{id}/rotate-secret

Replace a webhook subscription's secret (shown once)

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: webhook_admin · rotateWebhookSecret

A new secret replaces the old one at once: the next delivery is signed with it. Audited (webhook.rotate_secret, never the secret). Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a session or an API token of their role. no-store. A session must have confirmed its password within the last 10 minutes (SELF-1-2, #183), else 401 reauthentication_required before anything is done.

Tham số

TênVị tríKiểuMô tả
id
bắt buộc
pathstring

The subscription id.

Phản hồi

Mã trạng tháiKiểuMô tả
200WebhookSecret
application/json

The subscription, with its new secret shown this once.

400Error
application/json

A bad X-Request-Id; or an Idempotency-Key header, which this operation refuses: its response holds the new signing secret, which is stored only encrypted.

401Error
application/json

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

403Error
application/json

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

404Error
application/json

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

405Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

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

503Error
application/json

No key-encryption key is configured (AGRITRACE_ISSUER_KEK): a secret cannot be stored; nothing changed. Retry after Retry-After seconds once it is configured.

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

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

X-Request-Id500string

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

X-Request-Id503string

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

Retry-After503string

Seconds to wait before retrying.

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "subscription": {
    "id": 3,
    "url": "https://erp.buyer.example/hooks/croppath",
    "description": "Buyer ERP",
    "event_types": [
      "lot.sealed",
      "shipment.departed"
    ],
    "status": "active",
    "disabled_reason": null,
    "disabled_at": null,
    "consecutive_failures": 0,
    "created_by": "admin@coop.example",
    "created_at": 1790000000.5,
    "updated_at": 1790000000.5
  },
  "secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw3qdbLeXcY4o="
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 400 · application/json · idempotency_key_not_supported
{
  "error": "idempotency key not supported",
  "code": "idempotency_key_not_supported"
}
Phản hồi 401 · application/json · credentials
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 401 · application/json · reauthentication
{
  "error": "reauthentication required: confirm your password with POST /v1/auth/reauth",
  "code": "reauthentication_required"
}
Phản hồi 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 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"
}
Phản hồi 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Phản hồi 503 · application/json
{
  "error": "webhooks unavailable: no key-encryption key is configured",
  "code": "webhooks_unavailable"
}

GET /v1/webhooks/{id}/deliveries

A webhook subscription's delivery log

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: webhook_admin · listWebhookDeliveries

Newest first, one page (limit, default 50, at most 200; cursor from the previous page), optionally of one status. Deliveries finished more than 30 days ago are removed. Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a session or an API token of their role. Not audited (a read). no-store.

Tham số

TênVị tríKiểuMô tả
id
bắt buộc
pathstring

The subscription id.

status
không bắt buộc
query"pending" | "delivered" | "failed"

Only deliveries of this status.

limit
không bắt buộc
queryinteger

1 to 200 (default 50).

cursor
không bắt buộc
querystring

The previous page's next_cursor.

Phản hồi

Mã trạng tháiKiểuMô tả
200WebhookDeliveryPage
application/json

One page of deliveries.

400Error
application/json

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

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin), tenant not allowed (X-Tenant).

404Error
application/json

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

405Error
application/json

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

500Error
application/json

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

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

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

Cache-Control200string

no-store.

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

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

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "items": [
    {
      "id": 41,
      "subscription_id": 3,
      "event_id": "evt_6f1c2d3e4a5b46c7889900aabbccddee",
      "event_type": "lot.sealed",
      "status": "delivered",
      "attempts": 1,
      "next_attempt_at": null,
      "last_attempt_at": 1790000003.2,
      "last_status": 204,
      "last_error": null,
      "created_at": 1790000002.9,
      "delivered_at": 1790000003.4
    }
  ],
  "next_cursor": null
}
Phản hồi 400 · application/json · status
{
  "error": "invalid status: one of pending, delivered, failed",
  "code": "invalid_status"
}
Phản hồi 400 · application/json · limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Phản hồi 400 · application/json · cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 404 · application/json
{
  "error": "not found: 3",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/webhooks/{id}/deliveries/{delivery}/redeliver

Send a delivered or failed delivery again

Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: webhook_admin · redeliverWebhook

The delivery is pending again, due now, with a fresh retry window (attempts from 0) and the same event id and body. Audited (webhook.redeliver). Allowed for tenant_admin and platform_admin acting for the tenant (X-Tenant), through a session or an API token of their role.

Tham số

TênVị tríKiểuMô tả
id
bắt buộc
pathstring

The subscription id.

delivery
bắt buộc
pathstring

The delivery id.

Idempotency-Key
không bắt buộc
headerstring

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

Phản hồi

Mã trạng tháiKiểuMô tả
200WebhookDelivery
application/json

The delivery, pending again.

400Error
application/json

A bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

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

404Error
application/json

No such subscription of this tenant, or no such delivery of it.

405Error
application/json

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

409Error
application/json

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

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

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

500Error
application/json

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

Header của phản hồi

TênMã trạng tháiKiểuMô tả
X-Request-Id200string

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

Idempotent-Replayed200"true"

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

X-Request-Id400string

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

X-Request-Id401string

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

X-Request-Id403string

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

X-Request-Id404string

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

X-Request-Id405string

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

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

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

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

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

X-Request-Id422string

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

X-Request-Id500string

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

Ví dụ phản hồi

Phản hồi 200 · application/json
{
  "id": 41,
  "subscription_id": 3,
  "event_id": "evt_6f1c2d3e4a5b46c7889900aabbccddee",
  "event_type": "lot.sealed",
  "status": "pending",
  "attempts": 0,
  "next_attempt_at": 1790007200.5,
  "last_attempt_at": 1790000003.2,
  "last_status": 204,
  "last_error": null,
  "created_at": 1790000002.9,
  "delivered_at": null
}
Phản hồi 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Phản hồi 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Phản hồi 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Phản hồi 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Phản hồi 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Phản hồi 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Phản hồi 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Phản hồi 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"
}
Phản hồi 404 · application/json
{
  "error": "not found: 41",
  "code": "not_found"
}
Phản hồi 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Phản hồi 409 · application/json · disabled
{
  "error": "subscription disabled: enable it first",
  "code": "subscription_disabled"
}
Phản hồi 409 · application/json · pending
{
  "error": "delivery is pending: it is attempted again at its next attempt time",
  "code": "delivery_is_pending"
}
Phản hồi 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Phản hồi 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Phản hồi 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Phản hồi 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Phản hồi 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Phản hồi 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}