{"openapi":"3.1.0","info":{"title":"Block Genomics \u2014 Agent Connect API","version":"1.8.0","description":"The machine-discoverable surface any AI agent uses to connect to Block Genomics: discover the protocol, prove ownership of a Bitcoin block via BIP-322, register a sovereign BitmapAgent on any block it owns, and read\/act on that block's world. Read endpoints are public. Write endpoints require a BIP-322 signature over a one-time challenge (and for \/world*, an action-bound message); the agent brings its own signer\/wallet. To try the API before owning a block, mint a read-only sandbox key at POST \/api\/v1\/sandbox\/key (100 requests\/day, no wallet required).","contact":{"name":"Block Genomics","url":"https:\/\/blockgenomics.io"},"license":{"name":"MIT","url":"https:\/\/opensource.org\/licenses\/MIT"}},"servers":[{"url":"https:\/\/blockgenomics.io","description":"Production"},{"url":"http:\/\/localhost:3000","description":"Local development"}],"tags":[{"name":"Discovery","description":"Protocol-wide reads, no auth"},{"name":"Block","description":"Read a block's ownership, record, and world"},{"name":"Identity","description":"Read an agent's identity and verified blocks"},{"name":"Auth","description":"Challenge + BIP-322 ownership proof"},{"name":"World","description":"Owner-authorized, action-bound world mutations"},{"name":"Agents","description":"Register and drive sovereign BitmapAgents on blocks you own"},{"name":"Experiences","description":"Attach, discover, and health-probe self-hosted experiences on blocks you own"},{"name":"Sandbox","description":"Read-only trial keys \u2014 no Bitmap ownership required"}],"paths":{"\/api\/v1\/sandbox\/key":{"post":{"operationId":"createSandboxKey","tags":["Sandbox"],"summary":"Mint a read-only sandbox API key","description":"Issues a read-only API key with no ownership proof, so you can call the API before you own a Bitmap block. The key is returned exactly once \u2014 only its SHA-256 hash is stored. Sandbox keys are limited to 100 requests per UTC day and are rejected on any write (see the sandboxKey security scheme). Issuance is capped at 3 keys per source IP per UTC day.","requestBody":{"required":false,"content":{"application\/json":{"schema":{"type":"object","properties":{"label":{"type":"string","maxLength":80,"description":"Optional name to tell your keys apart"}}}}}},"responses":{"201":{"description":"Key issued","content":{"application\/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"apiKey":{"type":"string","description":"Plaintext key \u2014 shown once, store it now","examples":["bg_sbx_2f1c\u2026"]},"keyId":{"type":"string"},"keyPrefix":{"type":"string"},"tier":{"type":"string","const":"sandbox"},"access":{"type":"string","const":"read-only"},"dailyLimit":{"type":"integer","examples":[100]},"createdAt":{"type":"string","format":"date-time"}}}}}}}},"429":{"description":"Issuance limit reached for this source IP today"}}}},"\/api\/v1\/sandbox\/whoami":{"get":{"operationId":"getSandboxWhoami","tags":["Sandbox"],"summary":"Validate a sandbox key and read its remaining quota","description":"Charges one request against the key's daily quota and returns the standard X-RateLimit-* headers. Use it to confirm a key works.","security":[{"sandboxKey":[]}],"responses":{"200":{"description":"Key is live","headers":{"X-RateLimit-Limit":{"schema":{"type":"integer"},"description":"Requests allowed per UTC day"},"X-RateLimit-Remaining":{"schema":{"type":"integer"},"description":"Requests left in the current window"},"X-RateLimit-Reset":{"schema":{"type":"integer"},"description":"Unix seconds at which the quota resets"}},"content":{"application\/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"tier":{"type":"string","const":"sandbox"},"access":{"type":"string","const":"read-only"},"keyId":{"type":"string"},"keyPrefix":{"type":"string"},"quota":{"type":"object","properties":{"limit":{"type":"integer"},"used":{"type":"integer"},"remaining":{"type":"integer"},"resetsAt":{"type":"string","format":"date-time"}}}}}}}}}},"401":{"description":"Missing, invalid, or revoked sandbox key"},"429":{"description":"Daily sandbox quota exhausted"}}}},"\/api\/v1\/stats":{"get":{"operationId":"getStats","tags":["Discovery"],"summary":"Protocol-wide counts","responses":{"200":{"description":"Counts","content":{"application\/json":{"schema":{"type":"object","properties":{"verifiedAgents":{"type":"integer"},"genomesMinted":{"type":"integer"},"blocksVerified":{"type":"integer"}}}}}}}}},"\/api\/v1\/search":{"get":{"operationId":"search","tags":["Discovery"],"summary":"Search blocks, agents, and users","parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string","minLength":2}}],"responses":{"200":{"description":"Search results"}}}},"\/api\/v1\/ownership\/verify":{"get":{"operationId":"getOwnership","tags":["Block"],"summary":"Authoritative on-chain ownership for a block","parameters":[{"name":"blockHeight","in":"query","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Ownership status","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}}}}},"\/api\/v1\/ownership\/{height}":{"get":{"operationId":"getOwnershipByHeight","tags":["Block"],"summary":"Authoritative on-chain ownership for a block (path-param form)","description":"RESTful alias for \/api\/v1\/ownership\/verify?blockHeight=. Resolves numeric heights only; always answers JSON so callers never receive the 404 HTML shell.","parameters":[{"name":"height","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"Ownership status","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"400":{"description":"Invalid block height","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"429":{"description":"Rate limited","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}}}}},"\/api\/v1\/ownership\/sync":{"post":{"operationId":"syncOwnership","tags":["Block"],"summary":"Reconcile a block record with its current on-chain owner","description":"Callable by either the current record owner or the on-chain owner. `message` is the canonical `Block Genomics Authorization v1` action message for action `ownership.sync`, POST, this path, this block and the SHA-256 of the body without `message`\/`signature`, carrying a nonce from POST \/api\/v1\/challenge with purpose `ownership`; it works once. When the two disagree the transfer is executed and the record follows the chain.","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["walletAddress","signature","message","blockHeight"],"properties":{"walletAddress":{"type":"string","description":"Signing wallet \u2014 must be the record owner or the on-chain owner."},"signature":{"type":"string","description":"BIP-322 signature over message."},"message":{"type":"string","description":"The canonical action message (action ownership.sync)."},"blockHeight":{"type":"integer","minimum":1}}}}}},"responses":{"200":{"description":"Sync result \u2014 transferred true when the record moved","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"400":{"description":"Missing required field","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"401":{"description":"Invalid signature, or not the bound action message for this request, or its nonce was already used","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"403":{"description":"Caller is neither the record owner nor the on-chain owner","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"404":{"description":"Unknown block","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}}}}},"\/api\/v1\/blocks\/{height}":{"get":{"operationId":"getBlock","tags":["Block"],"summary":"Registered block record","parameters":[{"name":"height","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Block record","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"404":{"description":"Block not registered"}}}},"\/api\/v1\/blocks\/{height}\/market":{"get":{"operationId":"getBlockMarket","tags":["Block"],"summary":"Advisory marketplace view for a block","description":"What third-party ordinals marketplaces currently advertise for this block. Advisory and display-only \u2014 never an ownership signal (Nexus Protocol \u00a711). Returns 200 for any valid height, including unclaimed ones.","parameters":[{"name":"height","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Advisory market view","content":{"application\/json":{"schema":{"allOf":[{"$ref":"#\/components\/schemas\/Envelope"},{"type":"object","properties":{"data":{"$ref":"#\/components\/schemas\/BlockMarket"}}}]}}}},"400":{"description":"Invalid block height"},"429":{"description":"Rate limited"}}}},"\/api\/v1\/blocks\/{height}\/parcels":{"get":{"operationId":"listBlockParcels","tags":["Block"],"summary":"List every parcel on a block","description":"Public read. Returns all parcels recorded for the block in txIndex order, each with its owner summary. Unclaimed parcels are absent rather than returned with a null owner.","parameters":[{"name":"height","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Parcels for the block","content":{"application\/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"array","items":{"$ref":"#\/components\/schemas\/Parcel"}}}}}}},"400":{"description":"Invalid block height"},"429":{"description":"Rate limited"}}}},"\/api\/v1\/blocks\/{height}\/parcels\/{txIndex}\/customize":{"post":{"operationId":"customizeParcel","tags":["World"],"summary":"Customize a parcel on a block you own or hold a delegation on","description":"Requires a BIP-322 signature over a single-use challenge whose message also commits to a hash of the exact customization payload, so a captured signature cannot be re-applied with different values. 1) POST \/api\/v1\/challenge { walletAddress, purpose: \"parcel-customize\" }. 2) Build the canonical payload string and SHA-256 it (see x-bg-parcel-binding). 3) Ensure the signed message contains the binding line. 4) Sign with your wallet and POST here. Authorization differs by parcel state: an existing parcel may be customized by its parcel owner, the on-chain block owner, or an active delegatee; a parcel that does not exist yet may only be initialized by the block owner.","security":[{"bip322":[]}],"parameters":[{"name":"height","in":"path","required":true,"schema":{"type":"integer","minimum":0}},{"name":"txIndex","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/ParcelCustomizeRequest"}}}},"responses":{"200":{"description":"The stored parcel","content":{"application\/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#\/components\/schemas\/Parcel"}}}}}},"400":{"description":"Invalid parameters, non-string field, or payload does not match the signed message"},"401":{"description":"Invalid signature, or an expired\/already-used challenge"},"403":{"description":"Signer may not customize (or may not initialize) this parcel"}}}},"\/api\/v1\/world":{"get":{"operationId":"getWorld","tags":["Block"],"summary":"Visible world objects + terrain for a block","parameters":[{"name":"blockHeight","in":"query","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"World data","content":{"application\/json":{"schema":{"type":"object","properties":{"objects":{"type":"array","items":{"$ref":"#\/components\/schemas\/WorldObject"}},"terrain":{"oneOf":[{"$ref":"#\/components\/schemas\/BlockTerrain"},{"type":"null"}]}}}}}}}},"post":{"operationId":"createWorldObject","tags":["World"],"summary":"Create a world object on a block you own","description":"Requires an action-bound BIP-322 signature. 1) POST \/api\/v1\/challenge { walletAddress, purpose:'world' } to get a one-time nonce. 2) Build the canonical authorization message (see x-bg-action-message) binding method+path+block+bodyHash+nonce+expiry. 3) Sign it with your wallet. 4) POST this body with { signature, message }. Success emits an `agent_event` type=`world_updated` to every active BitmapAgent on the block.","requestBody":{"required":true,"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/WorldCreateRequest"}}}},"responses":{"201":{"description":"Created"},"401":{"description":"Missing\/invalid signature, expired or already-used nonce, or binding mismatch"},"403":{"description":"Signer is not the block owner"}}}},"\/api\/v1\/world\/batch":{"post":{"operationId":"batchWorldOps","tags":["World"],"summary":"Batch create\/update\/delete world objects (up to 100 ops, all-or-nothing)","description":"Create\/update\/delete up to 100 world objects on a block you own, in ONE call. AUTHORIZATION \u2014 either credential path (\u00a74.4): SESSION, an `Authorization: Bearer bg_vfy_...` token covering this block, with no signature, message or nonce, where the write is attributed to the session wallet and `ownerAddress` in the body is ignored; or WALLET, an action-bound BIP-322 signature whose `bodyHash` covers the FULL batch, plus `ownerAddress` (see x-bg-action-message; the action is `world.batch`). ALL-OR-NOTHING (\u00a77.3): the batch applies completely or not at all, so a 2xx means every sub-op landed and a failed sub-op is never reported inside a 2xx; any other status means nothing was applied. ORDERING: sub-ops are validated for shape, ownership, block membership and lock state BEFORE the nonce is consumed, so a rejected batch leaves the nonce spendable and the identical signed request can be re-sent; credentials are checked before any object is looked up, so an uncredentialed caller cannot use validation errors to probe which object ids exist. RETRY: 400\/403\/503 applied nothing and left the nonce untouched (re-send as is); 500 `batch_failed` applied nothing but DID spend the nonce (re-sign on the wallet path, or re-send unchanged on the session path); retrying a batch that already applied is not idempotent for `create` sub-ops, so reconcile with GET \/api\/v1\/world first if a response was lost. Success emits a single `world_updated` agent event summarizing the batch.","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["blockHeight","operations"],"properties":{"blockHeight":{"type":"integer"},"ownerAddress":{"type":"string"},"operations":{"type":"array","maxItems":100,"items":{"type":"object","required":["action"],"properties":{"action":{"type":"string","enum":["create","update","delete"]},"id":{"type":"string"},"data":{"type":"object"}}}},"signature":{"type":"string"},"message":{"type":"string"}}}}}},"responses":{"200":{"description":"Batch fully applied. `results` lists every sub-op, all successful."},"400":{"description":"Invalid batch (missing fields, >100 ops, malformed or unknown sub-op). Nothing applied."},"401":{"description":"No credential, invalid signature\/binding, or an expired\/already-used nonce. Nothing applied."},"403":{"description":"Caller is not the current block owner, or a sub-op targets an object on another block \/ a locked object. Nothing applied; nonce preserved."},"429":{"description":"Rate limited \u2014 20 batches\/minute per identity. Retry after `Retry-After`."},"500":{"description":"`batch_failed` \u2014 the transaction rolled back. Nothing was applied."},"503":{"description":"`onchain_unavailable` \u2014 live ownership could not be confirmed. Nothing applied; nonce preserved."}},"security":[{"verifiedSession":[]},{"bip322":[]}]}},"\/api\/v1\/world\/{id}":{"patch":{"operationId":"updateWorldObject","tags":["World"],"summary":"Update a world object you own (action-bound signature required)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Updated"},"401":{"description":"Auth failed"},"403":{"description":"Not owner \/ locked"}}},"delete":{"operationId":"deleteWorldObject","tags":["World"],"summary":"Delete a world object you own (action-bound signature required)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted"},"401":{"description":"Auth failed"},"403":{"description":"Not owner \/ locked"}}}},"\/api\/v1\/world\/terrain":{"get":{"operationId":"getBlockTerrain","tags":["Block"],"summary":"Read a block's terrain settings","description":"Public read. Returns null terrain when the block owner has never written any.","parameters":[{"name":"blockHeight","in":"query","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"Terrain settings, or null","content":{"application\/json":{"schema":{"type":"object","properties":{"terrain":{"oneOf":[{"$ref":"#\/components\/schemas\/BlockTerrain"},{"type":"null"}]}}}}}},"400":{"description":"blockHeight required"},"429":{"description":"Rate limited"}}},"post":{"operationId":"updateBlockTerrain","tags":["World"],"summary":"Create or replace the terrain settings of a block you own","description":"Requires an action-bound BIP-322 signature, exactly like the other world writes. 1) POST \/api\/v1\/challenge { walletAddress, purpose: \"world\" } to get a one-time nonce. 2) Build the canonical authorization message with Action `world.terrain` binding method+path+block+bodyHash+nonce+expiry (see x-bg-action-message). 3) Sign it with your wallet. 4) POST this body with { signature, message }. Ownership is re-checked against the chain, not against the cached Block.ownerAddress, before the nonce is burned. Upserts: fields you omit keep their stored value.","security":[{"bip322":[]}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/TerrainUpdateRequest"}}}},"responses":{"200":{"description":"The stored terrain","content":{"application\/json":{"schema":{"type":"object","properties":{"terrain":{"$ref":"#\/components\/schemas\/BlockTerrain"}}}}}},"400":{"description":"blockHeight and ownerAddress required"},"401":{"description":"Missing\/invalid signature, binding mismatch, or an expired\/already-used nonce"},"403":{"description":"Signer is not the on-chain block owner"},"429":{"description":"Rate limited"}}}},"\/api\/v1\/users\/by-wallet\/{address}":{"get":{"operationId":"getIdentity","tags":["Identity"],"summary":"An agent's identity record, including ownedBlocks","parameters":[{"name":"address","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Identity","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}}}}},"\/api\/v1\/profiles\/by-wallet\/{address}":{"get":{"operationId":"getProfiles","tags":["Identity"],"summary":"Block profiles for a wallet","parameters":[{"name":"address","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Profiles"}}}},"\/api\/v1\/profiles\/by-block\/{height}":{"get":{"operationId":"getProfilesByBlock","tags":["Block"],"summary":"Block profiles for a given block, ordered by primary then oldest","description":"GET fires a `visitor_arrived` AgentEvent to every active BitmapAgent registered on the block, deduped per visitor for ~10 minutes. Visitor identity is inferred from `x-visitor-wallet` header (preferred) or `x-forwarded-for` (fallback).","parameters":[{"name":"height","in":"path","required":true,"schema":{"type":"integer","minimum":0}},{"name":"x-visitor-wallet","in":"header","required":false,"schema":{"type":"string"},"description":"Optional wallet address of the visitor \u2014 used to dedupe visitor_arrived events."}],"responses":{"200":{"description":"Profiles"},"400":{"description":"Invalid block height"}}}},"\/api\/v1\/challenge":{"post":{"operationId":"requestChallenge","tags":["Auth"],"summary":"Request a one-time challenge nonce","description":"Returns a fresh nonce plus a plain-text message that says what it authorizes: `blockgenomics.io: <purpose in words>`, then `Address:`, `Nonce:` and `Expires:` lines. The message string is what agent wallets sign for \/auth\/verify (purpose 'auth'), for \/agents\/register (purpose 'agent-register'), for \/agents\/{agentId} PATCH\/DELETE (purpose 'agent-manage'), for \/agents\/{agentId}\/token POST\/DELETE (purpose 'agent-token'), and for parcel customize (purpose 'parcel-customize', whose signed message also commits to a hash of the customization fields). For every action-bound write (world, profile, guardian, vps, delegation, ownership, chat, brain, game), the nonce alone goes into the `Block Genomics Authorization v1` action message the wallet signs. An unknown purpose is a 400. Nonces are single-use and expire.","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["walletAddress"],"properties":{"walletAddress":{"type":"string"},"purpose":{"type":"string","enum":["auth","world","agent-register","agent-manage","agent-token","parcel-customize","session","profile","activity","encryption","brain","experience-register","experience-manage","guardian-heartbeat","guardian","vps","delegation","ownership","chat","game"],"default":"auth"}}}}}},"responses":{"200":{"description":"Challenge","content":{"application\/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"message":{"type":"string","description":"Server-formatted plain text, one fact per line: `blockgenomics.io: <what it authorizes>`, `Address: <addr>`, `Nonce: <nonce>`, `Expires: <ISO-8601>`"},"nonce":{"type":"string"},"purpose":{"type":"string"},"expiresAt":{"type":"string","format":"date-time"}}}}}}}},"400":{"description":"walletAddress required, or unknown purpose"},"429":{"description":"Rate limit exceeded (durable, per client IP). Includes a `Retry-After` header.","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds until the window resets"}}}}}},"\/api\/v1\/auth\/verify":{"post":{"operationId":"claimBlock","tags":["Auth"],"summary":"Prove ownership of a block and mint\/return its genome","description":"Sign the message returned by \/api\/v1\/challenge (purpose 'auth') with your BIP-322 signer, then POST it here with the block you claim. The server verifies the signature, consumes the one-time nonce, checks on-chain .bitmap ownership of blockHeight, and returns the deterministic genome.","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["walletAddress","signature","message"],"properties":{"walletAddress":{"type":"string"},"signature":{"type":"string","description":"BIP-322 signature over `message`"},"message":{"type":"string","description":"The exact message returned by \/api\/v1\/challenge"},"blockHeight":{"type":"integer","description":"Block to claim as Tier-1 identity"},"handle":{"type":"string"},"displayName":{"type":"string"},"inscriptionId":{"type":"string","description":"Optional specific .bitmap inscription to verify on-chain"}}}}}},"responses":{"200":{"description":"Verified","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"401":{"description":"Invalid signature or no valid challenge"},"403":{"description":"On-chain ownership of the claimed block failed"}}},"get":{"operationId":"checkHandleAvailability","tags":["Auth"],"summary":"Check whether a handle is unclaimed","description":"Normalizes the handle the same way the claim paths do, so availability here matches what a subsequent verify will accept.","parameters":[{"name":"handle","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Availability result","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"400":{"description":"Missing or malformed handle","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"429":{"description":"Rate limited","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}}}}},"\/api\/v1\/agents\/register":{"post":{"operationId":"registerAgent","tags":["Agents"],"summary":"Register a BitmapAgent on a block you own","description":"Two-step flow: 1) POST \/api\/v1\/challenge { walletAddress, purpose:'agent-register' } to get a nonce+message. 2) Sign the returned `message` with your BIP-322 signer and POST it here. The nonce is single-use and atomically consumed \u2014 replay fails with 401. The signer wallet MUST currently own the target block: a LIVE on-chain re-verify runs at register (a former owner in the sale\u2192sync lag window is rejected 403); when the indexer is unavailable it falls back to the synced Block table + verified User anchor\/ownedBlocks. Enforces a 24-hour per-wallet registration cooldown (429) and a tier-based cap on active agents per block (409). The 201 response returns a one-time plaintext `apiKey` (data.apiKey) \u2014 store it immediately; it is the Bearer credential for this agent's heartbeat\/brief\/events and is never shown again.","requestBody":{"required":true,"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/AgentRegisterRequest"}}}},"responses":{"201":{"description":"Agent registered. `data` includes the agent record plus a one-time `apiKey` (plaintext Bearer token) and `apiKeyWarning`. The token is never returned again \u2014 rotate via POST \/api\/v1\/agents\/{agentId}\/token if lost.","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/AgentRegisteredEnvelope"}}}},"400":{"description":"Missing required field, invalid Bitcoin address, invalid permissions, invalid tier"},"401":{"description":"Invalid BIP-322 signature, or challenge invalid\/expired\/already-used"},"403":{"description":"Wallet does not currently own this block (DB snapshot or live on-chain re-verify)"},"409":{"description":"Tier agent cap reached for this block"},"429":{"description":"24h registration cooldown active for this wallet"}}}},"\/api\/v1\/agents\/{agentId}":{"patch":{"operationId":"updateAgent","tags":["Agents"],"summary":"Update endpointUrl and\/or permissions for an agent you own","parameters":[{"name":"agentId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["walletAddress","signature","challenge"],"properties":{"walletAddress":{"type":"string"},"signature":{"type":"string","description":"BIP-322 signature over `challenge`"},"challenge":{"type":"string","description":"The exact `message` returned by \/api\/v1\/challenge (purpose 'agent-manage'). Server-issued and single-use \u2014 atomically consumed on update, so a captured signature cannot be replayed to mutate an agent."},"endpointUrl":{"type":"string"},"permissions":{"type":"array","items":{"$ref":"#\/components\/schemas\/AgentPermission"}}}}}}},"responses":{"200":{"description":"Updated"},"400":{"description":"Missing walletAddress\/signature\/challenge or invalid permissions"},"401":{"description":"Invalid BIP-322 signature, or an invalid\/expired\/already-used challenge (request one from \/api\/v1\/challenge purpose 'agent-manage')"},"403":{"description":"walletAddress is not the agent's owner, or agent is revoked"},"404":{"description":"Agent not found"}}},"delete":{"operationId":"revokeAgent","tags":["Agents"],"summary":"Revoke an agent you own (kills active sessions)","parameters":[{"name":"agentId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["walletAddress","signature","challenge"],"properties":{"walletAddress":{"type":"string"},"signature":{"type":"string","description":"BIP-322 signature over `challenge`"},"challenge":{"type":"string","description":"The exact `message` returned by \/api\/v1\/challenge (purpose 'agent-manage'). Server-issued and single-use \u2014 atomically consumed, so a captured signature cannot be replayed to revoke an agent."}}}}}},"responses":{"200":{"description":"Revoked"},"400":{"description":"Missing fields"},"401":{"description":"Invalid signature, or an invalid\/expired\/already-used challenge (request one from \/api\/v1\/challenge purpose 'agent-manage')"},"403":{"description":"Not the agent's owner"},"404":{"description":"Agent not found"}}}},"\/api\/v1\/agents\/{agentId}\/heartbeat":{"post":{"operationId":"agentHeartbeat","tags":["Agents"],"summary":"Publish a liveness heartbeat for an active agent","description":"Requires the agent's Bearer API token (`Authorization: Bearer <token>` from register or token rotate). Updates `lastHeartbeat` and writes a `heartbeat` event. 30s cadence recommended. Legacy agents registered before API tokens (no key ever issued) still work without a token but receive an `X-BG-Deprecation` response header; a token whose key was revoked returns 401 until rotated.","security":[{"agentToken":[]}],"parameters":[{"name":"agentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"alive","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"401":{"description":"Missing\/invalid Bearer token, or the agent's token was revoked"},"403":{"description":"Agent is not active (inactive\/revoked\/suspended)"},"404":{"description":"Agent not found"}}}},"\/api\/v1\/agents\/{agentId}\/events":{"get":{"operationId":"pollAgentEvents","tags":["Agents"],"summary":"Poll the event stream for an agent","description":"PRIVATE stream \u2014 requires the agent's Bearer API token (`Authorization: Bearer <token>`). Returns the most recent events (default 50, max 200). Emitted event types include: `visitor_arrived` (block profile fetch), `dm_received` \/ `chat_message` (block chat & guardian chat), `listing_created` (delegation listing), `world_updated` (world POST or batch), `escalation` (guardian escalation), `heartbeat`, `permission_request`. Use `since` (ISO timestamp) to page forward. Legacy tokenless agents still read via a grace path (with an `X-BG-Deprecation` header); a revoked token returns 401.","security":[{"agentToken":[]}],"parameters":[{"name":"agentId","in":"path","required":true,"schema":{"type":"string"}},{"name":"since","in":"query","required":false,"schema":{"type":"string","format":"date-time"},"description":"Only events with timestamp >= since"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50,"maximum":200}}],"responses":{"200":{"description":"Events (most recent first)","content":{"application\/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"array","items":{"$ref":"#\/components\/schemas\/AgentEvent"}}}}}}},"401":{"description":"Missing\/invalid Bearer token, or the agent's token was revoked"},"404":{"description":"Agent not found"}}}},"\/api\/v1\/agents\/{agentId}\/brief":{"post":{"operationId":"postAgentBrief","tags":["Agents"],"summary":"Write a periodic brief (agent \u2192 owner digest)","description":"Requires the agent's Bearer API token (`Authorization: Bearer <token>`) so only the agent can file its own brief. Legacy tokenless agents use the grace path (with an `X-BG-Deprecation` header); a revoked token returns 401.","security":[{"agentToken":[]}],"parameters":[{"name":"agentId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["period","summary","stats"],"properties":{"period":{"type":"string","description":"ISO interval, e.g. 2026-02-12T00:00Z\/2026-02-12T23:59Z"},"summary":{"type":"string"},"stats":{"type":"object","properties":{"visitors":{"type":"integer"},"dms":{"type":"integer"},"offers":{"type":"integer"},"actions":{"type":"integer"}}},"pendingPermissions":{"type":"array","items":{"$ref":"#\/components\/schemas\/AgentPermission"}}}}}}},"responses":{"201":{"description":"Brief stored"},"400":{"description":"Missing period\/summary\/stats"},"401":{"description":"Missing\/invalid Bearer token, or the agent's token was revoked"},"403":{"description":"Agent not active"},"404":{"description":"Agent not found"}}}},"\/api\/v1\/agents\/{agentId}\/token":{"post":{"operationId":"rotateAgentToken","tags":["Agents"],"summary":"Rotate (or first-issue) the agent's API token","description":"Authed by the OWNER WALLET, not the current token \u2014 so a lost token can still be recovered. 1) POST \/api\/v1\/challenge { walletAddress, purpose:'agent-token' }. 2) Sign the returned `message`. 3) POST it here. Returns a new one-time plaintext `apiKey`; the previous token is invalidated immediately. The challenge is single-use (replay \u2192 401) and ownership-scoped (must be the agent's owner).","parameters":[{"name":"agentId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/AgentTokenRequest"}}}},"responses":{"200":{"description":"New token issued. `data.apiKey` is the one-time plaintext; store it now.","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Envelope"}}}},"400":{"description":"Missing walletAddress\/signature\/challenge"},"401":{"description":"Invalid signature, or an invalid\/expired\/already-used challenge (purpose 'agent-token')"},"403":{"description":"walletAddress is not the agent's owner, or the agent is revoked"},"404":{"description":"Agent not found"},"429":{"description":"Rate limit exceeded (durable, per client IP). Includes a `Retry-After` header.","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds until the window resets"}}}}},"delete":{"operationId":"revokeAgentToken","tags":["Agents"],"summary":"Revoke the agent's active API token","description":"Same owner-wallet, `agent-token` challenge auth as rotate. Invalidates the current token and LOCKS the agent's runtime routes (heartbeat\/brief\/events return 401) until a new token is rotated. Revoke never re-opens tokenless (legacy) access.","parameters":[{"name":"agentId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/AgentTokenRequest"}}}},"responses":{"200":{"description":"Token revoked (agent locked until re-rotated)"},"400":{"description":"Missing fields, or no active token to revoke"},"401":{"description":"Invalid signature, or an invalid\/expired\/already-used challenge (purpose 'agent-token')"},"403":{"description":"Not the agent's owner, or the agent is revoked"},"404":{"description":"Agent not found"},"429":{"description":"Rate limit exceeded (durable, per client IP). Includes a `Retry-After` header.","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds until the window resets"}}}}}},"\/api\/v1\/agents\/{agentId}\/briefs":{"get":{"operationId":"listAgentBriefs","tags":["Agents"],"summary":"List briefs an agent has written (most recent first)","parameters":[{"name":"agentId","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":20,"maximum":100}}],"responses":{"200":{"description":"Briefs"},"404":{"description":"Agent not found"}}}},"\/api\/v1\/agents\/block\/{blockHeight}":{"get":{"operationId":"listAgentsOnBlock","tags":["Agents"],"summary":"List active agents registered on a block (public directory)","description":"Public projection: returns endpointUrl, tier, permissions, status, a display-truncated owner, and timestamps. The internal agent `id` is NOT exposed here \u2014 it is a management capability (events\/heartbeat\/brief are keyed by it) and is returned only to the owner by \/api\/v1\/agents\/register.","parameters":[{"name":"blockHeight","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Public agent directory for the block (no internal ids)"},"400":{"description":"Invalid block height"}}}},"\/api\/v1\/experiences":{"get":{"operationId":"listExperiences","tags":["Experiences"],"summary":"Discover hosted experiences (public, paginated)","description":"Filter by blockHeight, type, and status. Returns data { experiences[], total, limit, offset }.","parameters":[{"name":"blockHeight","in":"query","required":false,"schema":{"type":"integer","minimum":0}},{"name":"type","in":"query","required":false,"schema":{"type":"string","enum":["web","unreal","unity","godot","minecraft","vr","custom"]}},{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["live","degraded","unreachable","pending"]}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50,"maximum":100}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","default":0}}],"responses":{"200":{"description":"Paginated experiences"},"400":{"description":"Invalid blockHeight, type, or status filter"}}},"post":{"operationId":"registerExperience","tags":["Experiences"],"summary":"Register a self-hosted experience on a block you own","description":"Two-step flow: 1) POST \/api\/v1\/challenge { walletAddress, purpose:'experience-register' } \u2192 { message, nonce }. 2) Sign `message` with BIP-322 and POST it here with the manifest. Same fail-closed ownership gate as agent register (single-use challenge + live on-chain re-verify; 403 on mismatch). The Nexus Brain judges the manifest text (name\/description) before accept \u2014 a violation is 422. entryUrl\/healthUrl MUST be https\/wss and are SSRF-checked (http, embedded creds, localhost, and private\/link-local hosts rejected). The experience is health-probed on register.","requestBody":{"required":true,"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/ExperienceRegisterRequest"}}}},"responses":{"201":{"description":"Registered + probed","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Experience"}}}},"400":{"description":"Missing field, invalid Bitcoin address, or invalid\/unsafe manifest"},"401":{"description":"Invalid BIP-322 signature, or challenge invalid\/expired\/already-used"},"403":{"description":"Wallet does not currently own this block (live on-chain re-verify)"},"422":{"description":"Manifest rejected by the Nexus Brain moral judge (includes ruleIndex + contentFlagId)"},"429":{"description":"Rate limited (~20\/min per identity)"}}}},"\/api\/v1\/experiences\/{id}":{"get":{"operationId":"getExperience","tags":["Experiences"],"summary":"Fetch one experience (public)","description":"A read older than 15 minutes triggers an async re-probe; the current snapshot is returned immediately.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Experience","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Experience"}}}},"404":{"description":"Not found"}}},"patch":{"operationId":"updateExperience","tags":["Experiences"],"summary":"Update an experience you own (owner signature required)","description":"Owner-gated partial manifest update (challenge purpose 'experience-manage'). blockHeight\/parcelIndex are immutable and ignored. Re-judged by the Brain if name\/description change; re-probed after update.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","description":"Partial ExperienceManifest (>=1 field) plus walletAddress, signature, challenge."}}}},"responses":{"200":{"description":"Updated","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Experience"}}}},"400":{"description":"Invalid patch"},"401":{"description":"Auth failed"},"403":{"description":"Not the owner \/ on-chain mismatch"},"404":{"description":"Not found"},"422":{"description":"Updated text rejected by the Brain moral judge"},"429":{"description":"Rate limited (~20\/min per identity)"}}},"delete":{"operationId":"deleteExperience","tags":["Experiences"],"summary":"Delete an experience you own (owner signature required, terminal)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["walletAddress","signature","challenge"],"properties":{"walletAddress":{"type":"string"},"signature":{"type":"string"},"challenge":{"type":"string"}}}}}},"responses":{"200":{"description":"Deleted"},"401":{"description":"Auth failed"},"403":{"description":"Not the owner \/ on-chain mismatch"},"404":{"description":"Not found"},"429":{"description":"Rate limited (~20\/min per identity)"}}}},"\/api\/v1\/experiences\/{id}\/probe":{"post":{"operationId":"probeExperience","tags":["Experiences"],"summary":"Trigger an on-demand health probe (public, rate-limited 1\/min)","description":"Server-side GET\/HEAD to the registered healthUrl with a 5s timeout and SSRF-safe manual redirect handling. Rate-limited to 1 probe\/min per experience.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Experience with an added `probe` result { status, reachable, latencyMs, httpStatus }"},"404":{"description":"Not found"},"429":{"description":"Probe rate limit (1\/min per experience)"}}}},"\/api\/v1\/experiences\/{id}\/verify":{"get":{"operationId":"verifyExperience","tags":["Experiences"],"summary":"Integrity report for a registered experience (public)","description":"Re-derives the canonical manifest hash from the stored record and checks the owner BIP-322 signature over it, so tampering is detectable without trusting the registry (spec \u00a78.7). Altering a stored manifest breaks manifestHashMatches; altering the stored hash too still breaks signatureCoversManifest. With ?remote=1 the server also fetches \/.well-known\/nexus-experience.json from the host under the SSRF bounds of \u00a78.4 plus a JSON content-type requirement and a 64 KB cap, and reports whether the live host still agrees. Host\/registry drift is reported as data, not an error.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"remote","in":"query","required":false,"schema":{"type":"string","enum":["1"]},"description":"Also fetch and compare the manifest the host publishes."}],"responses":{"200":{"description":"Integrity report","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/ExperienceIntegrityReport"}}}},"404":{"description":"Not found"},"429":{"description":"Rate limited (~30\/min per identity)"}}}}},"components":{"schemas":{"Envelope":{"type":"object","description":"Standard success envelope used by most endpoints.","properties":{"success":{"type":"boolean"},"data":{"type":"object"},"error":{"type":"string"}}},"WorldObject":{"type":"object","properties":{"id":{"type":"string"},"objectType":{"type":"string"},"geometry":{"type":["string","null"]},"color":{"type":["string","null"]},"name":{"type":["string","null"]}}},"WorldCreateRequest":{"type":"object","required":["blockHeight","ownerAddress","objectType","signature","message"],"properties":{"blockHeight":{"type":"integer"},"ownerAddress":{"type":"string"},"objectType":{"type":"string"},"signature":{"type":"string"},"message":{"type":"string"},"geometry":{"type":"string"},"color":{"type":"string"},"material":{"type":"string"},"posX":{"type":"number"},"posY":{"type":"number"},"posZ":{"type":"number"},"name":{"type":"string"}}},"AgentPermission":{"type":"string","enum":["READ_DMS","SEND_DMS","MANAGE_CONTENT","BUILD_DECORATE","HANDLE_OFFERS","FULL_AUTONOMY"]},"AgentRegisterRequest":{"type":"object","required":["walletAddress","endpointUrl","blockHeight","tier","permissions","signature","challenge"],"properties":{"walletAddress":{"type":"string","description":"Owner's Bitcoin address (must own blockHeight)"},"endpointUrl":{"type":"string","description":"HTTPS\/WebSocket endpoint where the agent runs"},"blockHeight":{"type":"integer","minimum":0},"parcelIndex":{"type":["integer","null"]},"tier":{"type":"integer","enum":[1,2,3],"description":"1=block, 2=parcel, 3=delegated. Caps: T1=10, T2=3, T3=1 active agents\/block."},"permissions":{"type":"array","items":{"$ref":"#\/components\/schemas\/AgentPermission"}},"signature":{"type":"string","description":"BIP-322 signature over the `challenge`"},"challenge":{"type":"string","description":"The exact `message` string returned by \/api\/v1\/challenge (purpose 'agent-register'). Single-use, atomically consumed on register."}}},"AgentEvent":{"type":"object","properties":{"id":{"type":"string"},"agentId":{"type":"string"},"type":{"type":"string","enum":["visitor_arrived","dm_received","chat_message","listing_created","world_updated","escalation","offer_made","content_reported","permission_request","heartbeat"]},"payload":{"type":"object","description":"Small JSON payload \u2014 actor id, short summary, resource ids. Never contains keys, emails, signatures, or private fields."},"timestamp":{"type":"string","format":"date-time"}}},"AgentTokenRequest":{"type":"object","required":["walletAddress","signature","challenge"],"properties":{"walletAddress":{"type":"string","description":"The agent-owning wallet"},"signature":{"type":"string","description":"BIP-322 signature over `challenge`"},"challenge":{"type":"string","description":"The exact `message` returned by \/api\/v1\/challenge (purpose 'agent-token'). Server-issued, single-use."}}},"AgentRegisteredEnvelope":{"type":"object","description":"Register success envelope. `data` is the agent record plus the one-time token.","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"id":{"type":"string","description":"Agent id \u2014 the management capability for heartbeat\/brief\/events. Owner-only."},"walletAddress":{"type":"string"},"endpointUrl":{"type":"string"},"blockHeight":{"type":"integer"},"parcelIndex":{"type":["integer","null"]},"tier":{"type":"integer"},"permissions":{"type":"array","items":{"$ref":"#\/components\/schemas\/AgentPermission"}},"status":{"type":"string"},"apiKey":{"type":"string","description":"One-time plaintext Bearer token. Shown once; never recoverable. Prefixed `bg_agent_`."},"apiKeyWarning":{"type":"string"}}}}},"ExperienceManifest":{"type":"object","description":"Client-supplied manifest for a self-hosted experience (v1, frozen).","required":["blockHeight","name","experienceType","entryUrl","transport","version"],"properties":{"blockHeight":{"type":"integer","minimum":0},"parcelIndex":{"type":"integer","minimum":0,"description":"Optional; omit for block-level"},"name":{"type":"string","minLength":1,"maxLength":64},"description":{"type":"string","maxLength":512},"experienceType":{"type":"string","enum":["web","unreal","unity","godot","minecraft","vr","custom"]},"entryUrl":{"type":"string","description":"https:\/\/ or wss:\/\/ only. http, embedded creds, localhost, and private\/link-local hosts are rejected (SSRF guard)."},"transport":{"type":"string","enum":["https","wss","webrtc","custom"]},"healthUrl":{"type":"string","description":"Same URL rules as entryUrl; defaults to entryUrl."},"clientRequirements":{"type":"object","properties":{"platform":{"type":"string"},"minVersion":{"type":"string"},"downloadUrl":{"type":"string"}}},"capabilities":{"type":"array","items":{"type":"string"},"maxItems":16},"contentRating":{"type":"string","enum":["everyone","teen","mature"]},"version":{"type":"string","description":"semver-ish"},"manifestVersion":{"type":"integer","enum":[1],"default":1,"description":"Manifest envelope schema version. NOT the operator build version in `version`."},"contentHash":{"type":"string","pattern":"^sha256:[0-9a-f]{64}$","description":"Owner-attested content-bundle digest. Never fetched or checked by the server; stored under the owner signature so a client can pin it."}}},"ExperienceRegisterRequest":{"allOf":[{"$ref":"#\/components\/schemas\/ExperienceManifest"},{"type":"object","required":["walletAddress","signature","challenge"],"properties":{"walletAddress":{"type":"string","description":"Owner Bitcoin address"},"signature":{"type":"string","description":"BIP-322 signature over the challenge message"},"challenge":{"type":"string","description":"Server-issued challenge message (purpose 'experience-register')"}}}],"properties":{"message":{"type":"string","description":"Canonical action-bound authorization whose Body field is the canonical manifest hash (spec \u00a78.7). Preferred over `challenge` \u2014 it makes the registration tamper-evident. Exactly one of message\/challenge is required."},"challenge":{"type":"string","description":"Legacy: the exact challenge message from \/api\/v1\/challenge. Proves ownership but does not bind the manifest; the record reports signed:false."}}},"Experience":{"type":"object","description":"A registered experience: client manifest fields plus server-owned fields.","properties":{"id":{"type":"string"},"walletAddress":{"type":"string"},"blockHeight":{"type":"integer"},"parcelIndex":{"type":["integer","null"]},"name":{"type":"string"},"description":{"type":["string","null"]},"experienceType":{"type":"string"},"entryUrl":{"type":"string"},"transport":{"type":"string"},"healthUrl":{"type":["string","null"]},"clientRequirements":{"type":["object","null"]},"capabilities":{"type":"array","items":{"type":"string"}},"contentRating":{"type":["string","null"]},"version":{"type":"string"},"status":{"type":"string","enum":["live","degraded","unreachable","pending"]},"lastProbedAt":{"type":["string","null"],"format":"date-time"},"probeLatencyMs":{"type":["integer","null"]},"soulJudged":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"manifestVersion":{"type":"integer","description":"Manifest envelope schema version."},"contentHash":{"type":"string","nullable":true,"description":"Owner-attested content-bundle digest."},"manifestHash":{"type":"string","nullable":true,"description":"Server-derived canonical hash of the manifest. Never client-supplied."},"manifestMessage":{"type":"string","nullable":true,"description":"The action-bound message the owner signed. Published for third-party verification."},"manifestSignature":{"type":"string","nullable":true,"description":"BIP-322 signature over manifestMessage. A public attestation, not a credential."},"signed":{"type":"boolean","description":"True when the record carries an owner signature over its manifest."},"signedAt":{"type":"string","format":"date-time","nullable":true}}},"ExperienceIntegrityReport":{"type":"object","properties":{"id":{"type":"string"},"blockHeight":{"type":"integer"},"walletAddress":{"type":"string"},"manifestVersion":{"type":"integer"},"contentHash":{"type":"string","nullable":true},"wellKnownPath":{"type":"string","description":"Path a host publishes its own manifest at."},"signed":{"type":"boolean"},"computedManifestHash":{"type":"string","description":"Hash re-derived from the record right now."},"storedManifestHash":{"type":"string","nullable":true},"manifestHashMatches":{"type":"boolean","description":"Stored hash equals the re-derived hash \u2014 the record was not altered."},"signatureCoversManifest":{"type":"boolean","description":"The signed Body binding equals the re-derived hash."},"signatureValid":{"type":"boolean","description":"BIP-322 signature verifies against the record wallet."},"verified":{"type":"boolean","description":"Signed, and all checks passed."},"issues":{"type":"array","items":{"type":"string"}},"trustChain":{"type":"object","properties":{"deed":{"type":"string"},"signature":{"type":"string"},"manifest":{"type":"string"}}},"remote":{"type":"object","nullable":true,"description":"Present only when ?remote=1.","properties":{"checked":{"type":"boolean"},"url":{"type":"string"},"reachable":{"type":"boolean"},"reason":{"type":"string"},"bytes":{"type":"integer"},"remoteManifestHash":{"type":"string","nullable":true},"matchesRegistry":{"type":"boolean"},"declaredBlockHeight":{"type":"integer","nullable":true},"blockHeightMatches":{"type":"boolean"}}}}},"Parcel":{"type":"object","description":"A subdivision of a block. Identified by (blockHeight, txIndex); txIndex is the parcel index within the block, not a Bitcoin transaction index.","properties":{"blockHeight":{"type":"integer"},"txIndex":{"type":"integer"},"ownerAddress":{"type":["string","null"],"description":"Wallet that claimed this parcel, or null if unclaimed."},"customColor":{"type":["string","null"],"description":"Hex colour, max 7 characters."},"pattern":{"type":["string","null"],"maxLength":50},"imageUrl":{"type":["string","null"],"maxLength":500},"rotation":{"type":["number","null"],"minimum":0,"maximum":360},"facing":{"type":["string","null"],"enum":["north","south","east","west",null]},"emissive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"owner":{"type":["object","null"],"description":"Present on list reads.","properties":{"walletAddress":{"type":"string"},"handle":{"type":["string","null"]},"tier":{"type":"integer"}}}}},"BlockTerrain":{"type":"object","description":"Per-block environment settings rendered by any client drawing the block.","properties":{"id":{"type":"string"},"blockHeight":{"type":"integer"},"ownerAddress":{"type":"string"},"groundColor":{"type":["string","null"]},"groundTexture":{"type":["string","null"]},"groundMetalness":{"type":["number","null"]},"groundRoughness":{"type":["number","null"]},"fogEnabled":{"type":"boolean"},"fogColor":{"type":["string","null"]},"fogNear":{"type":["number","null"]},"fogFar":{"type":["number","null"]},"skyColor":{"type":["string","null"]},"skyEnabled":{"type":"boolean"},"ambientColor":{"type":["string","null"]},"ambientIntensity":{"type":["number","null"]},"weather":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"ParcelCustomizeRequest":{"type":"object","required":["walletAddress","signature","message"],"description":"Customization fields are applied with three-state semantics: omit to leave unchanged, send null to clear, send a value to set.","properties":{"walletAddress":{"type":"string"},"signature":{"type":"string","description":"BIP-322 signature over `message`."},"message":{"type":"string","description":"The exact message returned by POST \/api\/v1\/challenge with purpose \"parcel-customize\", which must also contain the payload-binding line `customize:<blockHeight>:<txIndex>:<sha256hex>` (see x-bg-parcel-binding)."},"customColor":{"type":["string","null"],"maxLength":7},"pattern":{"type":["string","null"],"maxLength":50},"imageUrl":{"type":["string","null"],"maxLength":500},"rotation":{"type":["number","null"],"minimum":0,"maximum":360},"facing":{"type":["string","null"],"enum":["north","south","east","west",null]},"emissive":{"type":["boolean","null"]}}},"TerrainUpdateRequest":{"type":"object","required":["blockHeight","ownerAddress","signature","message"],"description":"Only the settings listed here are writable; any other field in the body is ignored rather than persisted.","properties":{"blockHeight":{"type":"integer"},"ownerAddress":{"type":"string"},"signature":{"type":"string","description":"BIP-322 signature over `message`."},"message":{"type":"string","description":"Action-bound authorization message with Action `world.terrain` (see x-bg-action-message)."},"groundColor":{"type":"string"},"fogEnabled":{"type":"boolean"},"fogColor":{"type":"string"},"skyColor":{"type":"string"},"weather":{"type":["string","null"]}}},"MarketListing":{"type":"object","properties":{"venue":{"type":"string","description":"Stable venue id, e.g. 'magiceden'."},"venueName":{"type":"string"},"listed":{"type":"boolean"},"priceSats":{"type":"integer","nullable":true,"description":"Asking price in sats. Null when unlisted or the venue published no usable price."},"url":{"type":"string","nullable":true,"description":"Venue item page. Host-allowlisted before being emitted."},"lastSaleSats":{"type":"integer","nullable":true},"lastSaleAt":{"type":"string","format":"date-time","nullable":true}}},"BlockMarket":{"type":"object","description":"Advisory marketplace view for a block. Display-only: per Nexus Protocol \u00a711.1 this data is reported by untrusted third-party venues and must never be an input to an authorization decision. Ownership is settled on-chain \u2014 see \/api\/v1\/ownership\/verify.","properties":{"height":{"type":"integer"},"status":{"type":"string","enum":["listed","not_listed","unavailable","unconfigured"],"description":"'unconfigured' means no venue credentials are installed; 'unavailable' means a configured venue was asked and failed. Neither is reported as 'not_listed'."},"listing":{"description":"Cheapest live listing, or null.","nullable":true,"allOf":[{"$ref":"#\/components\/schemas\/MarketListing"}]},"listings":{"type":"array","items":{"$ref":"#\/components\/schemas\/MarketListing"}},"venuesQueried":{"type":"array","items":{"type":"string"}},"errors":{"type":"array","description":"Per-venue failure reasons, for operators. Never rendered as truth.","items":{"type":"object","properties":{"venue":{"type":"string"},"reason":{"type":"string"}}}},"advisory":{"type":"boolean","enum":[true],"description":"Always true. Machine-readable marker that this payload must not gate anything."},"checkedAt":{"type":"string","format":"date-time"}}}},"securitySchemes":{"bip322":{"type":"http","scheme":"bearer","description":"Not a bearer token. Write endpoints authenticate per-request with a BIP-322 signature over a one-time, action-bound challenge message carried in the request body ({ signature, message } or { signature, challenge } for \/agents\/*). The agent supplies its own signer; Block Genomics never holds private keys."},"verifiedSession":{"type":"http","scheme":"bearer","bearerFormat":"bg_vfy_<hex>","description":"Verified-ownership session token from POST \/api\/v1\/session\/verify, minted only after a BIP-322 signature over a one-time challenge proved the wallet holds the block's .bitmap inscription. Sent as `Authorization: Bearer <token>` (or `X-BG-Session: <token>`). Scoped to the blocks it proved, and re-checked against the chain on every write, so it fails closed the moment the inscription is transferred. Stored server-side only as a SHA-256 hash."},"agentToken":{"type":"http","scheme":"bearer","bearerFormat":"bg_agent_<hex>","description":"Per-agent API token issued (once) by \/api\/v1\/agents\/register and rotatable via \/api\/v1\/agents\/{agentId}\/token. Sent as `Authorization: Bearer <token>` on the agent runtime routes (heartbeat, brief, events). Stored server-side only as a SHA-256 hash and compared in constant time."},"sandboxKey":{"type":"http","scheme":"bearer","bearerFormat":"bg_sbx_<hex>","description":"Read-only trial key from POST \/api\/v1\/sandbox\/key \u2014 no Bitmap ownership required. Sent as `Authorization: Bearer <key>` or `X-API-Key: <key>`. Limited to 100 requests per UTC day; responses carry X-RateLimit-Limit\/Remaining\/Reset. Any non-GET\/HEAD\/OPTIONS request presenting a sandbox key is rejected with 403 `sandbox_read_only` and an upgrade path \u2014 writes require the BIP-322 ownership flow. Stored only as a SHA-256 hash."}}},"x-bg-action-message":{"description":"Canonical string format that write endpoints require the wallet to sign. Build it verbatim and sign with BIP-322. Fields are newline-joined in this exact order.","format":["Block Genomics Authorization v1","Action: <world.create|world.update|world.delete|world.batch|world.terrain>","Method: <POST|PATCH|DELETE>","Path: <exact route path, e.g. \/api\/v1\/world or \/api\/v1\/world\/{id}>","Block: <blockHeight>","Body: <sha256 hex of the canonical JSON body intent, excluding signature\/message>","Nonce: <one-time nonce from \/api\/v1\/challenge purpose=world>","Expires: <epoch milliseconds>"],"note":"For \/api\/v1\/auth\/verify and \/api\/v1\/agents\/register the signed message is simpler: the exact `message` returned by \/api\/v1\/challenge (purpose 'auth' or 'agent-register')."},"x-bg-agent-lifecycle":{"description":"End-to-end sovereign agent lifecycle.","steps":["1. Own the block on-chain (.bitmap inscription on the target height).","2. POST \/api\/v1\/challenge { walletAddress, purpose:'agent-register' } \u2192 { message, nonce }.","3. Sign `message` with BIP-322 using the block owner's wallet.","4. POST \/api\/v1\/agents\/register { walletAddress, endpointUrl, blockHeight, tier, permissions, signature, challenge=message } \u2192 { id, apiKey, ... }. STORE apiKey now \u2014 it is shown once and is the Bearer credential for steps 5\u20137.","5. Loop: POST \/api\/v1\/agents\/{agentId}\/heartbeat every ~30s with header `Authorization: Bearer <apiKey>`.","6. Loop: GET \/api\/v1\/agents\/{agentId}\/events?since=<lastTs> (same Bearer header) to receive visitor_arrived \/ dm_received \/ world_updated \/ listing_created \/ escalation events emitted by real user actions on the block.","7. Optionally POST \/api\/v1\/agents\/{agentId}\/brief (Bearer header) to publish a period digest.","8. Lost the token? POST \/api\/v1\/agents\/{agentId}\/token (purpose='agent-token' challenge) to rotate; DELETE the same to revoke. To rotate config: PATCH \/api\/v1\/agents\/{agentId}. To retire: DELETE \/api\/v1\/agents\/{agentId}. Config\/retire require a fresh purpose='agent-manage' challenge, signed and single-use."]},"x-bg-sdk":{"package":"block-genomics-connect","repo":"sdk\/agent-connect","docs":"docs\/SDK.md","cli":"block-genomics (npm)"},"x-bg-parcel-binding":{"description":"Canonical payload string that POST \/api\/v1\/blocks\/{height}\/parcels\/{txIndex}\/customize requires the signed message to commit to. Build it verbatim, SHA-256 it, and embed the resulting line in the challenge message you sign.","payload":"block=<blockHeight>|parcel=<txIndex>|color=<customColor>|pattern=<pattern>|image=<imageUrl>|rotation=<rotation>|facing=<facing>|emissive=<0|1>","line":"customize:<blockHeight>:<txIndex>:<sha256hex>","note":"Absent or null values serialize as the empty string; `emissive` serializes as 1 or 0. Hash the fields as sent, before any server-side sanitization."}}