Skip to content

Registrar API ​

POST /register ​

Claim a clientId, with proof that you hold the npub's key (two phases, as /update). The first signed claim wins; the same npub can add more domains. The domain and the signer origin (SIGNER_ORIGIN, default https://signer.shardsigner.com) must be in the clientId's Web3Auth Allowlist URLs; /update checks every domain the same way.

  • Web3Auth's settings unreadable: /register and /update answer 503 ("try again later"); sites already registered keep working. Emergency switch for the operator: the Worker variable ALLOW_UNCHECKED = "true" accepts them without that check, with a note saying so.
  • Registrants named by the project owner: an allowlist entry https://<npub>.nostr-registrant.invalid names that npub. Only the project owner can edit the allowlist, so such an npub may claim the clientId even over another npub's claim; once a project lists any, only those npubs can claim it.
jsonc
// Phase 1
{ "clientId": "string", "npub": "npub1...", "domain": "https://app.example.com" }
// → 200 { "ok": true, "nonce": "<64 hex>", "expiresIn": 300 }

// Phase 2: the same, plus
{ "nonce": "<nonce>", "signedEvent": { /* kind 27235, content = nonce, signed by the npub */ } }

// 201 Created (200 when the registrant adds a domain)
{ "ok": true, "event": "<nostr_event_id>", "published": 3, "total": 3 }

// 403 — domain or signer origin missing from the Web3Auth allowlist
{ "error": "Add https://app.example.com to this clientId's Allowlist URLs in the Web3Auth dashboard (Project Settings → Domains), then retry." }

// 404 — no Web3Auth Sapphire Mainnet project with this clientId
{ "error": "Web3Auth has no Sapphire Mainnet project with this clientId. ..." }

// 403 — signed by another key; or the project owner named other registrants
// 409 Conflict — already claimed by another npub (the error explains the registrant marker)
// 503 — Web3Auth's settings can't be read right now

POST /update (two-phase) ​

Phase 1 — request a nonce (omit nonce and signedEvent):

jsonc
// Request
{ "clientId": "string", "npub": "npub1..." }

// Response
{ "ok": true, "nonce": "<64 hex chars>", "expiresIn": 300 }

Phase 2 — submit the update with proof:

jsonc
// Request
{
  "clientId":   "string",
  "nonce":      "<64 hex chars from Phase 1>",
  "domains":    ["https://app.example.com"],
  "signedEvent": { /* signed NIP-01 kind:27235 event with content = nonce */ }
}

// Response
{ "ok": true, "event": "<nostr_event_id>", "domains": [...], "published": 3, "total": 3 }

Nonces are stored with a 5-minute TTL and consumed on first use.


Registry sync, GET /health and POST /sync ​

Relays don't sync with each other and can lose data, so the registrar keeps every registry event it publishes in REGISTRY_KV as well. A daily cron ([triggers] in wrangler.toml) reads all relays in RELAY_URLS, keeps the newest event per clientId, stores any event missing from KV, and re-sends the signed event to every relay that lacks it. Adding a relay to RELAY_URLS therefore fills it on the next run.

GET /health returns the last run's report:

jsonc
{
  "status": "ok",                 // "degraded": a registration is on fewer than 3 relays, or under half the relays are reachable
  "checkedAt": "2026-09-25T07:44:43.716Z",
  "registrations": 5,
  "kvBackfilled": 0,              // events found on relays but not yet in KV
  "relaysReachable": "5/5",
  "relays": [{ "url": "wss://nos.lol", "reachable": true, "missing": 2, "repaired": 2 }],
                                  // "rejected": ["<relay's reason>"] when a relay refused a re-send,
                                  // "dropped": n when it answered OK but doesn't return the event
  "underReplicated": []           // [{ clientId, copies }]
}

POST /sync runs the sync immediately (at most once every 5 minutes) and returns the same report. Neither endpoint needs auth; a sync only re-sends events the root key already signed.

bash
# Hosted registrar; self-hosted: use your Worker URL
curl -s -X POST https://nostr-shard-registrar.nostr-shard-signer.workers.dev/sync   # repair relays now
curl -s https://nostr-shard-registrar.nostr-shard-signer.workers.dev/health         # last report

When to run it: the widget shows only the Nostr-signer button (no Web3Auth sign-in) and the host page's console logs DOMAIN_NOT_REGISTERED for a domain you did register. The signer found the registration on none of the registry relays it could reach, usually because the relays that held it dropped it or are down. Run POST /sync, then check underReplicated is empty.

Choosing relays: a relay that always reports missing with repaired: 0, or lists rejected reasons or dropped, doesn't keep these events; one that stays reachable: false is down. Replace either in RELAY_URLS (and DEFAULT_REGISTRY_RELAYS in bunker/src/lib/nostr.ts). Dead relays also slow the signer: it waits for every relay (up to 8 s) before the final authorization answer.

MIT licensed. The signer runs at signer.shardsigner.com; this site never holds keys.