User Webhooks

Create and manage webhooks to receive real-time notifications when debates complete, verdicts are delivered, and more.

6 min read
Share

Webhooks let you receive HTTP POST notifications whenever key events occur in your AskVerdict account — such as when a debate finishes or an outcome is recorded. Each delivery is signed with HMAC-SHA256 so you can verify requests are authentic.

HTTPS Required

Webhook URLs must use https://. Plain HTTP endpoints are rejected at creation time.


Webhook Events

When creating or updating a webhook, you subscribe to one or more of the following events:

EventFired when
debate.createdA new debate is created
debate.completedA debate finishes and a verdict is available
debate.failedA debate fails due to an engine or provider error
outcome.recordedA real-world outcome is recorded against a debate
outcome.updatedAn existing outcome is updated
chain.createdA new debate chain is created
chain.updatedA debate chain is updated

Payload Signature Verification

Every webhook delivery includes an X-Verdict-Signature header containing an HMAC-SHA256 hex digest of the raw request body, signed with your webhook's secret.

Store Your Secret Securely

The signing secret is returned once at creation time and is never exposed again. If you lose it, delete the webhook and create a new one.

typescript
import { createHmac } from "crypto";
 
function verifySignature(
  rawBody: string,
  signature: string,
  secret: string
): boolean {
  const expected = createHmac("sha256", secret)
    .update(rawBody)
    .digest("hex");
  return expected === signature;
}
 
// In your webhook handler:
const sig = req.headers["x-verdict-signature"];
const body = await req.text(); // raw body before parsing
if (!verifySignature(body, sig, process.env.WEBHOOK_SECRET)) {
  return new Response("Unauthorized", { status: 401 });
}

Endpoints

List Webhooks

GET/api/webhooks

List all webhooks registered for the authenticated user, plus the supported event types.

No request body or query parameters required.

Secret Not Returned on List

The secret field is omitted from list responses. It is only returned once — immediately after creation.


Create Webhook

POST/api/webhooks

Register a new webhook endpoint. Returns the signing secret exactly once.

NameTypeRequiredDescription
urlstringRequiredHTTPS endpoint to receive event payloads. Must start with 'https://'.
eventsstring[]RequiredArray of event names to subscribe to. At least one event required. See the event table above for valid values.
descriptionstringOptionalHuman-readable label for this webhook. Max 500 characters.
bash
curl -X POST https://api.askverdict.ai/api/webhooks \
  -H "Authorization: Bearer vrd_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://myapp.example.com/hooks/askverdict",
    "events": ["debate.completed", "debate.failed"],
    "description": "Production webhook"
  }'

Error Responses

CodeErrorDescription
400VALIDATION_ERRORURL is not HTTPS, events array is empty, or contains unknown event names
401UNAUTHORIZEDInvalid or missing API key

Update Webhook

PUT/api/webhooks/:id

Update an existing webhook's URL, event subscriptions, active state, or description.

Path Parameters

ParameterTypeDescription
idstringThe webhook ID

All body fields are optional. Only supplied fields are updated.

NameTypeRequiredDescription
urlstringOptionalNew HTTPS endpoint URL. Must start with 'https://'.
eventsstring[]OptionalReplacement list of subscribed event names. Must contain at least one event.
activebooleanOptionalSet to false to pause deliveries without deleting the webhook. Set to true to resume.
descriptionstring | nullOptionalUpdated description. Max 500 characters. Pass null to clear.
bash
curl -X PUT https://api.askverdict.ai/api/webhooks/wh_abc123def456 \
  -H "Authorization: Bearer vrd_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "events": ["debate.completed", "outcome.recorded", "outcome.updated"],
    "active": true
  }'

Error Responses

CodeErrorDescription
400VALIDATION_ERRORInvalid URL, empty events array, or unknown event name
404NOT_FOUNDWebhook not found or does not belong to authenticated user

Delete Webhook

DELETE/api/webhooks/:id

Permanently delete a webhook and all its delivery history.

Path Parameters

ParameterTypeDescription
idstringThe webhook ID

Delivery History Deleted

Deleting a webhook also deletes all delivery log entries via cascading foreign key. This cannot be undone.


Delivery History

List Deliveries

GET/api/webhooks/:id/deliveries

List delivery attempts for a webhook, with status and response details.

Path Parameters

ParameterTypeDescription
idstringThe webhook ID

Query Parameters

ParameterTypeDefaultMaxDescription
limitinteger20100Number of delivery records to return
offsetinteger0Number of records to skip (for pagination)
bash
curl "https://api.askverdict.ai/api/webhooks/wh_abc123def456/deliveries?limit=20&offset=0" \
  -H "Authorization: Bearer vrd_your_api_key"

Automatic Retries

AskVerdict automatically retries failed deliveries up to 3 times with exponential backoff: 5 seconds, 30 seconds, then 5 minutes. After 3 failures the delivery is marked permanently failed. Use the redeliver endpoint to manually retry at any time.


Redeliver a Delivery

POST/api/webhooks/:id/deliveries/:deliveryId/redeliver

Queue a new delivery attempt based on the original event payload of a previous delivery.

This is useful for re-processing a failed delivery or replaying a specific event after fixing your endpoint.

Path Parameters

ParameterTypeDescription
idstringThe webhook ID
deliveryIdstringThe delivery record ID to re-trigger

No request body required.

bash
curl -X POST \
  "https://api.askverdict.ai/api/webhooks/wh_abc123def456/deliveries/del_uvw321/redeliver" \
  -H "Authorization: Bearer vrd_your_api_key"

The deliveryId in the response is the ID of the newly queued attempt. Poll the deliveries list to check its outcome.

Error Responses

CodeErrorDescription
404NOT_FOUNDWebhook or delivery not found, or does not belong to authenticated user

Send Test Ping

POST/api/webhooks/:id/test

Send a synthetic test event to your webhook endpoint to verify connectivity and signature verification.

The test ping sends a ping event with a minimal payload. It is recorded in your delivery history like any other delivery.

Path Parameters

ParameterTypeDescription
idstringThe webhook ID

No request body required.

bash
curl -X POST https://api.askverdict.ai/api/webhooks/wh_abc123def456/test \
  -H "Authorization: Bearer vrd_your_api_key"

Error Responses

CodeErrorDescription
404NOT_FOUNDWebhook not found or does not belong to authenticated user

Was this page helpful?