Webhooks
Webhooks allow you to receive real-time updates about results (and soon statuses) from the Parcha API. This guide explains how to use webhooks, including how to set them up, secure them with HMAC signatures, and test them.Setting Up Webhooks
Parcha API supports two types of webhooks:- Job Webhooks (
webhook_url): Receive notifications when the entire job is completed - Tool Webhooks (
tool_webhook_url): Receive real-time updates each time an LLM tool is executed during the job
Webhook Payloads
Job Webhook Payload
When a job is completed, Parcha API sends a POST request to your webhook URL with a payload containing job status information. Note: The webhook payload contains job status updates only, not the full check results.Fetching Full Check Results
To get the complete check results after receiving a webhook notification, use thegetJobById endpoint with include_check_results=true:
Tool Webhook Payload
Tool webhooks provide real-time updates for individual tool executions. You can filter events by tool ID. For example,kyb.incorporation_document_extractor provides events related to incorporation document checks in the following order:
- Text extraction results (fastest)
- Visual verification
- Fraud detection (slowest)
Text Extraction Results
The text extraction event is typically the fastest and includes important validation and extracted data fields:is_valid_document: Boolean indicating if the document is a valid incorporation documentbusiness_name: The primary name of the businessall_business_names: Array of all business names found in the documentincorporation_date: The date of incorporationbusiness_address: The primary business addressall_extracted_addresses: Object containing all addresses found in the document, categorized by typebusiness_activity: The stated purpose or activity of the businessjurisdiction: The jurisdiction where the business is incorporatedbusiness_registration_number: Array of registration numbers found in the document
Visual Verification Results
Fraud Detection Results
HMAC Signature Verification
To ensure the security and authenticity of webhook payloads, Parcha API signs each webhook request with HMAC-SHA256 signatures. Two signatures are provided in the webhook request headers:- Standard Signature (
X-Signature-SHA256): Signs the entire JSON payload - Compact Signature (
parcha-signature-compact): Signs only the case ID for lightweight verification
Standard Signature Verification
The standard signature is included in theX-Signature-SHA256 header and covers the entire request body.
To verify the standard signature:
- Compute the HMAC-SHA256 signature of the raw request body using your API secret key.
- Compare this computed signature with the one in the
X-Signature-SHA256header.
Parcha Compact Signature
The compact signature provides a lightweight alternative for verifying webhook authenticity without needing to process the entire payload. This signature is included in theparcha-signature-compact header and signs only the case ID from input_payload.id.
When to use the compact signature:
- When you need quick verification before processing large payloads
- When you want to validate the webhook source using only the case ID
- For implementing rate limiting or deduplication based on case ID
- When you need to verify webhooks in environments with limited payload access
- Extract the
idfield frominput_payloadin the webhook payload - Compute HMAC-SHA256 of the ID string using your API secret key
- Base64 encode the resulting digest
- The compact signature is only present when the payload contains
input_payload.id - Both signatures use the same API secret key
- The compact signature signs the string representation of the case ID
- Always use constant-time comparison (
hmac.compare_digestorcrypto.timingSafeEqual) to prevent timing attacks - The compact signature is useful for quick validation, but you should still verify the full signature for complete payload integrity
Testing Your Webhooks
Parcha API provides a/api/v1/testWebhook endpoint to help you test both job and tool webhooks. This endpoint sends sample payloads to your specified webhook URLs.
- Job webhooks by providing a
webhook_url - Tool webhooks by providing a
tool_webhook_url - Filtered tool webhooks by also including
tool_webhook_ids
Best Practices
- Always verify the HMAC signature to ensure the authenticity of webhook payloads.
- Implement proper error handling and retries in your webhook receiver to manage potential network issues or service interruptions.
- Process webhook payloads asynchronously to avoid blocking your webhook receiver.
- Store the raw payload for debugging purposes before processing it.
- Respond quickly to the webhook request (ideally within a few seconds) to avoid timeouts.
- When using tool webhooks, be prepared to handle events in any order as different tools have different processing times.
- Consider implementing separate endpoints for job webhooks and tool webhooks to simplify processing logic.