Create Webhook
Create a new webhook to receive real-time data from Scrapest when specified events occur.Endpoint
HTTP Request
Request Body
Request Parameters
Required Parameters
url
- Type: String
- Description: HTTPS endpoint URL to receive webhook events
- Format: Valid HTTPS URL
- Example:
https://your-domain.com/webhook
events
- Type: Array of strings
- Description: List of event types to subscribe to
- Options:
tweet.created- New tweets createdtweet.updated- Tweets updated (likes, retweets)user.updated- User profile updateswebhook.delivery_failed- Delivery failure notifications
- Example:
["tweet.created", "user.updated"]
Optional Parameters
filters
- Type: Object
- Description: Filters to apply to events before delivery
- Properties:
- keywords: Array of keywords to match
- users: Array of usernames to track
- language: Language code (e.g., “en”, “es”, “fr”)
- min_followers: Minimum follower count for users
- verified: Boolean to filter verified users only
secret
- Type: String
- Description: Secret key for webhook signature validation
- Length: 8-128 characters
- Auto-generated: If not provided, will be auto-generated
- Example:
your_webhook_secret
active
- Type: Boolean
- Description: Whether webhook should be immediately active
- Default:
true - Example:
true
description
- Type: String
- Description: Human-readable description of webhook purpose
- Max Length: 255 characters
- Example:
Webhook for programming tweets
Response Format
Success Response (201 Created)
Error Response (400 Bad Request)
Implementation Examples
JavaScript (Node.js)
Python
cURL
Webhook Verification
After creation, webhooks require verification:Verification Process
- Scrapest sends a POST request to your webhook URL
- Request contains verification challenge in the body
- Your endpoint must respond with the challenge value
- Webhook status changes to
active
Verification Request Format
Verification Response
Verification Implementation
Signature Validation
HMAC Signature
Each webhook request includes an HMAC signature for validation:Validation Implementation
Error Handling
Common Error Codes
400 Bad Request
- Invalid URL: Webhook URL is not a valid HTTPS endpoint
- Invalid Events: Event types are not recognized
- Invalid Filters: Filter parameters are malformed
401 Unauthorized
- Invalid API Key: API key is missing or invalid
- Insufficient Permissions: API key lacks webhook creation permissions
409 Conflict
- Duplicate Webhook: Webhook with same URL already exists
- Webhook Limit: Maximum number of webhooks reached
429 Too Many Requests
- Rate Limit: Too many webhook creation requests
- Retry After: Check
Retry-Afterheader for retry time
Error Handling Implementation
Best Practices
Security
- HTTPS Required: Always use HTTPS endpoints
- Secret Management: Store webhook secrets securely
- Signature Validation: Always validate webhook signatures
- Input Validation: Validate all incoming webhook data
Performance
- Fast Response: Respond to webhook requests quickly
- Async Processing: Process webhook data asynchronously
- Queue Management: Use message queues for high-volume webhooks
- Load Balancing: Distribute webhook load across servers
Reliability
- Idempotency: Handle duplicate webhook events
- Error Handling: Implement robust error handling
- Logging: Log all webhook deliveries for debugging
- Monitoring: Monitor webhook delivery success rates