Skip to main content
Menu
Account / Webhooks
Account

Webhooks

Receive signed events from Panward on your own server, check each signature and handle retries and duplicates.

7 minute readUpdated 15 November 2026Python · Node

What webhooks are for#

A webhook endpoint is an https URL of yours that Panward sends account and operations events to, signed with a secret only you and Panward hold. Event bodies are metadata only: ids, states and amounts. They never contain request or response content, and nothing in them names who served a model.

Create an endpoint#

You need the Owner or Admin role. In the console open Integrations and choose Add endpoint. Give the URL, the events to send, optionally the projects to limit it to, and a description.

  • The URL must be https and resolve to a public address. Internal address ranges are refused.
  • An organization has at most 20 endpoints.
  • The signing secret (whsec_…) is shown once, when the endpoint is created. Store it in your secret manager. Panward shows only its last four characters after that.

Events#

An endpoint receives the events you choose for it in the Add endpoint dialog (events in the API). Alert messages are not chosen there: they go to an endpoint that an alert rule uses as its channel. Every event below is sent today, and its data holds exactly the fields listed.

EventWhen it is sent
receipt.verification_failedA Sealed request's receipt became final at level failed, unless the client aborted the request. The request is credited back. Data: request_id, receipt_id, project_id, model, tier, region, verification_level, failure_reason, billing_state, credited_nano_usd.
alert.firingAn alert rule that uses the endpoint as its channel started firing, is still firing (a reminder) or was tested (see Use an endpoint as an alert channel). Data: alert_event_id, rule_id, rule_name, severity, metric, operator, threshold, window_minutes, observed_value, state, started_at, resolved_at, reminder, is_test.
alert.resolvedThat alert rule stopped firing. Data: alert_event_id, rule_id, rule_name, severity, metric, operator, threshold, window_minutes, observed_value, state, started_at, resolved_at, reminder, is_test.
key.revokedAn API key was revoked: by a member, with all keys at once, when its project was archived or deleted, when the member who created it was removed with their keys, when the organization's deletion was requested, or after a leak report. revoked_by is the member's user id, or null when Panward revoked it. Data: api_key_id, project_id, revoked_by, revoked_at.
policy.publishedA new policy version is live, for a project or for the organization (scope_type). With a second approver, it is sent when the approval publishes the version. Data: policy_version_id, version, scope_type, project_id, published_by.
top_up.creditedA top-up was added to your balance: a card or Link payment succeeded, a USDC deposit settled or what arrived was credited, or the bank transfer for an invoice top-up was matched. credited_nano_usd is what was added, after any network fee. Data: top_up_id, method, credited_nano_usd, status.
budget.reachedSpend this month reached a monthly limit you set: the organization's monthly cap, a project's monthly budget or a key's monthly limit (scope: organization, project or api_key). Sent once a month for each limit, with the usage that reached it; period is the month (YYYY-MM). Data: scope, project_id, api_key_id, period, limit_nano_usd, spend_nano_usd.
member.joinedA person joined the organization: they accepted an invitation, were provisioned by SCIM, or signed in with SSO for the first time (source: invitation, scim or sso_jit). Data: member_id, user_id, role, source.

Event body#

Each delivery is a JSON body with the event's id, its type, the time it was created (created_at), the organization it belongs to, the project it concerns and its data. organization and project are ids; project is null when the event concerns the whole organization (a top-up, a member, an alert, the organization's policy or monthly cap). The id stays the same when an event is delivered again, so it is what you deduplicate on. The same event is never queued twice for one endpoint.

An endpoint limited to projects receives the events of those projects, and the events that concern the whole organization.

The body of a key.revoked event
{
  "id": "evt_01JC7Q4N9W3XK2H8ZP5T6V7B8M",
  "type": "key.revoked",
  "created_at": "2026-11-09T14:28:52.000Z",
  "organization": "org_01JB2M4N6P8R0T2V4X6Z8B0D2F",
  "project": "prj_01JB2M4N6P8R0T2V4X6Z8B0D2G",
  "data": {
    "api_key_id": "key_01JC7PZH4T1A8Q9W3X5Y7Z2B4D",
    "project_id": "prj_01JB2M4N6P8R0T2V4X6Z8B0D2G",
    "revoked_by": "usr_01JB2M4N6P8R0T2V4X6Z8B0D2H",
    "revoked_at": "2026-11-09T14:28:52.000Z"
  }
}

Verify the signature#

Every delivery carries a panward-signature header: t=<unix seconds>,v1=<hex HMAC-SHA-256 of "<t>.<raw body>">. The HMAC key is your endpoint's signing secret.

  1. Read the raw body as bytes, before any JSON parsing. A parsed and re-serialised body does not match.
  2. Take t from the header and refuse the delivery when it is more than 5 minutes from your clock. This stops a captured delivery from being replayed later.
  3. Compute the HMAC-SHA-256 of t, a dot and the raw body, and compare it with each v1 value in constant time. Accept the delivery when one matches.
The signature header during a secret rotation: two v1 values, the new secret's first
panward-signature: t=1790000000,v1=<64 hexadecimal characters>,v1=<64 hexadecimal characters>
import hashlib
import hmac
import json
import os
import time
from http.server import BaseHTTPRequestHandler, HTTPServer

SECRET = os.environ["PANWARD_WEBHOOK_SECRET"].encode()
TOLERANCE_SECONDS = 300
seen = set()  # keep event ids in your database in production


def signature_ok(header, body, now=None):
    parts = header.split(",")
    stamps = [part[2:] for part in parts if part.startswith("t=")]
    if len(stamps) != 1 or not stamps[0].isdigit():
        return False
    if abs((now or time.time()) - int(stamps[0])) > TOLERANCE_SECONDS:
        return False
    expected = hmac.new(SECRET, stamps[0].encode() + b"." + body, hashlib.sha256).hexdigest()
    signatures = [part[3:] for part in parts if part.startswith("v1=")]
    return any(hmac.compare_digest(signature, expected) for signature in signatures)


class Receiver(BaseHTTPRequestHandler):
    def do_POST(self):
        body = self.rfile.read(int(self.headers["Content-Length"]))
        if not signature_ok(self.headers.get("panward-signature", ""), body):
            self.send_response(400)
            self.end_headers()
            return
        event = json.loads(body)
        if event["id"] not in seen:
            seen.add(event["id"])
            print(event["type"])  # hand the work to a queue, then answer
        self.send_response(204)
        self.end_headers()


HTTPServer(("", 8000), Receiver).serve_forever()

Respond#

Answer with a 2xx status quickly and do the work afterwards, for example from a queue. The target is a first attempt within 30 seconds of the event for 99% of deliveries.

Retries and automatic disable#

A delivery that does not get a 2xx answer is tried again after these delays, counted from the failed attempt: nine attempts in all over 23 hours and 21 minutes.

RetryAfter
11 minute
25 minutes
315 minutes
41 hour
52 hours
64 hours
78 hours
88 hours

An endpoint whose deliveries have failed for 3 consecutive days is set to disabled, with the reason in disabled_reason, and the organization's Owners are told by e-mail and in the console.

Duplicates and ordering#

A retry or a redelivery sends the same event again, so your endpoint can receive an event more than once. Keep the ids of the events you handled and skip one you have seen. Do not assume events arrive in the order they happened.

Deliveries#

The endpoint's delivery log lists the deliveries of the last 30 days, newest first, each with the signed event body that was sent, the status code, the duration and the attempt number.

StatusMeaning
pendingQueued, not sent yet.
succeededYour endpoint answered with a 2xx status.
failedThe attempt failed: a status other than 2xx, a timeout or a transport error.
retryingThe attempt failed and another one is scheduled at next_retry_at.
abandonedNot sent again: no attempt was left, or the endpoint was deleted while the delivery was pending.

Redeliver queues a new delivery of the same event, with a new delivery id. Send test delivers a signed webhook.test event at once and shows the result; it waits at most 10 seconds for your answer.

Pause, resume and delete#

StatusMeaning
activeDeliveries are sent.
pausedYou paused the endpoint: nothing is sent until you resume it.
disabledSet automatically after the endpoint kept failing, with a reason in disabled_reason. Resuming it re-enables it.

Deleting an endpoint abandons its pending deliveries, and alert rules that used it lose that channel.

Rotate the secret#

Rotate secret returns a new secret, shown once. For 24 hours after a rotation every delivery is signed with both secrets: the header carries two v1 values, the new secret's first. The end of the overlap is previous_secret_expires_at. Deploy the new secret within that time; a receiver that accepts any matching v1 keeps working throughout.

Use an endpoint as an alert channel#

Turn on alert_channel_enabled to offer the endpoint as a channel of alert rules. A rule that uses it sends alert.firing and alert.resolved to it, signed like every other delivery.

Security notes#

  • Panward sends deliveries only to public addresses: every address your host name resolves to must be public, the connection goes to the address that was checked, and redirects are not followed.
  • Never put a secret in the URL. Check the signature instead.
  • Treat a delivery whose signature does not check out as not sent by Panward, and answer it with a 4xx status.
Was this page helpful?Suggest an edit