Skip to main content
You are viewing the documentation of release 26.1, which is no longer the current one. Go to the documentation of the current release 26.2.

Consuming Webhooks

This scenario demonstrates how to receive and process webhook notifications from Circularo. Webhooks provide real-time updates about document events, allowing your application to respond immediately to changes in document status without the need for polling. Key features:
  • Receive webhook notifications as HTTP POST requests
  • Verify webhook authenticity using HMAC signatures
  • Process different types of document events
  • Implement a simple webhook receiver in various programming languages

Understanding Webhook Payloads

When an event occurs in Circularo, a webhook notification is sent to your configured endpoint as an HTTP POST request with a JSON payload containing:
  • documentId: The unique identifier of the document that triggered the event
  • event: The type of event that occurred (e.g., documentCreated, documentSigned)
  • actor: The user who performed the action that triggered the event
  • timestamp: The date and time when the event occurred

Webhook Security

To ensure the authenticity of webhook notifications:
  • HMAC Verification: Webhook requests can include an x-circularo-signature header with a SHA-256 HMAC signature
  • Signature Calculation: The signature is calculated using the webhook’s HMAC secret and the request body
  • Verification Process: Your application should calculate the expected signature and compare it with the received signature
  • Security Best Practices: Always verify signatures before processing webhook data to prevent spoofing
Never expose your HMAC secret in client-side code. Signature verification should always be performed on your server.

Prerequisites

Before consuming webhooks, you need:
  • A publicly accessible URL that can receive HTTP POST requests
  • A webhook configured in Circularo pointing to your URL
  • If using HMAC verification: The secret key configured when creating the webhook

Implementing a Webhook Receiver

To consume webhooks from Circularo, you need to implement an HTTP endpoint that can receive POST requests. Below are examples of webhook receivers in different programming languages.

Example Webhook Receiver Implementation

These examples show basic webhook receivers. In production, add proper error handling, logging, and business logic based on the event type.

Node.js (Express)

Python (Flask)

PHP

Best Practices for Webhook Consumption

  • Respond Quickly: Always respond to webhook requests promptly to prevent timeouts
  • Verify Signatures: Always verify webhook signatures to ensure authenticity (when HMAC secret is configured)
  • Process Asynchronously: For time-consuming operations, acknowledge the webhook immediately and process the data in the background
  • Implement Retry Logic: Be prepared to handle temporary failures in your webhook processing

Common Webhook Events

  • documentCreated: A new document has been created in the system
  • signRequest: A document has been shared with recipients for signing
  • documentSigned: A document has been signed by a user
  • documentCompleted: All required signatures have been collected for a document
  • signRejected: A recipient has rejected the document signing request
  • documentDeleted: A document has been deleted from the system

Troubleshooting Webhooks

  • Webhook Not Received: Verify your endpoint is publicly accessible and the webhook is correctly configured
  • Signature Verification Fails: Ensure you’re using the correct HMAC secret and properly handling the raw request body
  • Intermittent Failures: Implement proper logging to identify patterns in webhook failures
  • Testing Webhooks: Use services like webhook.site for initial testing before implementing your own endpoint