Webhooks
Real-time event notifications
Webhooks allow you to receive real-time notifications when events occur in CodePlanet. Instead of polling the API, webhooks push data to your endpoint when something happens.
Overview
When an event occurs (like a payment success or problem completion), CodePlanet sends an HTTP POST request to your configured webhook URL with event data.
Supported Events
| Event | Description |
|---|---|
payment.completed | Payment was successful |
payment.failed | Payment failed |
subscription.created | New subscription started |
subscription.cancelled | Subscription cancelled |
submission.accepted | Problem solved correctly |
certificate.earned | Certificate awarded |
streak.milestone | Streak milestone reached (7, 30, 100 days) |
Event Payload
All webhooks have this structure:
Example: Payment Completed
Example: Submission Accepted
Setting Up Webhooks
1. Create an Endpoint
Your endpoint must:
- Accept HTTP POST requests
- Return 2xx status code within 30 seconds
- Handle idempotency (same event may be sent multiple times)
2. Configure in Dashboard
Go to Settings → Developers → Webhooks and:
- Click "Add Endpoint"
- Enter your URL
- Select events to receive
- Copy your webhook secret
3. Verify Signatures
Always verify webhook signatures to ensure authenticity:
Security
Signature Verification
Every webhook includes:
x-codeplanet-signature: HMAC-SHA256 signaturex-codeplanet-timestamp: Unix timestamp
Always verify both to prevent replay attacks.
HTTPS Required
Webhook URLs must use HTTPS in production.
IP Allowlist
Webhooks are sent from these IPs:
34.120.XXX.XXX35.230.XXX.XXX
(Contact support for current IPs)
Retry Policy
If your endpoint fails (non-2xx response or timeout):
| Attempt | Delay |
|---|---|
| 1st retry | 1 minute |
| 2nd retry | 5 minutes |
| 3rd retry | 30 minutes |
| 4th retry | 2 hours |
| 5th retry | 24 hours |
After 5 retries, the webhook is marked as failed.
Best Practices
1. Respond Quickly
Return 200 immediately, then process asynchronously:
2. Handle Duplicates
Webhooks may be delivered multiple times. Use the event id for idempotency:
3. Log Everything
Keep logs of all webhook events for debugging:
4. Handle Failures Gracefully
If processing fails, don't return 200. Return 500 to trigger retry.
Testing
Webhook Testing Tool
Use the testing tool in the dashboard to send test events to your endpoint.
Local Development
Use ngrok to expose localhost:
Then use the ngrok URL as your webhook endpoint.
Monitoring
Check webhook delivery status in Settings → Developers → Webhooks → Logs:
- Successful deliveries ✓
- Failed attempts ✗
- Pending retries ⏳
Next Steps
- API Endpoints — Full API reference
- Authentication — Auth details
- Error Handling — Error codes