Skip to content
ndStill is in development. These docs describe the v2 API as designed; the SDKs and the hosted MCP server are previews and not generally available.
Docs

Webhooks

Signed deliveries (Standard Webhooks), retries, replay and how to verify them.

Webhooks tell your systems what happened without polling: a payment was held, a person approved it, an agent was frozen, a budget crossed its warning line. ndStill signs every delivery following the Standard Webhooks (opens in a new tab) specification, retries for three days, and lets you replay any delivery.

Adding an endpoint#

Create an endpoint in the console (Developers, Webhooks) or with the API:

Terminal
curl -X POST https://api.ndstill.com/v2/webhook-endpoints \
  -H "Authorization: Bearer $NDSTILL_API_KEY" \
  -H "Ndstill-Version: 2026-11-01" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/webhooks/ndstill",
    "description": "Approvals and freezes to the ops channel",
    "events": ["approval.created", "approval.decided", "agent.frozen", "budget.threshold_reached"]
  }'

events takes exact types, families such as payment_intent.*, or "*" for everything. The event catalogue lists them all. Each endpoint has its own signing secret (whsec_…), shown once when it's created and afterwards only after a passkey check, and its own pinned api_version for payload shapes.

What a delivery looks like#

HTTP
POST /webhooks/ndstill HTTP/1.1
Content-Type: application/json
webhook-id: msg_01JD9V2Q7K
webhook-timestamp: 1762178531
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=

{
  "id": "ev_01JD9V2Q7K",
  "object": "event",
  "type": "approval.created",
  "created_at": "2026-11-03T14:02:11Z",
  "data": { "object": { "id": "apr_01JD…", "object": "approval", "status": "pending", "reason_held": "$612.00 is above the $600.00 approval line" } },
  "related": { "object": "payment_intent", "id": "pi_01JD…" }
}
  • webhook-id is unique per event and stays the same across retries: use it to deduplicate.
  • webhook-timestamp is Unix seconds.
  • webhook-signature is a space-separated list of v1,<base64> signatures. During a secret roll it holds two.

Verifying signatures#

The signature is an HMAC-SHA256, keyed with the secret (the part after whsec_, base64-decoded), over {webhook-id}.{webhook-timestamp}.{raw body}. Always verify against the raw request body, before any JSON parsing.

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyNdstill(rawBody: string, headers: Record<string, string>, secret: string): boolean {
  const id = headers["webhook-id"];
  const ts = Number(headers["webhook-timestamp"]);
  if (!id || !ts || Math.abs(Date.now() / 1000 - ts) > 300) return false; // 5-minute tolerance
  const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
  const expected = createHmac("sha256", key).update(`${id}.${ts}.${rawBody}`).digest();
  return headers["webhook-signature"].split(" ").some((part) => {
    const [version, sig] = part.split(",");
    const given = Buffer.from(sig ?? "", "base64");
    return version === "v1" && given.length === expected.length && timingSafeEqual(given, expected);
  });
}

The SDKs wrap this as ndstill.webhooks.verify(rawBody, headers, secret), which also parses the event. Any Standard Webhooks library works too.

Retries and replay#

  • Answer with any 2xx within 15 seconds. Do the work afterwards (queue it); a slow handler looks like a failure.
  • Failed deliveries are retried with exponential backoff for 3 days, then moved to a dead-letter list.
  • Deliveries can arrive out of order and more than once. Use webhook-id to deduplicate, and the object's updated_at or status to ignore stale updates.
  • Replay any delivery, failed or not, with POST/webhook-deliveries/{id}/replay, and send a test ping with POST/webhook-endpoints/{id}/test.

Every delivery, with its status code and latency, is listed under webhook endpoints for 30 days.

Rolling a secret#

POST/webhook-endpoints/{id}/roll-secret starts a new secret. Until previous_secret_expires_at, every delivery is signed with both the old and the new secret, so you can deploy the new one without dropping events. Rolling needs a passkey check.

Events versus polling#

Webhooks are for your servers. Agents usually don't need them: over MCP they get progress notifications for held payments, and the SDK's approvals.wait() waits for a decision. For bulk sync (a data warehouse), list events with a cursor instead: GET /events?after=ev_… returns everything after the last one you saw.