Webhooks
Real-time notifications for payments, payouts, orders, and product updates via webhooks.
Overview
Webhooks allow your application to receive real-time notifications when events occur on ContentSellify. Instead of polling our API, webhooks push data to your endpoint automatically.
Base Webhook URL
Event Types
๐ฐ Payment Events
๐ฆ Order Events
๐ธ Payout Events
๐๏ธ Product Events
Webhook Payload Structure
All webhook events follow this structure:
{
"id": "evt_1234567890",
"type": "payment.completed",
"created_at": "2024-01-15T10:30:00Z",
"data": {
"order_id": "ord_abc123",
"amount": 4999,
"currency": "usd",
"customer": {
"id": "cus_xyz789",
"email": "customer@example.com"
},
"product": {
"id": "prod_456",
"title": "React Master Course",
"seller_id": "sel_def456"
}
}
}Setup Webhooks
- 1
Go to Dashboard โ API Settings โ Webhooks
- 2
Click Create Webhook Endpoint
- 3
Enter your endpoint URL (must be HTTPS)
Example: https://yourapp.com/api/webhooks
- 4
Select which events you want to receive
- 5
Save your Signing Secret - you'll need this to verify webhooks
Verify Webhook Signature
Always verify webhook signatures to ensure requests come from ContentSellify:
const crypto = require('crypto');
function verifyWebhookSignature(payload, signature, secret) {
const hash = crypto
.createHmac('sha256', secret)
.update(JSON.stringify(payload))
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(hash)
);
}
// Example usage in Express.js
app.post('/webhooks', (req, res) => {
const signature = req.headers['x-webhook-signature'];
const isValid = verifyWebhookSignature(
req.body,
signature,
process.env.WEBHOOK_SECRET
);
if (!isValid) {
return res.status(401).json({ error: 'Invalid signature' });
}
// Process webhook event
const { type, data } = req.body;
switch (type) {
case 'payment.completed':
handlePaymentCompleted(data);
break;
case 'order.created':
handleOrderCreated(data);
break;
// ... handle other events
}
res.status(200).json({ received: true });
});Best Practices
โก Respond Quickly
Return a 200 OK response within 5 seconds. Process heavy tasks asynchronously in the background.
๐ Handle Retries
We retry failed webhooks up to 3 times with exponential backoff. Make your endpoint idempotent to handle duplicate events.
๐ Always Verify Signatures
Never trust webhook payloads without verifying the signature. This prevents attackers from sending fake events.
๐ Log All Events
Keep detailed logs of received webhooks for debugging and audit trails.
Testing Webhooks
Test webhooks using our CLI or dashboard:
# Install ContentSellify CLI
npm install -g @contentsellify/cli
# Forward webhooks to local development server
contentsellify webhooks listen --forward-to http://localhost:3000/api/webhooks
# Send test webhook
contentsellify webhooks test --event payment.completed๐กTip: Use tools like ngrok to expose your local server for webhook testing during development.
Related Resources
Need Help with Webhooks?
Have questions about webhook implementation? Our developer support team is here to assist.
Contact Support