Instead of polling the API, register a webhook endpoint and SocialAPI will POST a signed payload to your server whenever a new comment, DM, review, or mention arrives.Documentation Index
Fetch the complete documentation index at: https://docs.social-api.ai/llms.txt
Use this file to discover all available pages before exploring further.
Register an endpoint
Endpoints can be registered in the dashboard under Webhooks → Add Endpoint, or via the API:secret is returned once. Store it immediately in your environment. It cannot be retrieved again. You use it to verify incoming signatures.
When you create an endpoint, SocialAPI sends a verification ping to your URL. Your server must respond with a
2xx status code or the endpoint will not be saved. Make sure your server is running and reachable before registering.Event types
| Event | When it fires |
|---|---|
comment.received | A new comment arrives on any connected account |
dm.received | A new direct message arrives (may include metadata.referral if the DM originated from an ad) |
dm.sent | Your account sent a direct message (echo confirmation from Meta). |
dm.referral | A user clicked an ad or referral link without sending a message. The interaction has empty content and includes metadata.referral. |
review.received | A new review arrives (Google Business Profile) |
mention.received | Your account is mentioned on a supported platform |
Payload format
Every webhook POST has a JSON body with anevent field and a data field containing the full interaction object:
data object is the same Interaction shape returned by GET /accounts/{id}/comments (and the equivalent DM, review, and mention endpoints). The id field is a stable SocialAPI interaction ID - see Interaction IDs.
Referral metadata
When a DM originates from an ad click (Instagram CTD or Facebook CTM ads), the interaction includes referral context inmetadata.referral:
dm.referral events (standalone ad clicks without a message) have empty content.text and always include metadata.referral.
Request headers
Every webhook request includes:| Header | Value |
|---|---|
Content-Type | application/json |
X-SocialAPI-Signature | sha256=<hmac-sha256-hex> |
X-SocialAPI-Event | The event type, e.g. comment.received |
Verifying signatures
Always verify theX-SocialAPI-Signature header before processing a webhook. This confirms the payload came from SocialAPI and was not tampered with.
The signature is HMAC-SHA256 of the raw request body, using your endpoint secret as the key, prefixed with sha256=.
- Node.js
- Python
- Go
Use a constant-time comparison (
timingSafeEqual / compare_digest / hmac.Equal) to prevent timing attacks. A simple string equality check is not safe.Responding to webhooks
Your endpoint must return an HTTP2xx status within 10 seconds. The webhook HTTP client enforces a 10-second timeout per delivery attempt. Any non-2xx response or a timeout is treated as a delivery failure.
Return 200 immediately and process the event asynchronously if your handler does heavier work.
Retry behavior
Failed deliveries are automatically retried up to 5 attempts with exponential backoff:| Attempt | Delay |
|---|---|
| 1 | Immediate |
| 2 | ~30 seconds |
| 3 | ~5 minutes |
| 4 | ~30 minutes |
| 5 | ~3 hours |
failed and no further retries occur.
Managing endpoints
List endpoints
Get endpoint details
Retrieve a single endpoint with delivery statistics (delivered/failed counts for the last 24 hours and 7 days). The secret is shown as a hint (last 4 characters only).Update an endpoint
Change the URL, subscribed events, or toggle delivery on/off. All fields are optional; provide at least one.Delete an endpoint
Delivery monitoring
Every webhook delivery is recorded with its status, HTTP response code, and duration. You can inspect delivery history, view individual attempts, send test payloads, and retry failed deliveries.| Endpoint | Description |
|---|---|
GET /v1/webhooks/{id}/deliveries | List deliveries (filterable by status and event_type, cursor-paginated) |
GET /v1/webhooks/{id}/deliveries/{did} | Full delivery detail including payload and all retry attempts |
POST /v1/webhooks/{id}/deliveries/{did}/retry | Re-enqueue a failed delivery |
POST /v1/webhooks/{id}/test | Send a test payload to verify your endpoint is working |
Security best practices
- Always verify signatures - never trust a webhook payload without checking
X-SocialAPI-Signature - Store your secret in an environment variable - never hardcode it or commit it to source control
- Use HTTPS - HTTP endpoints are rejected at registration time
- Respond quickly - return
200before doing heavy processing to avoid timeouts and spurious retries - Make handlers idempotent - retries mean the same event may arrive more than once; use the interaction
idto deduplicate