Overview
Dynamic Delivery allows you to programmatically handle product fulfillment by implementing a webhook endpoint that receives order information and returns delivery content. This is ideal for delivering digital products, license keys, game codes, or integrating with external fulfillment systems. When a customer purchases a product with dynamic delivery enabled, Komerza immediately sends a POST request to your configured webhook URL with order details, and your endpoint responds with the content to deliver to the customer.Dynamic Delivery is configured per product variant in your product settings
under delivery methods.
Use Cases
Digital Products
Deliver license keys, download links, or access codes in real-time
Third-Party Integration
Connect with external fulfillment systems or inventory management
Custom Logic
Implement complex delivery rules based on customer, product, or order data
Game Codes
Deliver game keys, activation codes, or in-game items automatically
How It Works
- Customer Purchases - A customer completes checkout for a product with dynamic delivery enabled
- Webhook Triggered - Komerza sends a POST request to your configured webhook URL
- Your Response - Your endpoint processes the request and returns the delivery content
- Customer Receives - The returned content is delivered to the customer, either as a single item or as one item per unit - see Response Format
Configuration
Setting Up Dynamic Delivery
- Navigate to your product in the Komerza Dashboard
- Select the variant you want to configure
- Choose Dynamic Delivery as the delivery method
- Enter your webhook endpoint URL
- Generate and save your webhook secret
Webhook Request
Request Headers
Signature Verification
All webhook requests include anX-Signature header containing an HMAC SHA256 signature. You should verify this signature to ensure the request is from Komerza.
Signature Calculation:
Payload Structure
The webhook receives a JSON payload with the following structure:Payload Fields
string (uuid)
required
The unique identifier of your store
string (uuid)
required
The unique identifier of the customer who made the purchase
string (uuid)
required
The unique identifier of the specific line item in the order
string (uuid)
required
The unique identifier of the product being delivered
string (uuid)
required
The unique identifier of the product variant being delivered
integer
required
The quantity of items purchased for this line item
object
required
Complete order information including customer details, all items, and payment
information. See the Order object in the API
Reference for full schema details.
Webhook Response
Response Format
Your endpoint can answer in one of two ways. Which you choose matters when a single purchase covers more than one unit.Plain text - one delivery
Respond with plain text (text/plain) containing the delivery content. It is shown
to the customer exactly as returned.
JSON - one delivery per unit
Respond with a JSON object containing anitems array, and each entry becomes a
separate delivered item. Use this when a purchase of ten should hand over ten distinct
keys rather than one block of text.
quantity field
(see Payload Fields) and return that many entries.
This form is required if resellers buy your stock in bulk. Buying stock up front only
works when each unit arrives as its own item, so a supplier answering in plain text
can only ever deliver one, and the rest of the purchase is refunded.
- The body must begin with
{(after any leading whitespace) and parse as a JSON object containing anitemsarray. Anything else is treated as plain text. - Entries that are JSON strings are delivered as-is. Entries of any other type - an object, for example - are delivered as their raw JSON.
- Blank and whitespace-only entries are skipped. If that leaves no usable entries, the whole body is treated as plain text instead.
Response Requirements
string
required
text/plain for a single delivery, or application/json for the items form. The
body is inspected either way, so a mislabelled content type does not by itself break
delivery.integer
required
Must be
200 for successful delivery. Any other status code will be treated
as a failure and trigger retry logic.string
required
The actual delivery content to show the customer. Can be multi-line. Each delivered
item is stored up to 10,000 characters and anything beyond that is cut off, so keep
individual items comfortably below it.
Example Implementations
Honouring Quantity
The examples above return one delivery regardless of how many units were bought. To hand over one item per unit, readquantity from the payload and return that many entries.
Timeout and Retry Logic
Timeout
Your webhook endpoint has 20 seconds to respond. If your endpoint doesn’t respond within this timeframe, the request will be considered failed and will be retried.Retry Policy
Komerza implements an automatic retry mechanism with exponential backoff for failed webhook deliveries:- Retry Attempts: 3 automatic retries
- Backoff Strategy: Exponential (2^retry seconds)
- 1st retry: after 2 seconds
- 2nd retry: after 4 seconds
- 3rd retry: after 8 seconds
Circuit Breaker
To protect your endpoint from being overwhelmed, Komerza implements a circuit breaker:- Threshold: 5 consecutive failures
- Break Duration: 30 seconds
- Behavior: After 5 consecutive failures, requests are paused for 30 seconds before attempting again
Error Handling
Common Error Scenarios
Invalid Signature (401)
Invalid Signature (401)
Cause: The signature verification failedSolution:
- Verify you’re using the correct webhook secret
- Ensure you’re reading the raw request body (not parsed JSON)
- Check your HMAC implementation matches the algorithm (SHA256, HEX encoded)
Timeout (408)
Timeout (408)
Cause: Your endpoint didn’t respond within 20 seconds Solution: -
Optimize your delivery generation logic - Use caching for frequently accessed
data - Consider asynchronous processing for complex operations
Server Error (500)
Server Error (500)
Cause: Your endpoint returned an error response Solution: - Check your
application logs for errors - Implement proper error handling and logging -
Validate the payload structure before processing
Circuit Breaker Triggered
Circuit Breaker Triggered
Cause: Too many consecutive failures (5+)Solution:
- Check your server health and availability
- Review error logs to identify the root cause
- Implement health checks and monitoring
- The circuit breaker will automatically reset after 30 seconds
Logging and Debugging
Komerza logs all webhook requests and responses for debugging purposes:- Request Body: Stored (truncated to 8,192 characters)
- Response Body: Stored (truncated to 900 characters)
- Response Code: Recorded for each attempt
- Signature: Stored for verification
Testing
Test Webhook Locally
Use a tool like ngrok or cloudflared to expose your local development server:Manual Testing
You can manually test your webhook endpoint by simulating a request:Production Testing
- Create a test product with dynamic delivery enabled
- Point it to your staging webhook endpoint
- Make a test purchase (use test mode if available)
- Verify the delivery content is generated correctly
- Check webhook execution logs in your dashboard
Support
Help Center
Browse our knowledge base and guides
Discord Community
Get help from the community and Komerza team
System Status
Check webhook and API system status
Telegram
Join our Telegram community for support