Overview
Webhooks allow you to receive real-time HTTP notifications when events occur in your Percify account. Instead of polling the API for status updates, webhooks push updates to your server automatically.Benefits
Real-Time Updates
Get notified instantly when events occur
Reduced API Calls
No need to poll for status updates
Efficient
Save credits and reduce latency
Setting Up Webhooks
1. Create an Endpoint
Create an HTTPS endpoint on your server to receive webhook events:2. Register Webhook URL
Register your endpoint in the Percify dashboard:1
Navigate to Settings
Go to Dashboard → Settings → Webhooks
2
Add Endpoint
Click “Add Endpoint” and enter your webhook URLRequirements:
- Must be HTTPS (required for production)
- Must respond within 10 seconds
- Should return 2xx status code
3
Select Events
Choose which events to receive:
- All events (recommended for development)
- Specific event types only
4
Save and Test
Save your webhook and click “Send Test Event” to verify
3. Verify Webhook Signatures
Always verify webhook signatures to ensure requests are from Percify:Event Types
Avatar Events
avatar.completed
Fired when avatar generation completes successfully.
avatar.failed
Fired when avatar generation fails.
avatar.published
Fired when an avatar is published to the community feed.
Video Events
video.completed
Fired when video generation completes.
video.failed
Fired when video generation fails.
Audio Events
audio.completed
Fired when audio generation completes.
voice.cloned
Fired when voice cloning completes.
Credit Events
credits.low_balance
Fired when credit balance drops below threshold.
credits.purchased
Fired when credits are purchased.
User Events
tier.upgraded
Fired when user upgrades subscription tier.
Implementing Event Handlers
Complete Example
Best Practices
Always Verify Signatures
Always Verify Signatures
Never process webhooks without signature verification. This prevents replay attacks and ensures authenticity.
Respond Quickly
Respond Quickly
Acknowledge receipt within 10 seconds. Process heavy tasks asynchronously.
Handle Retries
Handle Retries
Percify retries failed webhooks with exponential backoff. Make your handlers idempotent.
Use Queue for Heavy Processing
Use Queue for Heavy Processing
Log All Events
Log All Events
Keep detailed logs for debugging:
Testing Webhooks
Local Development with ngrok
Test Events
Send test events from the dashboard or via CLI:Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| Webhooks not received | URL not HTTPS | Use HTTPS for production |
| 401 Invalid signature | Wrong secret or verification logic | Check webhook secret in dashboard |
| Timeout errors | Handler takes too long | Respond within 10s, process async |
| Duplicate events | Retry logic | Implement idempotent handlers |
| Events out of order | Network delays | Don’t rely on event order |
Security Checklist
- Always verify webhook signatures
- Use HTTPS endpoints only
- Respond within 10 seconds
- Store webhook secrets securely
- Implement idempotent handlers
- Log all webhook events
- Monitor for suspicious activity
- Rate limit webhook endpoint
- Validate event data structure
- Handle errors gracefully