Skip to content

Webhooks

Audience: Engineers wiring Nanorix events into their existing systems — alerting, ticket queues, audit pipelines, compliance-automation platforms (Vanta, Drata). Time to read: 8 minutes. Prerequisites: A Nanorix API key and an HTTPS endpoint capable of receiving POST requests.

Nanorix posts a JSON event to your endpoint whenever something happens that you've subscribed to: a capsule is destroyed, an AuditProof is emitted, a destroyed capsule had requests refused by its egress policy, an API key is created or revoked. Each request is HMAC-SHA256 signed with your endpoint's secret so you can verify the payload originated from Nanorix and was not modified in transit.


Event-type catalog

Event Fires when Typical use
capsule.created A capsule is created Inventory; concurrent-capsule monitoring
capsule.executed Not currently emitted n/a
capsule.destroyed A capsule is destroyed (success or timeout) Lifecycle telemetry
capsule.destroyed_no_proof Not currently emitted n/a
capsule.destroyed_via_console Not currently emitted n/a
capsule.signing_failed Not currently emitted n/a
capsule.failed Capsule destruction does not complete: a destruction chain step fails and the capsule is left in an incomplete-destruction state. capsule.destroyed, cdp.generated and audit_proof.emitted are not sent for that capsule Alerting
capsule.timeout A capsule hits max_lifetime_seconds TTL-tuning signal
capsule.expiring A capsule is approaching its TTL ceiling (warning) Proactive cleanup
cdp.generated An AuditProof is generated at capsule destroy Storage pipelines (S3 Object Lock, etc.)
cdp.verified A stateless verify call answers valid: true for one of your AuditProofs: its signing key resolved against the published trust chain. A verdict that is integrity only does not send it, and the payload carries no caller IP address Compliance-automation triggers
audit_proof.emitted Customer-facing-brand alias for cdp.generated (fires alongside) Vanta / Drata / SIEM platforms
egress.blocked A capsule's requests were refused by its egress allowlist or other policy checks. Reported once, after the capsule's destroy completes and its AuditProof is signed and stored on the first attempt; not reported when the AuditProof is finished through retry-signing, or when destruction does not complete Anomaly detection; drift alerting
egress.rule_changed A rule is added to or removed from an egress profile through /v1/egress/profiles/{id}/rules. Rules added or removed through the older POST /v1/egress and DELETE /v1/egress/{id} endpoints, and profile create, update or delete, do not fire it Change-log input
usage.threshold Tier quota crosses a threshold (50%, 75%, 90%); sent only where billing tiers apply, never on an install with billing off Cost monitoring
key.created A new API key is created Key-rotation pipelines
key.revoked An API key is revoked Key-rotation pipelines
key.dot Not currently emitted n/a
capsulefile.created A new draft Capsulefile is created Build-system telemetry
capsulefile.finalized Not currently emitted (finalizing a draft fires capsulefile.updated) n/a
capsulefile.updated A draft Capsulefile is finalized and becomes immutable. Not sent when the draft's content matches a Capsulefile already finalized: the draft is discarded, without a capsulefile.deleted event, and the existing Capsulefile is returned Audit
capsulefile.deleted A Capsulefile is deleted Cleanup audit

You subscribe to a specific subset of events, or pass ["*"] to subscribe to all current and future events. The rows marked "Not currently emitted" cannot be subscribed to: a create or update request whose events list names one is refused with HTTP 400. Forever-Standard discipline: existing event types are permanent; new events arrive as additive entries to this catalog.

A webhook event is a notification, not a record. It is not part of any AuditProof, and a missing event does not show that a destruction completed or that it failed. The AuditProof is the record.


Registering an endpoint

import os

from nanorix import Client

client = Client(api_key=os.environ["NANORIX_API_KEY"])

endpoint = client.webhooks.create(
    url="https://hooks.your-org.com/nanorix",
    events=[
        "capsule.destroyed",
        "audit_proof.emitted",
        "egress.blocked",
    ],
    description="Production audit pipeline",
)

# Save endpoint["secret"] securely — it is shown ONCE on create.
print(endpoint["id"], endpoint["secret"])
import { NanorixClient } from "@nanorix/sdk";

const client = new NanorixClient({ apiKey: process.env.NANORIX_API_KEY! });

const endpoint = await client.webhooks.create({
  url: "https://hooks.your-org.com/nanorix",
  events: ["capsule.destroyed", "audit_proof.emitted", "egress.blocked"],
  description: "Production audit pipeline",
});

// endpoint.secret is shown ONCE
console.log(endpoint.id, endpoint.secret);
curl -X POST https://api.nanorix.io/v1/webhooks \
  -H "Authorization: Bearer nrx_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://hooks.your-org.com/nanorix",
    "events": ["capsule.destroyed", "audit_proof.emitted"],
    "description": "Production audit pipeline"
  }'

The response includes a secret that is shown exactly once — store it securely (your KMS, your secret manager, an env var sourced from a sealed store). Nanorix retains only a hash for the lifetime of the endpoint.

The webhook URL must use HTTPS. Loopback, link-local and cloud metadata addresses (and localhost) are always refused, and private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, fc00::/7, fec0::/10) are refused unless the install sets the private-network switch (NANORIX_EGRESS_ALLOW_PRIVATE=true, the Helm value egress.allowPrivateDestinations). The same rule applies when an event is sent: a name that resolves to a refused address is refused, and the delivery fails.

Proxies and private endpoints (self-hosted installs). Webhook, per-event signer and OIDC identity-provider requests do not use the environment proxy (HTTPS_PROXY and similar are ignored). A receiver, signer or identity provider on a private address needs NANORIX_EGRESS_ALLOW_PRIVATE=true on the install; that setting also opens capsule egress to private ranges.


Receiving an event

Every request includes:

Header Meaning
X-Nanorix-Signature HMAC-SHA256 signature of <timestamp>.<body> using your endpoint secret, prefixed sha256=
X-Nanorix-Timestamp Unix seconds; reject if outside a 5-minute window to prevent replay
X-Nanorix-Event The event type, e.g. capsule.destroyed
X-Nanorix-Delivery-Id Unique per delivery; use for idempotency in your handler
Content-Type application/json

Body shape:

{
  "id": "whd_k3Jf9aQ2xLmP",
  "event": "capsule.destroyed",
  "created_at": "2026-05-08T14:00:00.123456789+00:00",
  "data": {
    "capsule_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "capsulefile_id": null,
    "data_classification": "general",
    "duration_seconds": 4,
    "trigger": "user_explicit"
  }
}

The data object is event-specific. The shape is stable per Forever-Standard discipline — fields are additive, never removed or renamed.


HMAC signature verification

The signature header value is sha256=<hex>, computed over the message <timestamp>.<body>. Verify in constant time and reject on any failure or stale timestamp.

Python

import hashlib
import hmac
import time

def verify_webhook(payload: bytes, signature: str, secret: str, timestamp: int) -> bool:
    """Verify a Nanorix webhook signature."""
    if not signature.startswith("sha256="):
        return False

    # 5-minute replay window
    now = int(time.time())
    if abs(now - timestamp) > 300:
        return False

    expected = signature[len("sha256="):]
    message = f"{timestamp}.{payload.decode('utf-8')}"
    computed = hmac.new(
        secret.encode("utf-8"),
        message.encode("utf-8"),
        hashlib.sha256,
    ).hexdigest()
    return hmac.compare_digest(computed, expected)

The Python SDK ships this helper as Webhook.verify_signature(...):

from nanorix.resources.webhooks import Webhook
from flask import request, abort

@app.route("/nanorix", methods=["POST"])
def receive():
    signature = request.headers["X-Nanorix-Signature"]
    timestamp = int(request.headers["X-Nanorix-Timestamp"])
    if not Webhook.verify_signature(request.data, signature, MY_SECRET, timestamp):
        abort(401)
    handle(request.json)
    return "", 200

TypeScript

import { createHmac, timingSafeEqual } from "crypto";

function verifyWebhook(
  payload: Buffer,
  signature: string,
  secret: string,
  timestamp: number,
): boolean {
  if (!signature.startsWith("sha256=")) return false;

  const now = Math.floor(Date.now() / 1000);
  if (Math.abs(now - timestamp) > 300) return false;

  const expected = signature.slice("sha256=".length);
  const message = `${timestamp}.${payload.toString("utf-8")}`;
  const computed = createHmac("sha256", secret).update(message).digest("hex");

  const a = Buffer.from(computed, "hex");
  const b = Buffer.from(expected, "hex");
  if (a.length !== b.length) return false;
  return timingSafeEqual(a, b);
}

The TypeScript SDK ships this helper as a static on the Webhooks resource class: Webhooks.verifySignature(...), with the same shape.

curl (one-off verification)

TIMESTAMP=1715173200
# BODY must be the raw request body exactly as received, byte for byte
BODY='{"created_at":"...","data":{...},"event":"capsule.destroyed","id":"whd_..."}'
SECRET="whsec_..."

EXPECTED=$(printf '%s.%s' "$TIMESTAMP" "$BODY" | \
  openssl dgst -sha256 -hmac "$SECRET" -hex | \
  awk '{print $2}')

# Compare against X-Nanorix-Signature stripped of "sha256=" prefix
echo "sha256=$EXPECTED"

Retry policy

If your endpoint returns any status outside 200 through 299, the request fails (for example the connection is refused or TLS fails), or the response does not complete within 10 seconds, Nanorix sends the event again on a fixed schedule. Each delivery gets five attempts in total:

Attempt Sent after the prior attempt
1 (original) n/a
2 about 5 seconds
3 about 5 minutes
4 about 30 minutes
5 about 2 hours

Retries are sent by a background task that runs every 30 seconds, so each delay usually runs up to 30 seconds longer, plus up to 10 seconds for a slow request. From the first attempt to the last takes about 2 hours 35 minutes. If the fifth attempt also fails, the delivery moves to the dead-letter queue: GET /v1/webhooks/dlq lists dead-lettered deliveries and POST /v1/webhooks/dlq/{id}/replay sends one again.

A 2xx response (any status from 200 through 299) counts as success. Every other status, 410 Gone included, counts as a failure and is retried on the same schedule. Nanorix does not follow redirects: a 3xx response (301, 302, 307, 308 and the rest) counts as a failure, so register the final URL.

Automatic disable. Each endpoint counts its consecutive failed attempts, across all events, in consecutive_failures (returned by GET /v1/webhooks and GET /v1/webhooks/{id}). Any 2xx response sets the count back to 0. When it reaches 10, the endpoint is turned off (active: false): new events are no longer sent to it, and a delivery still waiting for a retry moves to the dead-letter queue when that retry comes due. Turn it back on with PUT /v1/webhooks/{id} and "active": true. Turning it back on does not reset the count, so until one delivery succeeds, a single failure turns it off again.


Idempotency expectations

Your endpoint MUST be idempotent. Nanorix may deliver the same event more than once under several conditions:

  • Network failure between Nanorix and your endpoint (Nanorix retries; your endpoint may have processed the original)
  • Your endpoint returned 5xx but actually processed the event
  • A dead-letter replay you request

Use the X-Nanorix-Delivery-Id header (or the body's id field) as the idempotency key. Common patterns:

# Postgres-backed dedup
def handle(event_id: str, body: dict):
    inserted = db.execute(
        "INSERT INTO processed_events (event_id) VALUES (%s) "
        "ON CONFLICT (event_id) DO NOTHING RETURNING event_id",
        (event_id,),
    ).fetchone()
    if not inserted:
        return  # duplicate; already processed
    process(body)
// Redis-backed dedup with 30-day TTL
async function handle(eventId: string, body: object) {
  const ok = await redis.set(`evt:${eventId}`, "1", "NX", "EX", 30 * 86400);
  if (ok !== "OK") return; // duplicate
  await process(body);
}

Listing, updating, deleting endpoints

# List all endpoints
client.webhooks.list()

# Get one
client.webhooks.get("wh_...")

# Update (rotate URL, change subscriptions, enable/disable)
client.webhooks.update(
    "wh_...",
    url="https://hooks.your-org.com/nanorix-v2",
    events=["capsule.destroyed", "audit_proof.emitted"],
    active=True,
)

# Delete
client.webhooks.delete("wh_...")

Update operations DO NOT rotate the secret. Rotate the signing secret in place with POST /v1/webhooks/{id}/rotate-secret, then update your handler with the new secret.


Troubleshooting

Signature mismatch

Symptom: verify_webhook returns False; HTTP 401 from your handler.

Likely causes: 1. The body bytes you're hashing have been re-serialized. Frameworks that parse the JSON before passing to your handler often change byte-level representation. Always hash the raw request body bytes, not a re-serialized form. 2. The secret in your handler is from a different endpoint or has been mutated (a stray newline, encoding change). Verify the secret matches what the endpoint create response returned. 3. The timestamp you supplied differs from X-Nanorix-Timestamp. The signature is over <timestamp>.<body> — using the wrong timestamp produces the wrong signature.

Replay rejection

Symptom: signature is correct but abs(now - timestamp) > 300 returns true and your handler rejects.

Likely causes: 1. Your server's clock has drifted. Run NTP. 2. The webhook was sitting in a queue (yours or an upstream proxy) for >5 minutes. Either widen your replay window (with caution) or fix the queue lag.

5xx loop

Symptom: Nanorix retries the same event multiple times and your endpoint keeps returning 5xx.

Likely causes: 1. Your handler raises on a malformed payload it doesn't recognize. Treat unknown event types as success (return 2xx) and log them; new events arrive over time per Forever-Standard discipline. 2. Your downstream system (database, queue) is degraded. Returning 5xx is correct here — Nanorix's retry schedule gives your system time to recover. After five attempts over about 2 hours 35 minutes, the delivery lands in the dead-letter queue.

DLQ recovery

If deliveries have landed in the dead-letter queue, list them with GET /v1/webhooks/dlq. If the endpoint was turned off, turn it back on first with PUT /v1/webhooks/{id} and "active": true: a replay to an endpoint that is off goes straight back to the dead-letter queue. Then replay each delivery with POST /v1/webhooks/dlq/{id}/replay, which gives it a fresh set of five attempts.


What webhooks are not

Webhooks are not the primary distribution channel for AuditProofs. Use client.audit_proofs.get(capsule_id) to retrieve the full proof for storage; the cdp.generated / audit_proof.emitted event carries identifiers and metadata, not the full proof body.

Webhooks are not for low-latency synchronous control. They fire asynchronously after the underlying event commits. If your application logic depends on synchronous knowledge of capsule state, poll GET /v1/capsules/<id> or rely on the SDK's capsule.run() blocking call.


  • API reference — full endpoint reference
  • Error catalog — error codes referenced in webhook delivery failures
  • AuditProof storage operational guide — pairs with cdp.generated for storage pipelines