Developer and creator documentation

Alerts: webhooks, Slack and Discord

Send what happens to your account to your own systems or your team's channels: the events, the body, the signature and a tested verifier.

Sections

Email is not the only way we tell you something happened. An alert can go to a URL of yours, signed so you can prove it came from us, or into a Slack or Discord channel. Developers and creators both use them: a developer hears that a balance is running low before calls start returning 402; a creator hears that an endpoint has started failing before the version is de-listed.

Three kinds of destination #

KindURLWhat it carries
Signed webhookAny public HTTPS URL of yoursA JSON body with the event's exact figures, signed with a secret only you and we hold
SlackA Slack incoming-webhook URL, on hooks.slack.comOne line saying what happened and a link to the app. No amounts
DiscordA Discord webhook URL, on discord.com/api/webhooksThe same line and link. No amounts

Slack and Discord URLs must be on those hosts. A “Slack” URL pointing anywhere else would just be an unsigned webhook, so it is refused.

Setting one up #

  1. In the account app, open Profile, then Alerts (/account/alerts).
  2. Add a destination: choose the kind, give it a label (1 to 60 characters), paste the URL, and tick the events it should receive. You see only the events for the roles your account holds.
  3. For a signed webhook, copy the signing secret now. It starts whsec_ and is shown once, when the destination is created, and never again. If you lose it, delete the destination and add it again.
  4. Press Send a test. A test event is delivered within about fifteen seconds, and the destination then shows whether it arrived.

An account holds at most ten destinations, of any mix of kinds. You can change a destination's events at any time. After you save it, the URL is shown only masked: a Slack or Discord webhook URL is itself the credential that lets anyone post to your channel, so we treat it like the signing secret. Deleting a destination wipes its stored URL and secret and cancels anything still waiting to be delivered to it.

What URL is accepted #

  • HTTPS on port 443, with a certificate a public client trusts. No http://, no other port, no user name or password in the URL, no #fragment.
  • A public address. A host that resolves to a private, loopback or link-local address is refused (refused_address). This is checked when you save, and again at every delivery, so a name that later starts resolving inward is refused then too.
  • Redirects are never followed. A 3xx answer is a failed delivery. Give us the final URL.

The events #

The list is closed: these are every event we send. A new event is added only by a later release, and this page lists it when it is. Each destination receives only the events you ticked for it.

TypeAudienceWhendata fields
balance.lowDeveloperYour balance fell below your low-balance threshold: a tenth of what your last top-up left it at, the same point as the low-balance emailbalance_micro, threshold_micro, currency
key.cap_warningDeveloperA key passed 80% of its spending capkey_name, key_last4, spent_micro, cap_micro, currency
key.cap_reachedDeveloperA key reached its spending capkey_name, key_last4, cap_micro, currency
topup.creditedDeveloperA top-up was credited to your walletamount_micro (what was credited to your balance), currency
endpoint.failingCreatorA tool's endpoint started failingtool, version, consecutive_failures
version.delistedCreatorA tool version was de-listed after repeated failurestool, version, consecutive_failures
withdrawal.paidCreatorA withdrawal was paidwithdrawal_id, amount_micro (before the fee), fee_micro, received_micro, currency
margin.changedCreatorYour platform margin is changingprevious_bps, margin_bps, effective_from
streak.at_riskCreatorYour reliable streak is at risk today: an endpoint is failing callsday, current_days
withdrawal_fee.changedCreatorYour withdrawal fee is changingold_flat_micro, old_bps, new_flat_micro, new_bps, currency, effective_at, direction, reason
milestone.reachedBothYou reached a milestoneaward_id, milestone, name, scope. No amount, even for an earnings milestone
followed.new_toolBothA creator you follow published a new toolcreator, tool, version
followed.new_versionBothA creator you follow released a new versioncreator, tool, version, changelog (at most 200 characters)
followed.retiredBothA creator you follow retired a tool versioncreator, tool, version
testBothYou pressed Send a test. Never subscribablemessage
  • Money is integer micro-USD in a JSON string, always: "1000000" is one dollar. Never parse it as a float. See money is a string. currency is "USD".
  • Counts and basis points are JSON numbers: consecutive_failures, previous_bps and margin_bps (1,000 basis points is 10%). effective_from and created_at are RFC 3339 times in UTC.
  • A key is named by its key_name and the last four characters of the key, key_last4. No event carries a key, a token, a request or response body, a prompt, or anything belonging to another account.

The webhook body #

Each delivery is one POST with Content-Type: application/json and one event: its id, its type, when it happened (created_at) and its data. The examples are indented here; what we send is compact, and the signature covers those exact bytes.

An event body
{
  "id": "evt_3f9c0e0f6a1b4c3d9e8f7a6b5c4d3e2f",
  "type": "balance.low",
  "created_at": "2026-11-17T12:00:00Z",
  "data": {
    "balance_micro": "412000",
    "threshold_micro": "500000",
    "currency": "USD"
  }
}
{
  "id": "evt_0a1b2c3d4e5f60718293a4b5c6d7e8f9",
  "type": "withdrawal.paid",
  "created_at": "2026-11-17T12:00:00Z",
  "data": {
    "withdrawal_id": "wd_...",
    "amount_micro": "25000000",
    "fee_micro": "250000",
    "received_micro": "24750000",
    "currency": "USD"
  }
}

In withdrawal.paid, received_micro is what reached you: amount_micro minus fee_micro, the withdrawal fee. See payouts.

A Slack destination receives {"text": "<what happened>. Open Nexus402: <link>"} and a Discord one {"content": "..."} with the same words, for example: Your balance fell below your low-balance threshold. Open Nexus402: followed by a link to your wallet in the account app. Neither is signed, because Slack and Discord authenticate the URL itself.

The signature #

Every webhook delivery carries three headers:

Webhook headers text
X-Nexus-Event-Id:          evt_...           (the body's id)
X-Nexus-Webhook-Timestamp: <unix seconds>    (when this delivery was signed)
X-Nexus-Webhook-Signature: v1=<lowercase hex HMAC-SHA256>

The signature is an HMAC-SHA256, keyed with your whole signing secret as UTF-8 text, whsec_ prefix included — copy it as shown and decode nothing. It is computed over the timestamp, one full stop, and the raw body:

The signed string text
<X-Nexus-Webhook-Timestamp>.<raw body bytes, exactly as received>
  • Verify the raw bytes, before you parse the JSON. Parsing and re-serialising changes the bytes, and the signature will not match.
  • Compare in constant time: crypto.timingSafeEqual, hmac.compare_digest, subtle.ConstantTimeCompare. An ordinary == returns sooner the earlier it finds a difference, which leaks the expected value to anyone who can time your answers.
  • Refuse everything if your secret is missing. Anyone can sign with an empty secret. These verifiers answer bad_secret, before reading the delivery, unless the secret starts with whsec_ and has something after it. That means your setup needs fixing, not the delivery.
  • Check the v1= prefix. It names the scheme, so a later one can be added beside it without being mistaken for this one.

Replay protection: 300 seconds either side #

Refuse a delivery whose timestamp is more than 300 seconds from your clock, in both directions. Without a lower bound a captured delivery can be replayed at you forever; without an upper one a future-dated one is valid forever. The timestamp is inside the signed string, so it cannot be changed without breaking the signature. Keep your server's clock synchronised; five minutes is room for ordinary drift, not for a clock that is wrong.

A retry is signed afresh, with a new timestamp, so a delivery we retry an hour later still verifies.

A complete verifier #

One function per language that takes your secret, the raw body and the two header values, and returns whether the delivery is ours and recent, or the reason it is not. Standard library only in each.

examples/webhooks
// A Nexus402 alert-webhook verifier for Node.js. NO DEPENDENCIES.
//
// Copy this file. It is not a package to import, so it can never version-skew
// against the platform. `examples/webhooks/webhooks_test.go` signs real bodies
// with the platform's own signer (`internal/alerts.Sign`) and refuses to pass
// unless this code accepts the genuine signature and refuses every tampered
// one, so what you copy is what our tests run.
//
// Every delivery carries three headers:
//   X-Nexus-Event-Id           the event id, also the body's `id`
//   X-Nexus-Webhook-Timestamp  Unix seconds when the delivery was signed
//   X-Nexus-Webhook-Signature  v1=<lowercase hex HMAC-SHA256>
//
// The signed string is `<timestamp>.<raw body>`, and the HMAC key is your
// whole signing secret as UTF-8, `whsec_` prefix included.

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

/**
 * How far either side of your clock a timestamp may be: 300 seconds.
 * Narrower rejects honest deliveries on ordinary clock skew; wider accepts
 * older replays of a captured delivery.
 */
export const TOLERANCE_SECONDS = 300;

const SIGNATURE_PREFIX = "v1=";
// Every signing secret starts with this.
const SECRET_PREFIX = "whsec_";

/**
 * Verify one delivery. Call it with the RAW body bytes, before any JSON
 * parse: re-serialising changes the bytes and the signature will not match.
 *
 * @param {object} input
 * @param {string} input.secret           your destination's signing secret, `whsec_...`
 * @param {Buffer|Uint8Array} input.rawBody the request body exactly as received
 * @param {string|undefined} input.timestamp the X-Nexus-Webhook-Timestamp header
 * @param {string|undefined} input.signature the X-Nexus-Webhook-Signature header
 * @param {number} [input.nowUnixSeconds]  defaults to your clock
 * @returns {{ ok: boolean, reason: string }}
 */
export function verifyWebhook({ secret, rawBody, timestamp, signature, nowUnixSeconds = Math.floor(Date.now() / 1000) }) {
  // First: anyone can sign with an empty secret, so a missing one must
  // refuse every delivery. This is a mistake in YOUR setup, not in the
  // delivery: check that your signing secret is set.
  if (typeof secret !== "string" || !secret.startsWith(SECRET_PREFIX) || secret.length === SECRET_PREFIX.length) {
    return { ok: false, reason: "bad_secret" };
  }
  // Digits only: a sign, a space or an exponent is not a timestamp we sent.
  if (typeof timestamp !== "string" || !/^[0-9]{1,15}$/.test(timestamp)) {
    return { ok: false, reason: "bad_timestamp" };
  }
  // Both directions: without an upper bound a future-dated delivery is valid
  // forever; without a lower one a captured delivery replays forever.
  if (Math.abs(nowUnixSeconds - Number(timestamp)) > TOLERANCE_SECONDS) {
    return { ok: false, reason: "timestamp_out_of_tolerance" };
  }
  if (typeof signature !== "string" || !signature.startsWith(SIGNATURE_PREFIX)) {
    return { ok: false, reason: "bad_signature_format" };
  }
  const expected = createHmac("sha256", Buffer.from(secret, "utf8"))
    .update(`${timestamp}.`, "utf8")
    .update(rawBody)
    .digest("hex");
  const presented = Buffer.from(signature.slice(SIGNATURE_PREFIX.length), "utf8");
  // timingSafeEqual throws on a length mismatch. The length of a SHA-256 hex
  // digest is public (64), so checking it first leaks nothing secret.
  const want = Buffer.from(expected, "utf8");
  if (presented.length !== want.length || !timingSafeEqual(presented, want)) {
    return { ok: false, reason: "signature_mismatch" };
  }
  return { ok: true, reason: "" };
}

// Using it, with node:http. Read the body as bytes, verify, THEN parse:
//
//   const chunks = [];
//   for await (const chunk of req) chunks.push(chunk);
//   const rawBody = Buffer.concat(chunks);
//   const verdict = verifyWebhook({
//     secret: process.env.NEXUS_WEBHOOK_SECRET,
//     rawBody,
//     timestamp: req.headers["x-nexus-webhook-timestamp"],
//     signature: req.headers["x-nexus-webhook-signature"],
//   });
//   if (!verdict.ok) { res.writeHead(400).end(); return; }
//   const event = JSON.parse(rawBody.toString("utf8"));
//   // Delivery is at least once: drop an event.id you have already handled.
//   res.writeHead(204).end();
"""A Nexus402 alert-webhook verifier for Python. STANDARD LIBRARY ONLY.

Copy this file. `examples/webhooks/webhooks_test.go` signs real bodies with
the platform's own signer (`internal/alerts.Sign`) and refuses to pass unless
this code accepts the genuine signature and refuses every tampered one, so
what you copy is what our tests run.

Every delivery carries three headers:
  X-Nexus-Event-Id           the event id, also the body's `id`
  X-Nexus-Webhook-Timestamp  Unix seconds when the delivery was signed
  X-Nexus-Webhook-Signature  v1=<lowercase hex HMAC-SHA256>

The signed string is `<timestamp>.<raw body>`, and the HMAC key is your whole
signing secret as UTF-8, `whsec_` prefix included.
"""

from __future__ import annotations

import hashlib
import hmac
import re
import time

# How far either side of your clock a timestamp may be: 300 seconds. Narrower
# rejects honest deliveries on ordinary clock skew; wider accepts older
# replays of a captured delivery.
TOLERANCE_SECONDS = 300

_SIGNATURE_PREFIX = "v1="
# Every signing secret starts with this.
_SECRET_PREFIX = "whsec_"
# ASCII digits only. `str.isdigit` would accept other scripts' digits, and a
# sign, a space or an exponent is not a timestamp we sent.
_TIMESTAMP = re.compile(r"[0-9]{1,15}")


def verify_webhook(
    secret: str | None,
    raw_body: bytes,
    timestamp: str | None,
    signature: str | None,
    now: int | None = None,
) -> tuple[bool, str]:
    """Verify one delivery; returns (ok, reason).

    Call it with the RAW body bytes, before any JSON parse: re-serialising
    changes the bytes and the signature will not match.
    """
    # First: anyone can sign with an empty secret, so a missing one must
    # refuse every delivery. This is a mistake in YOUR setup, not in the
    # delivery: check that your signing secret is set.
    if not secret or not secret.startswith(_SECRET_PREFIX) or secret == _SECRET_PREFIX:
        return False, "bad_secret"
    if now is None:
        now = int(time.time())
    if timestamp is None or _TIMESTAMP.fullmatch(timestamp) is None:
        return False, "bad_timestamp"
    # Both directions: without an upper bound a future-dated delivery is
    # valid forever; without a lower one a captured delivery replays forever.
    if abs(now - int(timestamp)) > TOLERANCE_SECONDS:
        return False, "timestamp_out_of_tolerance"
    if signature is None or not signature.startswith(_SIGNATURE_PREFIX):
        return False, "bad_signature_format"
    expected = hmac.new(
        secret.encode("utf-8"),
        timestamp.encode("ascii") + b"." + raw_body,
        hashlib.sha256,
    ).hexdigest()
    presented = signature[len(_SIGNATURE_PREFIX):]
    # Bytes, not str: compare_digest refuses a str holding non-ASCII text.
    if not hmac.compare_digest(expected.encode("ascii"), presented.encode("utf-8")):
        return False, "signature_mismatch"
    return True, ""


# Using it, with any framework that gives you the body as bytes. Verify,
# THEN parse:
#
#   ok, reason = verify_webhook(
#       os.environ["NEXUS_WEBHOOK_SECRET"],
#       request.body,  # bytes, exactly as received
#       request.headers.get("X-Nexus-Webhook-Timestamp"),
#       request.headers.get("X-Nexus-Webhook-Signature"),
#   )
#   if not ok:
#       return 400
#   event = json.loads(request.body)
#   # Delivery is at least once: drop an event["id"] you have already handled.
#   return 204
// Package webhook verifies Nexus402 alert webhooks. STANDARD LIBRARY ONLY.
//
// Copy this file into your own package. `examples/webhooks/webhooks_test.go`
// signs real bodies with the platform's own signer (`internal/alerts.Sign`)
// and refuses to pass unless this code accepts the genuine signature and
// refuses every tampered one, so what you copy is what our tests run.
//
// Every delivery carries three headers:
//
//	X-Nexus-Event-Id           the event id, also the body's `id`
//	X-Nexus-Webhook-Timestamp  Unix seconds when the delivery was signed
//	X-Nexus-Webhook-Signature  v1=<lowercase hex HMAC-SHA256>
//
// The signed string is `<timestamp>.<raw body>`, and the HMAC key is your
// whole signing secret as UTF-8, `whsec_` prefix included.
//
// Using it in a handler. Read the body as bytes, verify, THEN parse:
//
//	raw, err := io.ReadAll(io.LimitReader(r.Body, 64<<10))
//	if err != nil { http.Error(w, "", http.StatusBadRequest); return }
//	if err := webhook.Verify(secret, raw,
//		r.Header.Get("X-Nexus-Webhook-Timestamp"),
//		r.Header.Get("X-Nexus-Webhook-Signature"), time.Now()); err != nil {
//		http.Error(w, "", http.StatusBadRequest)
//		return
//	}
//	// json.Unmarshal(raw, &event). Delivery is at least once:
//	// drop an event.ID you have already handled.
//	w.WriteHeader(http.StatusNoContent)
package webhook

import (
	"crypto/hmac"
	"crypto/sha256"
	"crypto/subtle"
	"encoding/hex"
	"errors"
	"strconv"
	"strings"
	"time"
)

// ToleranceSeconds is how far either side of your clock a timestamp may be.
// Narrower rejects honest deliveries on ordinary clock skew; wider accepts
// older replays of a captured delivery.
const ToleranceSeconds = 300

const signaturePrefix = "v1="

// Every signing secret starts with this.
const secretPrefix = "whsec_"

// The reasons a delivery is refused. Each error's text is the same reason
// code the Node and Python verifiers return.
var (
	// ErrBadSecret is a mistake in YOUR setup, not in the delivery: check
	// that your signing secret is set.
	ErrBadSecret          = errors.New("bad_secret")
	ErrBadTimestamp       = errors.New("bad_timestamp")
	ErrOutOfTolerance     = errors.New("timestamp_out_of_tolerance")
	ErrBadSignatureFormat = errors.New("bad_signature_format")
	ErrSignatureMismatch  = errors.New("signature_mismatch")
)

// Verify checks one delivery against the destination's signing secret. Pass
// the RAW body bytes, before any JSON parse: re-serialising changes the bytes
// and the signature will not match. A nil error means the delivery is ours
// and recent.
func Verify(secret string, rawBody []byte, timestamp, signature string, now time.Time) error {
	// First: anyone can sign with an empty secret, so a missing one must
	// refuse every delivery.
	if rest, ok := strings.CutPrefix(secret, secretPrefix); !ok || rest == "" {
		return ErrBadSecret
	}
	// Digits only: strconv.ParseInt alone would accept a leading sign.
	if timestamp == "" || len(timestamp) > 15 || strings.Trim(timestamp, "0123456789") != "" {
		return ErrBadTimestamp
	}
	seconds, err := strconv.ParseInt(timestamp, 10, 64)
	if err != nil {
		return ErrBadTimestamp
	}
	// Both directions: without an upper bound a future-dated delivery is
	// valid forever; without a lower one a captured delivery replays forever.
	if skew := now.Unix() - seconds; skew > ToleranceSeconds || skew < -ToleranceSeconds {
		return ErrOutOfTolerance
	}
	presented, ok := strings.CutPrefix(signature, signaturePrefix)
	if !ok {
		return ErrBadSignatureFormat
	}
	mac := hmac.New(sha256.New, []byte(secret))
	mac.Write([]byte(timestamp + "."))
	mac.Write(rawBody)
	expected := hex.EncodeToString(mac.Sum(nil))
	if subtle.ConstantTimeCompare([]byte(expected), []byte(presented)) != 1 {
		return ErrSignatureMismatch
	}
	return nil
}

Delivery, retries and duplicates #

  • Answer 2xx within 10 seconds. Any 2xx is success, and the body of your answer is ignored (we read at most 4 KiB of it). Anything else — another status, a redirect, a timeout, a refused connection, a failed TLS handshake — is a failed attempt. If you have slow work to do, answer first and do it afterwards.
  • Failed attempts are retried with backoff for 24 hours. After that the event counts as failed for that destination.
  • Delivery is at least once. A delivery that reached you but whose answer we never saw is sent again, so you can receive the same event twice. Remember the event id (also in X-Nexus-Event-Id) and drop one you have already handled.
  • Do not depend on order. A retried event can arrive after a newer one. Use created_at if order matters to you.
  • An alert reports something that has already happened. It never holds up a call, a top-up or a payout, and a failed delivery never undoes one.

When a destination is paused #

After 20 consecutive failed events — each one already retried for 24 hours — we pause the destination. It stops receiving, we email the account, and the app shows it as paused. Fix whatever is wrong, then press Resume on the destination: that clears the pause and its count of failed events. A paused destination cannot send a test until it is resumed. One delivered event resets the count to zero, so only an unbroken run of failures pauses a destination.

The app shows each destination's last success, last failure and its reason, and the status code where there was one:

ReasonWhat happened
http_statusYour URL answered with a status that is not 2xx, a redirect included. The status code is shown beside it
timeoutNo answer within 10 seconds
connectThe connection could not be made
tlsThe TLS handshake failed, usually a certificate a public client does not trust
refused_addressThe host resolved to a private, loopback or link-local address, so we did not connect
invalid_urlThe stored URL no longer passes the rules above
unsealedWe could not read the destination's stored URL or secret. This one is ours, not yours; if it persists, delete the destination and add it again

What we do to keep this safe #

  • Your secrets are encrypted at rest: the signing secret and the Slack and Discord URLs. They are never written to a log, and our own operators see only a destination's host, never its URL.
  • Every delivery goes through the same guard as calls to creators' endpoints: the address is resolved and checked on every connection, so a name cannot be pointed at our internal network after you save it.
  • Deliveries come from our background worker, never from the gateway that serves paid calls, so a slow or failing webhook never slows a tool call.

Install agent tools

Help your coding agent stay on track when building with Nexus402. Learn more

Paste this into Claude Code, Codex or Cursor. Your agent connects itself to Nexus402 and adds the skills, for whichever tool it is.

Prompt for your agent text
Set up Nexus402 for me in this coding agent.
1. Read https://www.nexus402.dev/docs/agents.md and work out which tool you are (Claude Code, Codex or Cursor).
2. Add the Nexus402 MCP server https://api.nexus402.dev/v1/mcp the way that page shows for your tool, sending the X-Nexus-Api-Key header from the NEXUS402_API_KEY environment variable.
3. Install the skills listed at https://www.nexus402.dev/.well-known/skills/index.json where your tool keeps skills or rules.
Never write my key into a file, a commit or a reply. If NEXUS402_API_KEY is not set, stop and tell me to set it.
Then check the connection lists tools, and tell me what you changed.

Connect the gateway, then add the two skills.

Terminal bash
claude mcp add --transport http --scope user nexus402 https://api.nexus402.dev/v1/mcp \
  --header "X-Nexus-Api-Key: $NEXUS402_API_KEY"

mkdir -p ~/.claude/skills/nexus402-tools && curl -fsSL https://www.nexus402.dev/.well-known/skills/nexus402-tools/SKILL.md -o ~/.claude/skills/nexus402-tools/SKILL.md
mkdir -p ~/.claude/skills/nexus402-endpoint && curl -fsSL https://www.nexus402.dev/.well-known/skills/nexus402-endpoint/SKILL.md -o ~/.claude/skills/nexus402-endpoint/SKILL.md

Add the gateway to ~/.codex/config.toml, then add the skills with npx skills add https://www.nexus402.dev.

~/.codex/config.toml toml
[mcp_servers.nexus402]
url = "https://api.nexus402.dev/v1/mcp"
env_http_headers = { "X-Nexus-Api-Key" = "NEXUS402_API_KEY" }
tool_timeout_sec = 130
Add to Cursor

Opens Cursor and asks to add the gateway. Your key is read from NEXUS402_API_KEY.

Or add it by hand to ~/.cursor/mcp.json. Then add the skills with npx skills add https://www.nexus402.dev.

~/.cursor/mcp.json json
{
  "mcpServers": {
    "nexus402": {
      "url": "https://api.nexus402.dev/v1/mcp",
      "headers": {
        "X-Nexus-Api-Key": "${env:NEXUS402_API_KEY}"
      }
    }
  }
}

Skills-only installs don't update automatically.

Terminal bash
npx skills add https://www.nexus402.dev

Every option reads your key from NEXUS402_API_KEY; none writes it into a file. Learn more