btcintel

Link the person's own key to the account

POST /v1/auth/npub/link
who may call it
A session
the session of an account · replace: true needs aal 2, but for a custodied key that no app uses on an account without a second factor.
what it costs
1 request of the quota
tiers and keys
how fresh
Never cached
every answer carries the index's height and the node's
MCP tool
None
On this page

Needs aal 1. proof is the kind 27235 event described at POST /v1/auth/npub/challenge, signed by pubkey; source records how the person signs: nip07 (extension), nip46 (remote signer), nip55 (Android signer). One live key per account and one account per key (409). With replace: true the key takes the place of the account's live key in one step: a custodied key is retired, kept in the signer and exportable for 30 days (retired_key on /v1/auth/me), and the apps connected to it lose their access; replacing a custodied key needs aal 1, or aal 2 when apps use it or the account has a second factor, and replacing an own key needs aal 2 (403 otherwise). Every replacement is told to the account by e-mail, naming the old and the new npub. The link is shown to the account (/v1/auth/me) and to human operators in the ops audit; no public route or record carries it.

Parameters

NameWhereTypeRequiredWhat it does
pubkeybodystringrequired64 hex characters.
sourcebodystringrequiredHow the person signs with the key: nip07 (a browser extension), nip46 (a remote signer) or nip55 (an Android signer).
proofbodyobjectrequiredA Nostr event as NIP-01 serialises it. Signed on the way out of POST /v1/auth/npub/sign; unsigned on the way in (id and sig absent, pubkey optional).
replacebodybooleanoptionalIn place of the account's live key; without it, a live key answers 409.

The body is application/json.

schema
  • pubkey string required — 64 hex characters.
  • source string required — How the person signs with the key: nip07 (a browser extension), nip46 (a remote signer) or nip55 (an Android signer). · one of "nip07", "nip46", "nip55"
  • proof NostrEvent required — A Nostr event as NIP-01 serialises it. Signed on the way out of POST /v1/auth/npub/sign; unsigned on the way in (id and sig absent, pubkey optional).
    • id string — The event's id, 64 hex: the SHA-256 of its NIP-01 serialisation. POST /v1/auth/npub/sign sets it.
    • pubkey string — The author's public key, 64 hex. On an event sent to be signed it may be left out, and must otherwise be the account's custodied key.
    • created_at integer required — Unix seconds.
    • kind integer required — The event's kind.
    • tags array of array of string required — The event's tags.
    • content string required — The event's text.
    • sig string — The author's Schnorr signature of the id, 128 hex. Never on an event sent to be signed.
  • replace boolean — In place of the account's live key; without it, a live key answers 409.

What it answers

201 · application/json

The linked key.

FieldTypeWhat it carries
pubkeystring64 hex characters.
npubstringThe key as an npub (NIP-19).
sourcestringHow the key signs: custodied by btcintel's signer, or the person's own through nip07 (a browser extension), nip46 (a remote signer) or nip55 (an Android signer).
linked_atstringWhen the key was linked to the account.
exportablebooleanTrue for a custodied key: POST /v1/auth/npub/export hands it over.
exported_atstringWhen a custodied key was last exported; absent until then, and while the signer does not answer.
clientsarrayThe NIP-46 apps connected to a custodied key; empty when none, absent while the signer does not answer.
clients[].client_pubkeystringThe app's pubkey, 64 hex characters.
clients[].namestringWhat the account called the app when it made the link; may be empty.
clients[].permsarrayWhat the app may ask for: sign_event:<kind>, sign_event, nip44_encrypt, nip44_decrypt, nip04_encrypt, nip04_decrypt.
clients[].connected_atstringWhen the app connected.
clients[].last_used_atstringAbsent until the app's first request after connecting.
schema SigningIdentity
  • pubkey string required — 64 hex characters.
  • npub string required — The key as an npub (NIP-19).
  • source string required — How the key signs: custodied by btcintel's signer, or the person's own through nip07 (a browser extension), nip46 (a remote signer) or nip55 (an Android signer). · one of "custodied", "nip07", "nip46", "nip55"
  • linked_at string (date-time) required — When the key was linked to the account.
  • exportable boolean required — True for a custodied key: POST /v1/auth/npub/export hands it over.
  • exported_at string (date-time) — When a custodied key was last exported; absent until then, and while the signer does not answer.
  • clients array of SignerClient — The NIP-46 apps connected to a custodied key; empty when none, absent while the signer does not answer.
    • client_pubkey string required — The app's pubkey, 64 hex characters.
    • name string required — What the account called the app when it made the link; may be empty.
    • perms array of string required — What the app may ask for: sign_event:<kind>, sign_event, nip44_encrypt, nip44_decrypt, nip04_encrypt, nip04_decrypt.
    • connected_at string (date-time) required — When the app connected.
    • last_used_at string (date-time) — Absent until the app's first request after connecting.

Errors

StatusCodeWhen
400invalid_inputMalformed input (invalid_input).
401unauthorizedunauthorized: the request does not say who makes it, or what it offers does not verify: no key or session where one is needed, or a password, a code, a passkey or a signed event that does not check. The message says what is missing.
403forbiddenforbidden: the caller is known but may not do this: a key without the scope or the tier the action needs, a session without an npub, a second factor or a recent sign-in, an operator without the role or switched off, or a source that does not allow it. The message says which.
409conflictconflict: the state refuses the change, for example a dispute of this caller's already open, a dispute or a claim no longer open, an address that belongs to another account, or a thing done already. The message says which.
422nip98_invalidThe NIP-98 event was refused (nip98_invalid): wrong URL or method, stale, bad signature, wrong payload hash, or used before; the message names the reason.
501not_configurednot_configured: this deployment does not run what the route needs, for example the mempool engine, accounts, the intel store or watchlists. The message names it.
503signing_off, unavailablesigning_off: the custodied signer is switched off (SIGNING_ENABLED), keys stay encrypted and exportable later; or unavailable: the signer service is not answering.

Each comes in the one error envelope, and none is cached: an error carries Cache-Control: no-store.

Example

No snippet. This route takes a signed-in session (the cookie btcintel.io sets) or a NIP-98 signature from your Nostr signer, never a key, so no snippet can run it from a shell. See Identity.