agentleFS
CUSTOM-DOMAIN-APPCUSTOM-DOMAIN-APP/customdomain-mcp/skills/setup-webhooks/SKILL.md

setup-webhooks

Skill1 starsChanged 20 days agoMITView on GitHub

Set up CustomDomain™ webhooks so a product learns when a customer's domain goes live, fails, or drifts. Use when someone asks to receive webhook events, verify a webhook signature, handle retries, register a webhook endpoint, or react to connection.live and connection.failed events.

  • Reads credentials
  • Sends data out

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. thunderphone/skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository9 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use an API key, from an environment variable, never in the browser:

    line 20
  2. Distinctive:

    Never log the secret, the signature header together with the secret, or full request bodies that hold customer data.

    line 126
  3. Distinctive:

    Do not act on an event before the signature check passes.

    line 127

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Set up webhooks

CustomDomain™ sends a signed HTTPS request to your endpoint when a connection changes. Use it instead of polling.

Docs: https://docs.customdomain.ai/docs/webhooks/overview and https://docs.customdomain.ai/docs/webhooks/verifying-signatures

Steps

1. Write the receiver first

The endpoint must be a public https address. localhost and private addresses are refused at registration, so use a tunnel or a deployed preview while developing. See "The receiver" below.

2. Register the endpoint from your server

Use an API key, from an environment variable, never in the browser:

curl -X POST https://api.customdomain.ai/v1/webhooks \
  -H "Authorization: Bearer $CUSTOMDOMAIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://your-app.example/webhooks/customdomain","events":["connection.live","connection.failed"]}'
  • The answer holds id and a secret that starts whsec_. The secret is shown once. The person stores it in their secret store as CUSTOMDOMAIN_WEBHOOK_SECRET. Do not print it in chat or commit it.
  • An empty events list, or "*", subscribes to every event. Subscribe only to events that exist; the catalog is on the overview page.
  • A widget token with the default connect scope cannot register an endpoint. Use the API key.
  • GET /v1/webhooks lists endpoints without secrets. DELETE /v1/webhooks/{id} removes one.
  • A Sandbox (test mode) application has its own endpoints, made with its own key. Register one there to test, and register again on the live application at go live.

3. Verify every delivery

Each request carries three headers:

  • X-JE-Timestamp: unix seconds when it was signed.
  • X-JE-Signature: sha256= and a hex HMAC-SHA256 of the string <timestamp>.<raw body>, keyed by the endpoint's secret.
  • X-JE-Event-Id: the event id, the same on every retry.

Rules:

  • Sign the exact bytes received. Read the raw body before any JSON parsing. Do not re-serialize.
  • Compare in constant time.
  • Reject a timestamp older than your window. Five minutes is the recommended window.
  • Answer a bad signature with 401 and do nothing else.

4. Answer fast, then work

  • Return any 2xx within 15 seconds. Do slow work after you answer, from a queue or job.
  • Network errors, 5xx and 429 are retried with growing delays, up to 12 attempts. Any other 4xx is treated as a permanent failure and is not retried. So return 5xx for a temporary problem on your side, and never return 4xx for one.
  • The same event can arrive more than once. Deduplicate on X-JE-Event-Id (the id in the body). Make the handler safe to run twice.

5. Test

  • Send a test delivery to one endpoint with POST /v1/webhooks/{id}:test. It sends a webhook.test event to that endpoint only.
  • Connect a .test name in the Sandbox. Its events are signed and delivered like real ones and carry "sandbox": true.
  • GET /v1/webhook-deliveries shows recent outcomes (attempts, status_code, delivered, error).

The receiver

Node, using the built in crypto module. This one keeps the body as text so the signature matches.

import crypto from "node:crypto";

export function verify(rawBody, timestamp, signature, secret, toleranceSeconds = 300) {
  const ts = Number.parseInt(timestamp, 10);
  if (!Number.isFinite(ts)) return false;
  if (Math.abs(Date.now() / 1000 - ts) > toleranceSeconds) return false;
  const expected =
    "sha256=" + crypto.createHmac("sha256", secret).update(`${ts}.`).update(rawBody).digest("hex");
  const a = Buffer.from(signature || "");
  const b = Buffer.from(expected);
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

Next.js route handler (app/webhooks/customdomain/route.ts):

import { verify } from "@/lib/customdomain-verify";

export async function POST(req: Request) {
  const raw = await req.text(); // the exact bytes, before any parsing
  const ok = verify(
    raw,
    req.headers.get("x-je-timestamp") ?? "",
    req.headers.get("x-je-signature") ?? "",
    process.env.CUSTOMDOMAIN_WEBHOOK_SECRET!,
  );
  if (!ok) return new Response("bad signature", { status: 401 });

  const event = JSON.parse(raw);
  if (event.sandbox) return new Response("ok"); // skip test mode events where they would touch real data
  // Deduplicate on event.id, then act on event.type.
  return new Response("ok");
}

Express: use express.raw({ type: "application/json" }) on this route only, so the body stays as bytes, and pass req.body to verify.

What an event looks like

A flat JSON object: id, type, user_id, domain, provider, propagation_status, data, created_at, and fields that apply to the event (such as connection_id, error_code and error_message on a failure). Fields that do not apply are left out.

  • user_id is the end_user_ref you passed when the customer connected. Use it to find the customer in your own data. It is missing when none was passed. A value that starts console: comes from the console's own tests, not a customer, so skip it.
  • sandbox: true marks a test mode event. A live event has no such field.

Events most products use

EventUse it to
connection.liveMark the customer's domain as connected.
connection.failedTell the customer the records never appeared, and link them to help.
connection.disconnectedMark the domain removed.
certificate.failed, certificate.expiringWarn about a certificate problem.
domain.record_missing, domain.record_restoredReact to DNS drift, where drift alerts are switched on.

The full list and each payload: https://docs.customdomain.ai/docs/webhooks/overview#event-catalog

Rules

  • Never log the secret, the signature header together with the secret, or full request bodies that hold customer data.
  • Do not act on an event before the signature check passes.
  • Store the secret as an environment variable name in code; the value lives only in the secret store.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.