Overview
Webhooks provide instant notifications when your projects finish generating, eliminating the need for constant polling. When you include awebhookUrl in your project creation request, InitRepo will send a POST request to that URL when generation completes.
Setup
Include awebhookUrl in your project creation request:
Webhook Payload
Webhook Headers
Payload Fields
string
Always “project.completed” for completion notifications.
string
ISO 8601 timestamp when the webhook was sent.
string
Unique identifier of the completed project.
string
Generated project name.
string
Always “completed” for success notifications.
integer
Total credits consumed for this project.
string
ISO 8601 timestamp when the project was created.
string
ISO 8601 timestamp when the project completed.
Security Requirements
HTTPS Only
- Webhook URLs must use HTTPS protocol
- HTTP URLs will be rejected during project creation
- TLS 1.2 or higher required
No Private IPs
- Private IP ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) are blocked
- Localhost addresses (127.0.0.0/8) are not allowed
- Link-local addresses (169.254.0.0/16) are blocked
Webhook Signature Verification (Required)
InitRepo signs all webhook payloads with HMAC-SHA256 using your webhook secret. Always verify signatures to ensure authenticity.Getting Your Webhook Secret
Your webhook secret is available in your InitRepo dashboard under API Keys. Each API key has its own unique webhook secret.Signature Verification Process
Python Example
Additional Security Measures
Rate Limiting Protection
- Implement rate limiting on your webhook endpoints
- InitRepo includes automatic retry protection against abuse
- Maximum 6 delivery attempts per webhook with exponential backoff
Request Validation
Error Handling
Enhanced Retry Logic
InitRepo uses an intelligent retry system with exponential backoff and jitter to handle failed webhook deliveries:Retry Schedule
- Attempt 1: Immediate delivery
- Attempt 2: 1 second + random jitter (0-500ms)
- Attempt 3: 2 seconds + random jitter (0-1s)
- Attempt 4: 4 seconds + random jitter (0-2s)
- Attempt 5: 8 seconds + random jitter (0-4s)
- Attempt 6: 16 seconds + random jitter (0-8s) - Final attempt
What Triggers Retries
- HTTP status codes other than 2xx (200-299)
- Network timeouts (>10 seconds)
- Connection refused or DNS resolution failures
- SSL/TLS handshake failures
Delivery Status Tracking
Each webhook attempt is logged with detailed status information available through the API:Webhook Monitoring
Access comprehensive delivery statistics through the API:Timeout Configuration
- Connection Timeout: 5 seconds to establish connection
- Response Timeout: 10 seconds to receive complete response
- Total Request Timeout: 15 seconds maximum per attempt
Response Requirements
- Success: Return HTTP status 200-299 to acknowledge receipt
- Failure: Any other status code triggers retry according to schedule
- Response Body: Ignored (can be empty or JSON)
- Response Time: Aim for <5 seconds to avoid timeouts
Error Scenarios
Permanent Failures (No Retries)
- URL returns 404 Not Found
- Invalid HTTPS certificate
- Webhook URL blocked by security policy
Temporary Failures (Will Retry)
- 5xx server errors
- Network timeouts
- Rate limiting (429 status)
- Connection refused
Best Practices
Idempotency
Logging and Monitoring
Rate Limiting
- Implement rate limiting on your webhook endpoint
- Expect up to 5 webhook attempts per project completion
- Handle bursts gracefully
Testing Webhooks
Local Development
Use tools like ngrok or localtunnel to expose local servers:Test Mode
Use test API keys for development - webhooks work the same way but don’t consume credits.Troubleshooting
Webhook Not Received
- Check URL: Ensure webhook URL is HTTPS and publicly accessible
- Verify Logs: Check your application logs for incoming requests
- Test Endpoint: Send a test POST request to your webhook URL
- Check Firewall: Ensure your server accepts POST requests on the webhook path
Duplicate Webhooks
- Implement Idempotency: Use project IDs to prevent duplicate processing
- Check Timestamps: Compare webhook timestamps to avoid processing old events
- Log Processing: Keep track of processed webhook events
Timeout Issues
- Optimize Response Time: Ensure your webhook handler responds within 10 seconds
- Async Processing: Move heavy processing to background jobs
- Return Early: Send 200 response immediately, process asynchronously