Language-agnostic contract for Drawbridge — the public-facing API gateway that fronts the Gatekeeper, the Lightning mediator, the Herald name service, and the DIDComm relay. It enforces an L402 (“Lightning HTTP 402”) paywall and a subscription-credential alternative on every protected route, then proxies the request upstream.
The canonical implementation is services/drawbridge/server/.
Related specs. Drawbridge is a thin proxy. The behaviour of every protected endpoint is the same as the corresponding Gatekeeper / Lightning-mediator / Herald endpoint — read those specs for the downstream contract. This document covers only what Drawbridge adds on top: the L402 challenge/response, subscription auth, per-operation pricing, rate limiting, and the route prefix layout.
The Drawbridge sits on the public network edge of an Archon node. It has three jobs:
X-Subscription-DID header
proving they hold a valid subscription credential issued by this
deployment’s owner; no payment per request./api/v1/did, /dids, /ipfs/*, /block/*, /search, /query)
are forwarded to the local Gatekeeper. Lightning routes are
forwarded to the local Lightning mediator. Herald routes
(/.well-known/*, /names/*) are forwarded to the local Herald. The
DIDComm relay is fronted at /didcomm and /didcomm/* (not paywalled — DIDComm has
its own signed-challenge auth)./ready, /version, /status, /capabilities,
/didcomm-endpoint, /invoice/:did, the Herald well-known endpoints.DIDComm, Lightning, Herald name resolution, the explorer and the Cashu
mint are optional — a node may not deploy them. Each is “offered” iff
its downstream URL resolves to a non-empty value (see
§8.2). Under the bundled Compose that follows
the service’s profile in COMPOSE_PROFILES; outside Compose an operator
opts a service out by setting its URL empty (e.g. ARCHON_DIDCOMM_URL=).
When a service is off:
GET /api/v1/capabilities reports it false, and/didcomm, /api/v1/lightning, /invoice/:did,
/names) returns HTTP 501 { "error": "<service> is not enabled
on this node" } rather than proxying to an absent upstream.Clients (e.g. keymaster) read the manifest once and fail fast with a clear message instead of discovering absence via a transport error.
It carries no key material. The macaroon root secret
(ARCHON_DRAWBRIDGE_MACAROON_SECRET) is the only sensitive material on
disk; it MUST be ≥ 32 characters and is used only to sign + verify the
service’s own macaroons (HMAC-SHA-256 internal to macaroons.js).
Binds to ${ARCHON_BIND_ADDRESS}:${ARCHON_DRAWBRIDGE_PORT} (default
0.0.0.0:4222).
| Method | Path | Notes |
|---|---|---|
GET |
/api/v1/ready |
Returns <bool> — proxies upstream Gatekeeper readiness. false on connect failure. |
GET |
/api/v1/version |
{ version, commit } (commit is GIT_COMMIT sliced to 7 chars; the sentinel string "unknown" is returned when GIT_COMMIT is unset). |
GET |
/api/v1/capabilities |
{ didcomm, lightning, names, explorer, cashu, memeplex, memepool } — which optional services this node offers (each true iff its downstream URL is configured). Reflects node intent (config), not live health. See Optional services. |
GET |
/api/v1/status |
{ service: "drawbridge", upstream: GatekeeperStatus, uptime: <seconds>, memoryUsage: <node memUsage> }. HTTP 502 if Gatekeeper is unreachable. |
GET |
/api/v1/didcomm-endpoint |
{ endpoint: <string\|null> } — this node’s public DIDComm relay endpoint for publish-didcomm auto-discovery: <ARCHON_DRAWBRIDGE_PUBLIC_HOST>/didcomm, else the Tor onion only when a SOCKS connection to its hidden service succeeds, else null. |
POST |
/api/v1/l402/pay |
Final step of L402 flow. Body: { paymentHash }. Marks the matching macaroon as paid + returns the bearer credential. See §4.4. |
GET |
/invoice/:did |
Forwarded to lightning-mediator’s /invoice/:did. Returns { paymentRequest, paymentHash, ... }. Used by external zappers to pay any DID that has published a Lightning service. 501 if Lightning is disabled. |
* |
/didcomm/** |
Forwarded to the local DIDComm relay (path prefix /didcomm stripped). Carries the relay’s own routes (mailbox messages/*, signed-challenge, egress deliver). Not paywalled — DIDComm authenticates with its own signed challenge. 501 if DIDComm is disabled. application/didcomm-encrypted+json bodies are captured as text and forwarded verbatim. |
GET |
/.well-known/* |
Forwarded to Herald (e.g. lnurlp/<name>, webfinger, names). |
GET\|POST\|PUT\|DELETE |
/names/* |
Forwarded to Herald (/api/*). 501 if name resolution is disabled. |
GET |
/explorer/** |
Forwarded to the node’s own DID explorer. 501 if the explorer is disabled. Unlike the routes above, the /explorer prefix is not stripped: the explorer’s bundle is built with base=/explorer/ and the app is mounted there, so the prefix has to survive the hop or its asset URLs point somewhere the upstream no longer answers. |
GET |
/memeplex/** |
Forwarded to the node’s Memeplex indexer (path prefix /memeplex stripped). Only the indexer’s /api/v1 is reachable; any other path is 400, and any method but GET or HEAD is 405. 501 if the node runs no indexer. |
GET, POST, PUT, DELETE |
/memepool/** |
Forwarded to the node’s Memepool service (path prefix /memepool stripped). Under /memepool/api only the service’s /api/v1 is reachable, by these methods; another path there is 400. Anything else under the mount is one of the service’s pages or their files, and is only read: another method is 405 (a preflight is answered by the node’s CORS handling, as on every mount). /memepool redirects to /memepool/. Cookies the service sets are set for /memepool, so a browser sends them to Memepool and to nothing else on the host. 501 if the node runs no Memepool. |
* |
/1.0/identifiers/** |
Forwarded verbatim to the Gatekeeper’s standards-conformant DID resolution / dereferencing surface (/1.0/identifiers/:did, /:did/data, /:did/registration; see Gatekeeper spec §2.6). Not paywalled — public DID resolution for interop with universal resolvers, which do not speak L402. Proxied unchanged (no prefix stripped), so the Gatekeeper’s resolution triple, raw dereferenced resources, and status/error shapes pass through intact. |
GET |
/metrics |
Prometheus exposition. |
When using the bundled Tor onion, Drawbridge probes a SOCKS connection to
its published hidden service every 60 seconds. The
drawbridge_public_onion_reachable gauge is 1 when reachable, 0 when the
hostname file exists but the onion cannot be reached, and -1 when no hostname
is published (or an explicit public host is configured). Changes between these
states are logged. A 0 means DIDComm and Lightning endpoints already present
in DID documents may be unreachable; restarting Tor with its existing keys
restores the same onion. Check that tor is in COMPOSE_PROFILES and the Tor
container is running. DIDComm endpoint discovery reuses a result for at most
30 seconds so public requests cannot trigger an unbounded number of Tor circuits.
The probe has a five-second timeout, and the periodic check keeps the metric
current between discovery requests. It does not alter
/ready or the config-only /capabilities response.
The proxy routes above are unauthenticated by design — a universal resolver does not speak L402, a DIDComm sender must reach a stranger’s mailbox, and a name claim proves DID control rather than presenting a macaroon. The paid path’s limiter keys on the macaroon’s DID and so cannot apply to any of them, which leaves the upstream’s own limits as the only bound. Herald has none.
Each surface therefore carries a bucket of its own, on the same middleware
/didcomm uses:
| Routes | Setting | Default | Budget |
|---|---|---|---|
/didcomm/** |
see DIDComm spec §5.2.1 | requests + bytes | |
/.well-known/*, GET /names/*, /1.0/identifiers/**, /invoice/:did |
ARCHON_DRAWBRIDGE_PUBLIC_READ_PER_SOURCE |
120 | requests, per source |
ARCHON_DRAWBRIDGE_PUBLIC_READ_GLOBAL |
1200 | requests, whole bucket | |
/explorer/** |
ARCHON_DRAWBRIDGE_EXPLORER_READ_PER_SOURCE |
600 | requests, per source |
ARCHON_DRAWBRIDGE_EXPLORER_READ_GLOBAL |
6000 | requests, whole bucket | |
/memeplex/** |
ARCHON_DRAWBRIDGE_MEMEPLEX_READ_PER_SOURCE |
600 | requests, per source |
ARCHON_DRAWBRIDGE_MEMEPLEX_READ_GLOBAL |
6000 | requests, whole bucket | |
/memepool/**, reads |
ARCHON_DRAWBRIDGE_MEMEPOOL_READ_PER_SOURCE |
300 | requests, per source |
ARCHON_DRAWBRIDGE_MEMEPOOL_READ_GLOBAL |
3000 | requests, whole bucket | |
/memepool/**, writes |
ARCHON_DRAWBRIDGE_MEMEPOOL_WRITE_PER_SOURCE |
30 | requests, per source |
ARCHON_DRAWBRIDGE_MEMEPOOL_WRITE_GLOBAL |
600 | requests, whole bucket | |
POST /names/poppy/* except /names/poppy/api/* |
ARCHON_DRAWBRIDGE_POPPY_AUTH_PER_SOURCE |
120 | requests, per source |
ARCHON_DRAWBRIDGE_POPPY_AUTH_GLOBAL |
1200 | requests, whole bucket | |
other POST\|PUT\|DELETE /names/* |
ARCHON_DRAWBRIDGE_NAME_WRITE_PER_SOURCE |
10 | requests, per source |
ARCHON_DRAWBRIDGE_NAME_WRITE_GLOBAL |
60 | requests, whole bucket | |
| all of the above | ARCHON_DRAWBRIDGE_PUBLIC_RATE_LIMIT_WINDOW |
60s | window |
The explorer is separate because it is chatty. One page load is dozens of asset requests; sharing a budget with DID resolution would let a single visitor exhaust it.
Herald’s writes are separate because they are expensive. PUT /names/api/name
makes Herald issue a verifiable credential and takes a name out of a global
namespace that never refills. Control of a DID is free to obtain, so the write
budget is deliberately small — 10 claims a minute clears any human.
Herald’s Personal Agent Protocol sign-in has its own budget. Token requests,
device polling every five seconds, sign-in pages and wallet responses are POSTs, but
not name writes; on the write budget, a device sign-in that follows the advertised
polling interval would be refused. Account writes through Poppy’s API
(/names/poppy/api/*) stay on the write budget. The bucket is chosen from the path Herald
receives after dot-segment removal. Its 429 carries Retry-After and an empty JSON
body: Poppy defines no error code for a rate limit.
Per-source keying applies only when the source identifies a client, exactly
as on /didcomm: trust proxy is not configured, so behind the bundled Tor
container or any reverse proxy every request arrives from one private address
and only the global bucket binds. See DIDComm spec §5.2.1
for why keying on it anyway would be worse than not keying at all.
A request refused by its per-source bucket is not charged to the global one: it never reaches the upstream, and charging it anyway would let a single source drain the shared budget while already being refused.
Exceeding a budget returns 429 with Retry-After and { error, resetAt }.
If the limiter’s own store is unreachable the check fails open — it protects
availability and must not become the outage it prevents.
| Method | Path | Notes |
|---|---|---|
GET |
/api/v1/l402/status |
Returns service-level L402 status: { enabled, lightning, pricing: [<operationKey>, ...] }. |
POST |
/api/v1/l402/revoke |
Body: { macaroonId: <macaroonId> }. Revokes the macaroon (subsequent verifications return invalid). |
GET |
/api/v1/l402/payments/:did |
List of PaymentRecord for the DID. |
All admin routes require the X-Archon-Admin-Key header. When the
server ARCHON_ADMIN_API_KEY is unconfigured (empty), admin routes
return HTTP 403 { "error": "Admin API key not configured" }. When
configured, a missing or mismatched client header returns HTTP 401.
Constant-time comparison is used.
When L402 is enabled, protected routes require a matching admin key, a valid
L402 bearer, a Cashu payment (§4.5), or the
explicitly enabled subscription stub. Public read exceptions are listed in
§3.2. On 402 challenge, the response is HTTP 402 with a
WWW-Authenticate: L402 macaroon="<base64>", invoice="<bolt11>" header, an
X-Cashu header when Cashu payment is offered, and a JSON body with the same
fields.
Each route is a 1:1 forward to the upstream Gatekeeper after auth passes; the response shape is identical to the Gatekeeper’s. See the Gatekeeper spec §2 for each route’s contract.
| Method | Path |
|---|---|
GET |
/api/v1/registries |
POST |
/api/v1/did |
POST |
/api/v1/did/generate |
GET |
/api/v1/did/:did (forwards versionTime/versionSequence/confirm/verify query params) |
GET |
/api/v1/did/:did/genesis (immutable genesis DID document; no publisher authorization claim) |
POST |
/api/v1/dids |
POST |
/api/v1/dids/export |
POST/GET |
/api/v1/ipfs/json[/:cid] |
POST/GET |
/api/v1/ipfs/text[/:cid] |
POST/GET |
/api/v1/ipfs/data[/:cid] |
POST/GET |
/api/v1/ipfs/stream[/:cid] (true streaming both directions; no body buffering) |
GET |
/api/v1/block/:registry/latest |
GET |
/api/v1/block/:registry/:blockId |
GET |
/api/v1/search?q= |
POST |
/api/v1/query |
Plus a wildcard mount of all Lightning routes, forwarded to the Lightning mediator:
| Method | Path |
|---|---|
* |
/api/v1/lightning/** |
The path tail is appended onto the upstream URL untouched. See the Lightning mediator spec.
Global Express limits (json, urlencoded, text, raw for
application/octet-stream): 10 MB each. A dedicated text parser
for application/didcomm-encrypted+json (also 10 MB) captures DIDComm
envelopes so they survive proxying to the relay byte-for-byte. The IPFS
stream POST (/api/v1/ipfs/stream) explicitly bypasses the raw parser
so the upstream Kubo client can stream the request body directly.
cors() with permissive defaults (any origin, no
credentials). It exposes the 402 challenge headers WWW-Authenticate,
X-Cashu, X-L402-Price and X-L402-Operation, so a browser client can
read the payment requests from the headers and not only from the body./.well-known/*, /names/*): cors({ origin:
true, credentials: true }) — required for browser flows that depend
on session cookies (Herald login, OAuth/OIDC).All error responses are application/json { "error": "<message>" }
unless a downstream proxy returned its own body verbatim. Standard
status codes:
401 — auth header malformed or admin key wrong402 — L402 challenge (with WWW-Authenticate header)403 — admin not configured / scope insufficient429 — rate-limited501 — the requested optional service (DIDComm / Lightning / names) is not enabled on this node502 — upstream Gatekeeper / Lightning / Herald / DIDComm unreachable503 — Lightning service unavailable (L402 invoice creation failed)400 — an X-Cashu token that cannot pay the request or that the node refused503 — Cashu payment could not be redeemed, or no payment method is availableThe route label is the request path with dynamic segments collapsed:
/did/<did> -> /did/:did
/invoice/<did> -> /invoice/:did
/ipfs/json/<cid> -> /ipfs/json/:cid
/ipfs/text/<cid> -> /ipfs/text/:cid
/ipfs/data/<cid> -> /ipfs/data/:cid
/ipfs/stream/<cid> -> /ipfs/stream/:cid
/queue/<registry> -> /queue/:registry
/block/<registry>/latest -> /block/:registry/latest
/block/<registry>/<id> -> /block/:registry/:blockId
/payments/<did> -> /payments/:did
The label is the full path, with its mount: /api/v1/did/:did,
/names/poppy/api/names/:name.
A path is a caller’s to choose, and a label is a series the node keeps for as long as it runs, so a caller cannot make labels at will:
/names, /.well-known,
/explorer, /didcomm, /cashu, /memeplex, /memepool,
/1.0/identifiers,
/api/v1/lightning) is labelled by its path with the segments above
collapsed. The paths under a mount cannot be listed, so a node keeps at most
500 distinct labels of this kind, and a request whose label would be one more
is recorded as /:other./:unrouted, whatever
its path. Its answer is a 404.Protected routes first accept a nonempty X-Archon-Admin-Key matching
Drawbridge’s ARCHON_ADMIN_API_KEY, using the same constant-time comparison
as its admin routes. This exemption grants no new administrative capability:
holders of this key already administer the paywall. Exempt requests create no
invoice and consume no paid quota. They increment
drawbridge_l402_admin_bypasses_total; public bypass routes do not.
Both Keymaster service runtimes can send an explicitly configured upstream credential. To combine server-side DIDComm and L402 with the bundled Compose:
ARCHON_KEYMASTER_GATEKEEPER_URL=http://drawbridge:4222
ARCHON_KEYMASTER_GATEKEEPER_API_KEY=${ARCHON_ADMIN_API_KEY}
Compose maps the latter to ARCHON_GATEKEEPER_API_KEY inside Keymaster. Outside
Compose, set ARCHON_GATEKEEPER_URL and ARCHON_GATEKEEPER_API_KEY directly.
The upstream key defaults to empty; Keymaster never automatically forwards its
own admin key to a potentially remote upstream. Configure this credential only
for a trusted endpoint. Browser wallets do not receive the exemption automatically.
An empty server key never enables exemption. A missing or incorrect header continues through the ordinary payment flow, including accepting a valid L402 bearer; it does not cause an admin-auth rejection on proxy routes.
For other requests, the L402 middleware looks for an Authorization: L402 <macaroon>:<preimage>
header. If valid, the request proceeds. Without one, an X-Cashu token pays
for the request when Cashu payment is offered (§4.5).
Otherwise it issues a 402 challenge.
If ARCHON_DRAWBRIDGE_L402_ENABLED=false, the auth middleware chain
is empty and all proxy routes are open. This is intentional for
private / single-tenant deployments.
Setting ARCHON_DRAWBRIDGE_SUBSCRIPTIONS_ENABLED=true prepends a
subscription-auth middleware ahead of L402. The current middleware is
a stub and performs no verification whatsoever: any request carrying
an X-Subscription-DID header — any value, no credential resolution, no
signature, no expiry or revocation check — is marked
subscription-authenticated, and the L402 middleware then skips payment
verification for it. Enabling this flag therefore lets any caller bypass
the paywall with a single header. It exists only so the dual-auth flow
can be exercised before the subscription system is built.
Real credential verification is tracked in #121. Until that lands, leave
this flag false in any deployment that is not a throwaway dev instance.
The L402 middleware (mounted on the /api/v1 router) has a hard-coded
bypass list for paths that should never be paywalled. Paths are matched
against the request path with the /api/v1 prefix stripped:
/ready, /version, /status, /metrics, /capabilities, /didcomm-endpoint/l402//did/, /ipfs/ or /block/.
Block reads are free because every create operation names a recent block,
so pricing them would make creating a DID cost two payments; adding a
block (POST /block/:registry) stays paid.(Auth is also applied per-route — only the protected proxy routes spread the auth middleware into their handler chain — so the public routes above carry no auth regardless; the bypass list is belt-and-suspenders.)
All other routes are handled outside this router and so are not subject
to the L402 middleware at all (e.g. /invoice/:did, /didcomm/*,
/.well-known/*, /names/*).
Implementations MUST honor this list — clients depend on at least
/ready, /version, and the GET DID, IPFS and block read paths being free.
The L402 protocol is a Lightning-paid HTTP authentication scheme. The Drawbridge implements a slight variant compatible with macaroons.js:
When auth fails on a protected route, Drawbridge:
resolveDID, getDIDs) by
matching the route’s full path, /api/v1/..., to the pricing config
(see §5).ARCHON_DRAWBRIDGE_DEFAULT_PRICE_SATS (default 10).POST /api/v1/l402/invoice to create
a CLN invoice for that amount. The mediator gets 10 seconds; past that,
Lightning counts as unavailable, and a challenge can offer Cashu alone
(§4.5).did = <header X-DID or empty>scope = the operation key for a priced operation, with one use. A
default-priced pass covers the default scopes (resolveDID,
getDIDs, listRegistries, searchDIDs) and always the operation
it was bought for, with no use limit until expiry.expiry = <now + ARCHON_DRAWBRIDGE_INVOICE_EXPIRY seconds> (default 3600)payment_hash = <invoice payment hash>POST /api/v1/l402/pending
on the Lightning mediator (the mediator owns the key-value store
for invoice → macaroon lookup).WWW-Authenticate: L402 macaroon="<base64>", invoice="<bolt11>"{ macaroon, invoice } for clients that don’t parse
the header.Macaroons are built with macaroons.js
and serialized with the library’s default (binary, base64-wrapped).
Caveats are encoded as plain text strings of the form <key> = <value>:
did = did:cid:bagaaiera...
scope = resolveDID
expiry = 1726700000
max_uses = 100
payment_hash = abc123...
Implementations SHOULD use a macaroons.js-compatible library (macaroons.py, libmacaroons, macaroon-rs, etc.). A minimal custom implementation MUST:
rootSecret = ARCHON_DRAWBRIDGE_MACAROON_SECRET
as the keyed-MAC primitive.http://localhost:<port> (yes, even on
remote servers — the location is informational, not a routing hint).Clients pay the invoice, retrieve the preimage from their Lightning wallet, and resubmit:
Authorization: L402 <base64-macaroon>:<hex-preimage>
Drawbridge’s L402 middleware:
:.sha256(preimage) == payment_hash from the macaroon
caveats.rootSecret.did matches the request’s X-DID (or empty).scope matches the operation key for the requested route.expiry > now.currentUses < maxUses (incremented on every accepted request).payment_hash matches the now-verified preimage.finish event, if
the upstream status was < 500, increments currentUses in the
store.On any failure: HTTP 401 with a fresh 402 challenge.
POST /api/v1/l402/pay exists for a polling flow where the client wants
Drawbridge to confirm the payment server-side rather than presenting
the credential immediately:
{ paymentHash }. (Any preimage in the body is IGNORED.)GET /api/v1/l402/pending/:paymentHash)./api/v1/l402/check) and verifies it matches the payment hash.{ macaroonId, macaroon, paymentHash, method, amountSat, preimage }.NUT-24 is a second way to
pay the same price (#1596). The 402 challenge carries X-Cashu: creqA…, a
NUT-18 payment request for one call:
a: the price in sats;u: sat;m: the node mint’s public URL, <ARCHON_DRAWBRIDGE_PUBLIC_HOST>/cashu.The body lists acceptedMethods and repeats the request as cashu. The client
retries with X-Cashu: cashuB…. A Keymaster wallet that has the node mint makes
that token from the request:
keymaster cashu-decode-request "$request" # the amount, and the mint it would be paid from
token=$(keymaster cashu-pay-request "$request" --max 10)
curl -H "X-Cashu: $token" …
--max refuses a request asking for more sats than the caller expects. Before
serving, Drawbridge:
X-DID, which is
unauthenticated and attributes the payment only;400 if it is from
another mint, of another unit, for less than the price, or carries spending
conditions;POST /cashu/receive) into the
identity ARCHON_NODE_ID, so the payment lands in the node’s Cashu wallet and
Drawbridge holds no funds. Drawbridge follows Keymaster’s own
classification, the HTTP status KeymasterClient carries on its errors.
400 means the token is at fault: malformed or not covering its fee,
already spent, locked to another key, or refused by the mint, for example
for duplicate inputs or an invalid signature. Drawbridge answers 400.503
and a logged warning. That includes a Keymaster or mint that cannot be
reached, and a Keymaster server error;400, and what it brought in stays
received;method: "cashu", then serves the request.X-Cashu is redacted from request logs: a token refused before redemption is
still spendable.
A Cashu payment covers only the request it comes with, and no macaroon is issued. The token is redeemed before the request is served, so a request that then fails is still paid.
Cashu is offered only while all of these hold:
cashu profile) and an https
ARCHON_DRAWBRIDGE_PUBLIC_HOST;ARCHON_DRAWBRIDGE_KEYMASTER_URL,
ARCHON_DRAWBRIDGE_KEYMASTER_ADMIN_KEY and ARCHON_NODE_ID. The bundled
Compose sets these for the node’s own Keymaster;ARCHON_NODE_ID on that Keymaster has added the node mint
(archon add-cashu <node ID>).Drawbridge checks the last at most once a minute, gives up on a lookup after 5
seconds so a stalled Keymaster cannot hold up a Lightning challenge, and logs a
warning while it fails. Lightning and Cashu are each offered when they can work. If invoice
creation fails while Cashu is ready, the challenge offers Cashu alone; with
neither available, the answer is 503.
Metric: drawbridge_cashu_payments_total.
Per-operation prices are loaded at startup. Only two individual operations have dedicated environment-variable overrides:
ARCHON_DRAWBRIDGE_PRICE_CREATE_DID — sats for createDID
(accepts >= 0).ARCHON_DRAWBRIDGE_PRICE_RESOLVE_DID — sats for resolveDID
(must be > 0).For any other operation, set the JSON override
ARCHON_DRAWBRIDGE_PRICING (see §8.2).
The full set of operation keys (used by the route-to-scope mapper):
| Key | Routes |
|---|---|
resolveDID |
GET /did/:did |
createDID |
POST /did |
generateDID |
POST /did/generate |
getDIDs |
POST /dids |
exportDIDs |
POST /dids/export |
importDIDs |
POST /dids/import |
removeDIDs |
POST /dids/remove |
exportBatch |
POST /batch/export |
importBatch |
POST /batch/import |
importBatchByCids |
POST /batch/import/cids |
getQueue |
GET /queue/:registry |
clearQueue |
POST /queue/:registry/clear |
processEvents |
POST /events/process |
listRegistries |
GET /registries |
searchDIDs |
GET /search |
queryDIDs |
POST /query |
getBlock |
GET /block/:registry/:blockId and /latest |
addBlock |
POST /block/:registry |
addJSON |
POST /ipfs/json |
getJSON |
GET /ipfs/json/:cid |
addText |
POST /ipfs/text |
getText |
GET /ipfs/text/:cid |
addData |
POST /ipfs/data |
getData |
GET /ipfs/data/:cid |
The IPFS streaming routes (/ipfs/stream, /ipfs/stream/:cid) have no
explicit scope entry and so fall through to the default price.
Any operation without an explicit price uses
ARCHON_DRAWBRIDGE_DEFAULT_PRICE_SATS. createDID accepts a value of
0 (free); resolveDID requires > 0. Other free operations must be
configured via the ARCHON_DRAWBRIDGE_PRICING JSON override or by
disabling L402 entirely.
Per-DID sliding window stored in Redis. Request ledger key:
drawbridge:ratelimit:<did> (a sorted set of per-request members
scored by timestamp, TTL = rateLimitWindow seconds). Each
authenticated request adds an entry; if more than rateLimitMax
entries fall in the last rateLimitWindow seconds, the request is
rejected with HTTP
429 { "error": "Rate limit exceeded", "resetAt": <unix> }.
Defaults: 100 requests / 60 seconds. Configured via:
ARCHON_DRAWBRIDGE_RATE_LIMIT_MAXARCHON_DRAWBRIDGE_RATE_LIMIT_WINDOWAnonymous (unauthenticated) requests are rate-limited per-IP. The DID
used for rate-limiting is read from the X-DID request header (the L402
middleware also uses this header for the macaroon’s did caveat).
Namespace: drawbridge:. All values are JSON strings unless noted.
| Key | Type | TTL | Contents |
|---|---|---|---|
drawbridge:macaroon:<id> |
STRING | none | MacaroonRecord |
drawbridge:payment:<id> |
STRING | none | PaymentRecord |
drawbridge:payments:did:<did> |
SORTED SET | none | Payment IDs for that DID, scored by createdAt |
drawbridge:ratelimit:<did> |
SORTED SET | windowSeconds |
Sliding-window members scored by request timestamp |
MacaroonRecord:
{
"id": "<hex>",
"did": "<DID or empty>",
"scope": ["resolveDID", ...],
"createdAt": <unix ms>,
"expiresAt": <unix ms>,
"maxUses": <int>,
"currentUses": <int>,
"paymentHash": "<hex>",
"revoked": <bool>
}
PaymentRecord — same shape as in the
Lightning mediator spec §5.
A new implementation MUST use this schema if the Redis instance is shared with the reference TypeScript service.
ARCHON_DRAWBRIDGE_MACAROON_SECRET is ≥ 32
chars — exit 1 on failure.waitUntilReady=true, retry-with-backoff).
Exit on persistent failure.| Variable | Default | Meaning |
|---|---|---|
ARCHON_DRAWBRIDGE_PORT |
4222 |
HTTP listen port. |
ARCHON_BIND_ADDRESS |
0.0.0.0 |
|
ARCHON_GATEKEEPER_URL |
http://localhost:4224 |
Upstream Gatekeeper. |
ARCHON_COMPOSE_PROFILES |
unset | The node’s COMPOSE_PROFILES, passed by the bundled Compose. When present, an empty upstream URL below resolves to its container if the service’s profile is listed, and stays off otherwise. |
ARCHON_HERALD_URL |
http://localhost:4230 |
Upstream Herald (for /.well-known/* and /names/*); container http://herald:4230, profile herald. Off: capability names:false, /names → 501. |
ARCHON_LIGHTNING_MEDIATOR_URL |
http://localhost:4235 |
Upstream for Lightning routes + L402 invoice/pending storage; container http://lightning-mediator:4235, profile lightning. Off: capability lightning:false, /lightning + /invoice/:did → 501. |
ARCHON_EXPLORER_URL |
http://localhost:4000 |
Upstream DID explorer proxied at /explorer; container http://explorer:4000, profile explorer. Off: capability explorer:false, /explorer → 501. |
ARCHON_DIDCOMM_URL |
http://localhost:4236 |
Upstream DIDComm relay proxied at /didcomm; container http://didcomm:4236, profile didcomm. Off: capability didcomm:false, /didcomm → 501. |
ARCHON_CASHU_MINT_URL |
empty | Upstream Cashu mint proxied at /cashu; container http://cashu-mint:8085, profile cashu. Off: capability cashu:false, /cashu → 501. |
ARCHON_DRAWBRIDGE_PUBLIC_HOST |
empty | Public base URL this node is reachable at (clearnet host or Tor onion). Used by /didcomm-endpoint to advertise <host>/didcomm. |
ARCHON_DRAWBRIDGE_KEYMASTER_URL |
empty | The node’s Keymaster, which redeems Cashu payments (§4.5). The bundled Compose fixes it to http://keymaster:4226. |
ARCHON_DRAWBRIDGE_KEYMASTER_ADMIN_KEY |
empty | Admin key for that Keymaster. Given explicitly, not taken from ARCHON_ADMIN_API_KEY; the bundled Compose passes the node’s admin key. |
ARCHON_NODE_ID |
empty | The node identity whose Cashu wallet receives payments. |
ARCHON_DRAWBRIDGE_TOR_HOSTNAME_FILE |
/data/tor/hostname |
When PUBLIC_HOST is empty, /didcomm-endpoint falls back to the Tor onion read from this shared hidden-service hostname file. |
ARCHON_DRAWBRIDGE_TOR_PROXY |
tor:9050 |
SOCKS5 proxy used to check that the published hidden service is reachable. Set to the Docker network address for bundled Tor. |
ARCHON_REDIS_URL |
redis://localhost:6379 |
Macaroon/payment/rate-limit store. |
ARCHON_ADMIN_API_KEY |
empty | Required for L402 admin routes. Empty → admin routes 403. |
ARCHON_DRAWBRIDGE_L402_ENABLED |
false |
When false, all proxy routes open. |
ARCHON_DRAWBRIDGE_SUBSCRIPTIONS_ENABLED |
false |
Insecure dev stub (#121). When true, any request carrying an X-Subscription-DID header bypasses L402 payment verification with no credential check. See §3.1. |
ARCHON_DRAWBRIDGE_MACAROON_SECRET |
empty (required) | HMAC root secret. ≥ 32 chars. |
ARCHON_DRAWBRIDGE_DEFAULT_PRICE_SATS |
10 |
Per-request price for unmapped operations. |
ARCHON_DRAWBRIDGE_INVOICE_EXPIRY |
3600 |
Macaroon expiry, seconds. |
ARCHON_DRAWBRIDGE_RATE_LIMIT_MAX |
100 |
|
ARCHON_DRAWBRIDGE_RATE_LIMIT_WINDOW |
60 |
Seconds. |
ARCHON_DRAWBRIDGE_PRICE_CREATE_DID |
unset | Sats price for createDID (accepts >= 0). |
ARCHON_DRAWBRIDGE_PRICE_RESOLVE_DID |
unset | Sats price for resolveDID (must be > 0). |
ARCHON_DRAWBRIDGE_PRICING |
unset | JSON pricing override; { "operations": { "<scope>": { "amountSat": <n>, "description": "..." } } }. Merged on top of the per-operation env vars. |
GIT_COMMIT |
unknown |
Build commit. |
How an upstream URL resolves (
upstreams.ts). A non-empty value is used as given, whether or not its profile runs. Otherwise, whenARCHON_COMPOSE_PROFILESis present (the bundled Compose always passes it), the URL is the service’s container if its profile is listed and empty (off) if not. WithoutARCHON_COMPOSE_PROFILES, an unset URL falls back to the localhost default and an explicitly empty one turns the service off. The result drives/capabilitiesand the 501 gating. Profiles given withdocker compose --profileinstead ofCOMPOSE_PROFILESare not visible here; set the URL for those.
SIGTERM/SIGINT → close HTTP listener → disconnect Redis → exit 0.
| Metric | Type | Labels |
|---|---|---|
drawbridge_http_requests_total |
counter | method, route, status |
drawbridge_http_request_duration_seconds |
histogram (buckets: 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5) |
method, route |
drawbridge_l402_admin_bypasses_total |
counter | none |
drawbridge_l402_challenges_total |
counter | did_known ("true"/"false") |
drawbridge_l402_verifications_total |
counter | result ("success"/"failure") |
drawbridge_version_info |
gauge | version, commit |
Plus the standard Prometheus process metrics. Route normalization rules in §2.7.
pino at LOG_LEVEL (default info); HTTP via pino-http in
production or morgan('dev') otherwise. Errors logged as structured
{ err } objects with the upstream URL when a proxy call fails.
The pino-http request log redacts headers that carry bearer secrets:
authorization, dpop, cookie and x-archon-admin-key on requests, and
set-cookie and location (which can carry authorization codes) on responses.
No log lines are contractual for downstream consumers.
ghcr.io/archetech/drawbridgeUnit and router tests live in tests/drawbridge/, including internal admin-key
exemption, payment fallback, and admin-route rejection. Additional validation:
A conformant third implementation MUST:
GET /api/v1/capabilities and apply the optional-service
off-switch + 501 gating (§1 Optional services):
a service whose downstream URL is empty reports false and its proxy
mount returns 501.WWW-Authenticate: L402 macaroon="...", invoice="...", JSON body
with the same fields.sha256(preimage) == payment_hash constant-time.ARCHON_ADMIN_API_KEY is configured (so the upstream services accept
the proxy request).