Skip to content

Set Webhook Secret - API Reference

Sets the shared secret used to sign every webhook we send you. Your server uses the same value to confirm a request is authentic — see Verifying webhooks for how.

You choose the value; there is no generate-a-secret endpoint. Use a CSPRNG rather than inventing one by hand:

Terminal window
openssl rand -hex 32

Calling this endpoint again replaces the previous secret. The account has one secret, shared by every monitor and every webhook URL.

POST https://api.socialdata.tools/user/webhook/secret

Headers

Authorization string required

Authorization Bearer header containing your SocialData API key

Example: Bearer YOUR_API_KEY

Body

secret string required

The shared secret used to sign webhook requests. Maximum 256 characters. Store it somewhere your webhook handler can read it, and treat it like a password

Example: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08

Code Examples

Terminal window
curl -X POST "https://api.socialdata.tools/user/webhook/secret" \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"secret": "YOUR_WEBHOOK_SECRET"}'

Example Responses

{
"status": "success",
"message": "Webhook secret updated"
}

Response Codes

  • 200 OK - request succeeded
  • 422 Unprocessable Content - validation failed (e.g. one of the required parameters was not provided)

Rotating the secret

New deliveries are signed with the new value as soon as the change takes effect. Deliveries already in flight were signed with the old one, so a strict handler will reject them.

If dropped events matter, accept either secret for a few minutes:

  1. Deploy a handler that treats a request as valid if it verifies against the old secret or the new one.
  2. Call this endpoint with the new secret.
  3. Once traffic has settled, remove the old secret from the handler.

Before you integrate