Menu

Build with

Webhooks

Register an endpoint once, verify it, and receive signed events from monitors and batches.

Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)

Webhook endpoints are registered once per team and referred to by id from monitors and batches. Events can always be pulled instead; a webhook is a convenience, not a requirement.

Endpoints

EndpointWhat it does
POST /v1/webhooksRegister a URL. Returns the endpoint with status: "pending" and its secret, shown once
POST /v1/webhooks/{id}/verifySends a webhook.test event carrying a random challenge. The endpoint becomes active when its 2xx answer contains HMAC-SHA256(secret, challenge) in hex. Repeating the challenge is not enough: the endpoint must hold the secret
GET /v1/webhooks, GET /v1/webhooks/{id}List, or read one. Free
POST /v1/webhooks/{id}/testSends a webhook.test event to an active endpoint
POST /v1/webhooks/{id}/rotateIssues a new secret, shown once. For 24 hours deliveries carry both signatures
GET /v1/webhooks/{id}/deliveriesThe delivery log
DELETE /v1/webhooks/{id}Remove it. Its monitors keep running and their events are pulled

Register and verify

Example
Shell
curl https://api.millionshort.com/v1/webhooks \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://hooks.example.com/millionshort", "description": "production" }'
Example
Shell
curl -X POST https://api.millionshort.com/v1/webhooks/$WEBHOOK_ID/verify \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY"

Only an active endpoint receives events. An endpoint still pending 24 hours after registration is deleted.

FieldTypeNotes
idstring
urlstring
descriptionstring or null
statuspending, active or disabled
secretstringStarts with whsec_. Only in the answers to register and rotate
created_atdate and time
last_success_atdate and time, or null
consecutive_failuresinteger

What your endpoint receives

A POST with a JSON body, the event, and three headers:

Text
MS-Event-Id: evt_01J...
MS-Timestamp: 1763460000
MS-Signature: t=1763460000,v1=<hex>

The signature is HMAC-SHA256(secret, "<event id>.<t>.<raw body>"), in hex. The key is the whole secret string, whsec_ included, as UTF-8 bytes. t is the same number as MS-Timestamp. Every delivery is signed, the verification challenge included. During a rotation there are two v1= values, and either may match.

Check the signature

Example
Python
import hashlib
import hmac
import time


def verify(secret, event_id, timestamp, signature_header, raw_body, tolerance=300):
    """True when the delivery is ours and recent. raw_body is bytes, exactly as received."""
    if abs(time.time() - int(timestamp)) > tolerance:
        return False
    signed = event_id.encode() + b"." + str(timestamp).encode() + b"." + raw_body
    expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    sent = [part[3:] for part in signature_header.split(",") if part.startswith("v1=")]
    return any(hmac.compare_digest(expected, candidate) for candidate in sent)

Your endpoint should:

  1. Reject a delivery whose timestamp is more than 300 seconds from now.
  2. Compare signatures in constant time, as above.
  3. Remember MS-Event-Id for 24 hours and drop repeats. A retry keeps the event id and carries a fresh timestamp and signature.
  4. Answer with a 2xx status quickly, and do the work afterwards.

Delivery rules

The delivery log

GET /v1/webhooks/{id}/deliveries returns the latest attempts, newest first:

FieldTypeNotes
event_idstring
event_typestring
attemptinteger
status_codeinteger or nullWhat your endpoint answered
duration_msinteger
okboolean
atdate and time

The log never holds the body of a delivery.

Limits

Event types

monitor.changed, monitor.failed, monitor.paused, extract_batch.completed and webhook.test. The Monitors page describes what each carries.

An Agent run started with a webhook_id delivers agent.completed when it ends, with the run's id, status, stop_reason and credits_used. See the webhook event.

This page as Markdown · llms.txt