Skip to main content
Webhook endpoints are registered through the signed partner API. PayFi can keep multiple endpoints per partner integration, and each endpoint declares which events it wants to receive. PayFi only sends HTTPS callbacks and blocks localhost, private IP, link-local, metadata, and credential-bearing URLs. Payloads are redacted: raw documents, prompts, completions, secrets, signatures, presigned URLs, and full tax IDs are never sent.

Manage endpoints

Use the same PayFi partner authentication headers used by the rest of the API.
  • GET /v1/webhooks
  • POST /v1/webhooks
  • GET /v1/webhooks/{webhookId}
  • PATCH /v1/webhooks/{webhookId}
  • DELETE /v1/webhooks/{webhookId}
  • POST /v1/webhooks/{webhookId}/test
Create request:
PayFi generates the webhook signing secret and returns it only in the create response or when rotateSecret is true on update. Store it immediately.

Events

Supported events:
  • operation.created
  • operation.requirements.ready
  • operation.documents.partial
  • operation.analysis.completed
  • operation.action_required
  • operation.manual_review.completed
  • operation.callback.failed
operation.callback.failed is emitted to other subscribed endpoints when a delivery fails terminally. PayFi does not recursively emit operation.callback.failed for a failed callback-failed delivery.

Payload

The API Reference includes one schema per event:
  • WebhookOperationCreatedPayload
  • WebhookDocumentsPartialPayload
  • WebhookAnalysisCompletedPayload
  • WebhookActionRequiredPayload
  • WebhookManualReviewCompletedPayload
  • WebhookCallbackFailedPayload
All events share the same top-level shape so partners can route by event first and then apply event-specific rules. Default shape:
Do not treat webhook delivery as the source of truth for PayFi state. The source of truth remains GET /v1/operations/{operationId}.

End-to-end flow

  1. The partner creates one or more webhook endpoints with POST /v1/webhooks.
  2. PayFi validates the signed partner request, reserves the idempotency key, validates the URL, generates a signing secret, stores the encrypted secret, and returns the plaintext secret once.
  3. When an operation changes state, PayFi selects active endpoints subscribed to that event.
  4. PayFi builds the allowlisted payload, redacts it, serializes it to raw JSON, hashes the raw body, and persists a WebhookDelivery before any HTTP call.
  5. The worker loads due deliveries, reloads the endpoint, revalidates that it is active and has a safe URL, decrypts the endpoint secret, verifies the stored payload hash, signs the exact raw JSON body, and sends the callback.
  6. PayFi persists every attempt with status, response status, response body hash, request header hash, duration, failure code, and attempted timestamp.
  7. A 2xx response marks the delivery as DELIVERED. A retryable failure sets RETRY_SCHEDULED and nextAttemptAt. A terminal failure marks the delivery as FAILED.

Registration validations

Webhook management endpoints use the same partner request signing model as the rest of the API:
  • X-PayFi-Api-Key
  • X-PayFi-Nonce
  • X-PayFi-Signature
  • Idempotency-Key on create, update, delete, and test requests
PayFi validates:
  • API key is active and scoped to the partner integration.
  • Nonce has not been replayed.
  • Request timestamp is inside the allowed skew.
  • HMAC signature matches the exact raw request body.
  • Idempotency key is reused only with the same method, path, and body hash.
  • Webhook ID belongs to the signed partner integration.
  • URL uses HTTPS and does not include credentials.
  • URL host is not localhost, private IP, link-local, or metadata infrastructure.
  • eventTypes contains only supported event names.
  • Signing secrets are generated server-side and returned only on create or explicit rotation.

Delivery validations

Before each HTTP delivery attempt, PayFi validates the stored delivery again:
  • Endpoint still exists, is active, and belongs to the same organization and partner integration.
  • Endpoint URL still passes SSRF validation.
  • Endpoint signing secret decrypts successfully.
  • Re-serialized payload hash matches the persisted payloadHash.
  • Payload is signed with the exact raw JSON body that will be sent.
  • Response bodies are hashed for auditability; raw response bodies are not stored.
  • Authorization headers, webhook secrets, signatures, raw documents, prompts, completions, and full tax IDs are never written into delivery logs.
These checks happen on retries too, so disabling an endpoint or rotating a secret affects future attempts without changing already persisted delivery payloads.

Signature verification

PayFi signs the exact raw JSON body and sends:
Signature base string:
Use the webhook signing secret as the HMAC-SHA256 key. Verify the signature before parsing business fields, using the exact raw body bytes received by your HTTP server.

Retries

PayFi retries transient partner processing failures:
  • network errors
  • timeout
  • HTTP 408
  • HTTP 429
  • any HTTP 5xx
Terminal failures:
  • any HTTP 2xx: delivered
  • HTTP 4xx except 408 and 429: failed
Retry schedule: Partners should make webhook handlers idempotent by storing the x-payfi-webhook-id header or a tuple of event and operationId.

Test delivery

POST /v1/webhooks/{webhookId}/test sends one signed sample payload to the endpoint. Test deliveries do not schedule retries, so a failed test response is terminal for that test request.