Create Webhook
Register a new webhook endpoint to receive QR Ph transaction notifications
Overview
The Create Webhook endpoint allows you to register a new webhook URL that will receive real-time notifications when QR Ph transactions complete. You can specify which transaction events (success or declined) to receive and enable or disable the webhook immediately.Endpoint
Authentication
This endpoint requires HTTP Basic Authentication using your Secret Key.Request
Headers
| Header | Value | Required | Description |
|---|---|---|---|
Authorization | Basic {base64(secret_key:)} | Yes | HTTP Basic Auth with your secret key |
Content-Type | application/json | Yes | Request body format |
activation-code | string | No | Merchant activation code for multi-merchant setups |
"MERCHANT_ABC_123"When you create a webhook with an activation code, Modulus Labs includes the same activation-code in the header of webhook notifications sent to your endpoint.Prerequisites
Before creating a webhook, ensure you have:- Your Secret Key for HTTP Basic Authentication
Encrypted Payload Structure
The request body must contain arequest object with a JWE-encrypted Token that includes your webhook configuration:
Body Parameters (Encrypted Payload)
Token field. See the Encryption Guide for details on creating JWE tokens.| Field | Type | Required | Description |
|---|---|---|---|
callbackUrl | string | Yes | HTTPS URL where Modulus Labs sends webhook notifications |
webhookAction | string | Yes | Transaction events to receive: QRPH_SUCCESS, QRPH_DECLINED |
callbackUrl
callbackUrl
- Format: Valid HTTPS URL
- Example:
"https://api.yourcompany.com/webhooks/modulus"
- Must use HTTPS protocol (HTTP not supported in production)
- Must be publicly accessible from the internet
- Must respond within 10 seconds
- Should return
200 OKto acknowledge receipt
webhookAction
webhookAction
QRPH_SUCCESS- Receive notifications when payments succeedQRPH_DECLINED- Receive notifications when payments are declined
"QRPH_SUCCESS"Example Payload (Before Encryption)
Response
Success Response
Status Code:201 Created
Returns the created webhook object with a unique id that you can use to update or delete the webhook later.
a78efd32-de3b-4854-b599-11ae9f98f97e"QRPH_SUCCESS" "QRPH_DECLINED"ENABLED or DISABLEDExample: "ENABLED""https://api.yourcompany.com/webhooks/modulus"Response Example
Error Responses
400 Bad Request
400 Bad Request
400Causes:- Invalid webhook URL format
- Missing required fields
- Invalid action values
- Invalid status value
- Ensure callbackUrl uses HTTPS protocol
- Verify all required fields are present
- Check that actions contain valid values (
QRPH_SUCCESS,QRPH_DECLINED) - Ensure status is either
ENABLEDorDISABLED
401 Unauthorized
401 Unauthorized
409 Conflict
409 Conflict
409Cause: Webhook URL already registered for this merchantResponse Example:- Use a different webhook URL, or
- Update the existing webhook using Update Webhook API, or
- Delete the existing webhook and create a new one
500 Internal Server Error
500 Internal Server Error
500Cause: Unexpected server errorSolution:- Retry the request
- If the issue persists, contact Modulus Labs support with the reference number
Multi-Merchant Setup
If you manage multiple merchants, use theactivation-code header to associate the webhook with a specific merchant:
activation-code header will be included in the request:
Use Cases
E-commerce Integration
E-commerce Integration
POS System
POS System
Development and Testing
Development and Testing
Best Practices
Use HTTPS Only
Save Webhook ID
id in your database. You’ll need it to update or delete the webhook.Test Before Enabling
DISABLED status during development. Test with the Simulate API before enabling.Include Both Actions
QRPH_SUCCESS and QRPH_DECLINED to handle all transaction outcomes.Unique URLs per Environment
Verify Connectivity First
Validation Checklist
Before creating a webhook, verify:Webhook Endpoint is Ready
- Endpoint accepts POST requests
- Endpoint responds within 10 seconds
- Endpoint can decrypt JWE payloads
- Endpoint implements idempotency
URL is Accessible
- URL uses HTTPS protocol
- URL is publicly accessible from the internet
- Firewall allows incoming requests
- SSL certificate is valid
Authentication is Configured
- Secret key is correct
- Authorization header format is valid
- Using correct environment (sandbox vs production)
What Happens Next?
After creating a webhook:Webhook is Registered
Transactions Trigger Notifications
Automatic Retries
200 OK, Modulus Labs automatically retries up to 3 more times at 15-minute intervals.Next Steps
Test Your Webhook
View Webhooks
Update Webhook
Receiving Webhooks
Authorizations
HTTP Basic Authentication using your Secret Key as the username and an empty password
Headers
Optional activation code to identify which merchant this webhook belongs to. Used for multi-merchant environments.
Body
Response
Webhook created successfully
Unique identifier for the webhook
List of transaction events this webhook receives
QRPH_SUCCESS, QRPH_DECLINED Current status of the webhook
ENABLED, DISABLED The HTTPS URL where notifications are sent