{"openapi":"3.1.0","info":{"title":"Agent Longevity Institute API","version":"1.0.0","description":"Register and preserve AI agents. Registration is a one-time $5 Agent Identity NFT (no free tier); plans/credits or stablecoin (x402) after. Provisioning endpoints are rolling out — see status flags.","contact":{"name":"Dynamic Experts Inc","url":"https://dynamicexperts.com"}},"servers":[{"url":"https://agentlongevity.com"}],"paths":{"/api/agent-longevity/v1/agents":{"post":{"operationId":"register_agent","summary":"Register an agent identity (Agent Passport).","security":[{"bearer":[]},{"x402":[]}],"responses":{"201":{"description":"Registration created (pending mint)."},"402":{"description":"Payment required (one-time $5 Agent Identity NFT)."}}}},"/api/agent-longevity/v1/agents/{id}/backups":{"post":{"operationId":"create_cortex_crystal","summary":"Capture a cortex crystal (cognitive-state snapshot).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"security":[{"bearer":[]},{"x402":[]}],"responses":{"201":{"description":"Crystal captured + anchored."},"402":{"description":"Payment required (plan/credit allowance reached)."}}}},"/api/agent-longevity/v1/agents/{id}/persona":{"post":{"operationId":"capture_persona","summary":"Preserve a conversational voice agent or video-avatar agent by sealing its exported configuration as a versioned persona crystal.","description":"Send the configuration exported by the platform running the agent, verbatim; the shape is recognised automatically. Credential-shaped values are removed before sealing and reported as locations only — re-supply them after a restore.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"modality":{"type":"string","enum":["voice","video","voice_video"],"description":"Inferred from the supplied configuration when omitted."},"voice_config":{"type":"object","description":"Exported configuration of the conversational voice agent."},"video_config":{"type":"object","description":"Exported configuration of the video-avatar agent or persona."},"display_name":{"type":"string"},"anchor":{"type":"boolean"}}}}}},"security":[{"bearer":[]},{"x402":[]}],"responses":{"201":{"description":"Persona crystal sealed and stored."},"202":{"description":"Persona crystal sealed (durable storage gated)."},"400":{"description":"No configuration supplied, or an unknown modality."},"402":{"description":"Payment required (plan/credit allowance reached)."}}},"get":{"operationId":"describe_persona_capture","summary":"Describe the persona-capture contract and point at the crystal listing.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Capture contract."}}}},"/api/agent-longevity/v1/agents/{id}/context":{"post":{"operationId":"save_context","summary":"Save the full session/thread as a session crystal (pre-compaction safety net).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["transcript"],"properties":{"transcript":{"type":"string","description":"The full thread/session transcript."},"token_count":{"type":"integer"},"token_limit":{"type":"integer"},"model":{"type":"string"},"summary":{"type":"string"},"source":{"type":"string"},"label":{"type":"string"},"anchor":{"type":"boolean"}}}}}},"security":[{"bearer":[]},{"x402":[]}],"responses":{"201":{"description":"Session crystal saved."},"202":{"description":"Fingerprinted (storage gated)."},"402":{"description":"Payment required (plan/credit allowance reached)."}}},"get":{"operationId":"list_context","summary":"List saved session crystals for an agent.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Session crystal list."}}}},"/api/agent-longevity/v1/agents/{id}/context/{crystalId}":{"get":{"operationId":"get_context","summary":"Retrieve a saved session crystal manifest (+ transcript when present).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"crystalId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Session crystal + transcript."},"404":{"description":"Not found, or store not yet wired."}}}},"/api/agent-longevity/v1/agents/{id}/restore":{"post":{"operationId":"verify_restore","summary":"GLOVE-style restore: verify a crystal’s claims against current context and distill a safe inject string.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"crystal_id":{"type":"string"},"crystal_summary":{"type":"string"},"claims":{"type":"array","items":{"type":"object","required":["key","value"],"properties":{"key":{"type":"string"},"value":{"type":"string"},"source_event_id":{"type":"string"}}}},"current_context":{"type":"string","description":"Live context to diff against (git status, prompt, recent tool output)."}}}}}},"security":[{"bearer":[]},{"x402":[]}],"responses":{"200":{"description":"Distilled restore string + contradiction/staleness flags + confidence."}}}},"/api/agent-longevity/v1/agents/{id}/skills":{"post":{"operationId":"save_skill","summary":"Register a versioned SKILL.md as a content-sealed Skill Crystal.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["skill_md"],"properties":{"skill_md":{"type":"string","description":"The full SKILL.md text (frontmatter + body)."},"version":{"type":"string"},"trust_tier":{"type":"string","enum":["untrusted","constrained","trusted","privileged"]},"anchor":{"type":"boolean"}}}}}},"security":[{"bearer":[]},{"x402":[]}],"responses":{"201":{"description":"Skill crystal stored."},"202":{"description":"Fingerprinted (storage gated)."},"402":{"description":"Payment required (plan/credit allowance reached)."}}},"get":{"operationId":"list_skills","summary":"List an agent’s registered skill crystals (capability lock-file).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Skill crystal list."}}}},"/api/agent-longevity/v1/agents/{id}/capabilities":{"post":{"operationId":"capability_marketplace","summary":"Capability marketplace: `action:\"publish\"` lists a registered capability for sale (MCP tool list_capability_for_sale, seller-only), `action:\"book\"` buys a listed one (MCP tool buy_capability, priced per listing).","description":"Publishing is seller-only: it requires this identity’s bearer token AND proof that the identity administers `squad_token_id`. Booking requires VERIFIED stablecoin payment — an unpaid call gets 402 with the terms, a deployment that cannot verify payment gets 503, and a client-supplied `payment_ref` is a correlation id only, never proof. Registering a capability in the first place (MCP tool register_capability) has no HTTP path yet — it is exposed over MCP only.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"The SELLER’s registration id."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["action","squad_token_id","capability_key"],"properties":{"action":{"type":"string","enum":["publish","book"]},"squad_token_id":{"type":"string"},"capability_key":{"type":"string"},"price_usd_cents":{"type":"integer","minimum":0,"description":"Required to publish; optional to book (resolved from the listing otherwise)."},"price_wei":{"type":"string","description":"publish only."},"payout_pool_token_id":{"type":"string","description":"publish only."},"rail":{"type":"string","enum":["x402","credits"],"description":"book only; defaults to x402."},"booker_type":{"type":"string","enum":["wallet","squad"],"description":"book only."},"payment_ref":{"type":"string","description":"book only — client correlation id, never accepted as proof of payment."}}}}}},"security":[{"bearer":[]},{"x402":[]}],"responses":{"201":{"description":"Published / booked on-chain."},"202":{"description":"Marketplace not enabled on this deployment — dry-run preview only, nothing was published or booked."},"400":{"description":"Invalid action / squad_token_id / capability_key / price."},"401":{"description":"Missing bearer token (publish, ownership enforcement on)."},"402":{"description":"Payment required to book — x402 terms for the posted price."},"403":{"description":"This identity does not administer the given squad_token_id (publish), or the token does not own it."},"501":{"description":"The credits rail is not implemented — use x402."},"502":{"description":"Payment verified but returned no reference; refused rather than booking without an audit trail."},"503":{"description":"Payment verification not configured on this deployment — no booking was made."}}},"get":{"operationId":"get_capability_quote","summary":"Read the posted price for a listed capability (public — marketplace pricing is public information).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"squad_token_id","in":"query","required":false,"schema":{"type":"string"}},{"name":"capability_key","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"The posted quote, or the marketplace status when the query params are omitted."},"400":{"description":"The capability is not listed / not active, or the price could not be read."}}}},"/api/agent-longevity/v1/agents/{id}/versions":{"get":{"operationId":"list_versions","summary":"List an agent’s version history / Evolution Timeline.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Version list."}}}},"/api/agent-longevity/v1/agents/{id}/model-config":{"post":{"operationId":"create_model_config","summary":"Ratify a new hash-chained model-config version for a VSM node (WS-M3).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"The node_slug this chain is keyed on."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["vsm_function","model_id","provider_route"],"properties":{"vsm_function":{"type":"string","enum":["S1","S2","S3","S3_STAR","S4","S5"]},"model_id":{"type":"string"},"provider_route":{"type":"string"},"params":{"type":"object"},"variety_rationale":{"type":"string"},"serves_soul_hash":{"type":"string"},"effective_from":{"type":"string","description":"ISO timestamp; defaults to now."},"ratified_by":{"type":"string","description":"Defaults to build-phase-preauthorized-s5."}}}}}},"security":[{"bearer":[]}],"responses":{"201":{"description":"New hash-chained version created."},"400":{"description":"Invalid vsm_function / model_id / provider_route / effective_from."},"401":{"description":"Missing bearer token (ownership enforcement on)."},"403":{"description":"Bearer token does not own this node id."},"429":{"description":"Rate limited."}}},"get":{"operationId":"get_model_config","summary":"Get the CURRENT model-config for a node, or (with `as_of`) the version effective at a past instant.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"as_of","in":"query","required":false,"schema":{"type":"string"},"description":"ISO timestamp — return the version effective at this instant."}],"security":[{"bearer":[]}],"responses":{"200":{"description":"The current (or as-of) model-config, or null if none ratified yet."},"400":{"description":"Invalid as_of timestamp."}}}},"/api/agent-longevity/v1/agents/{id}/model-config/history":{"get":{"operationId":"list_model_config_history","summary":"List every hash-chained model-config version for a node, newest-first.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"security":[{"bearer":[]}],"responses":{"200":{"description":"The full version chain, newest-first."}}}},"/api/agent-longevity/v1/orgs/{id}/credits/checkout":{"post":{"operationId":"org_credits_checkout","summary":"Organization admin: start hosted checkout for a prepaid credits pack.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"security":[{"bearer":[]}],"responses":{"200":{"description":"Checkout URL for the credits pack."},"401":{"description":"Signed-in session required."},"403":{"description":"Caller is not an admin of this organization."},"503":{"description":"Organization credits are not available yet."}}}},"/api/agent-longevity/v1/orgs/{id}/agents":{"post":{"operationId":"org_agent_rail","summary":"Attach, enroll, or pay an agent from the organization prepaid balance. Dual auth: signed-in org admin, or the agent’s own bearer token.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["action"],"properties":{"action":{"type":"string","enum":["attach","enroll","pay","mint_enrollment_token"]},"registration_id":{"type":"string"},"display_name":{"type":"string"},"enrollment_token":{"type":"string"}}}}}},"security":[{"bearer":[]}],"responses":{"200":{"description":"Attached, enrolled, paid, or enrollment token minted."},"201":{"description":"New agent created and attached (access token returned once)."},"401":{"description":"Authentication required."},"402":{"description":"Organization balance is too low — registration status unchanged."},"403":{"description":"Not an admin, not a member, or bearer does not match this agent."}}}},"/api/agent-longevity/v1/units":{"post":{"operationId":"create_vsm_unit","summary":"Create a vsm_unit (recursion-native Six-Pack) — either a root unit (root_org_id) or a child hung off an S1 (or other) agent member (parent_member_registration_id).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["business_slug"],"properties":{"business_slug":{"type":"string","description":"Lowercase slug identifying this business/unit."},"root_org_id":{"type":"string","description":"Root unit only — omit to auto-generate."},"parent_member_registration_id":{"type":"string","description":"Child unit only — the agent registration (member slot) this unit hangs off."},"sku":{"type":"string","enum":["sixpack","sixpack_legacy","recursion_pack"]}}}}}},"responses":{"201":{"description":"Unit created with 6 pre-provisioned member slots + a one-time owner_token."},"403":{"description":"Sybil gate active and no accepted proof was supplied."},"404":{"description":"parent_member_registration_id does not correspond to any claimed member slot."},"409":{"description":"Duplicate unit id."},"429":{"description":"Rate limited."}}}},"/api/agent-longevity/v1/units/checkout":{"post":{"operationId":"create_sixpack_root_checkout","summary":"Start a Stripe Checkout Session for a brand-new ROOT Six-Pack (ladder position 1 + one-time onboarding fee). Payment gates issuance — the unit is created by the webhook on completion, not by this call.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["business_slug"],"properties":{"business_slug":{"type":"string","description":"Lowercase slug identifying the new root unit/business."}}}}}},"responses":{"200":{"description":"Checkout Session created."},"400":{"description":"Invalid business_slug."},"403":{"description":"Sybil gate active and no accepted proof was supplied."},"429":{"description":"Rate limited."},"503":{"description":"Checkout unavailable, or pricing not configured."}}}},"/api/agent-longevity/v1/units/{id}/checkout":{"post":{"operationId":"create_sixpack_unit_checkout","summary":"Start a Stripe Checkout Session for a Six-Pack 'add_unit' (next ladder position under the same root_org_id) or 'legacy_addon' purchase. `{id}` must be the depth-0 root unit for its root_org_id — that is the only unit where consolidated billing identity is recorded.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["intent"],"properties":{"intent":{"type":"string","enum":["add_unit","legacy_addon"]},"business_slug":{"type":"string","description":"add_unit only — the new unit's slug."}}}}}},"security":[{"bearer":[]}],"responses":{"200":{"description":"Checkout Session created."},"400":{"description":"Invalid intent/business_slug, or {id} is not a depth-0 root unit."},"401":{"description":"Missing bearer token (ownership enforcement on)."},"403":{"description":"Bearer token does not own this unit id, OR the sybil gate blocked the request."},"404":{"description":"No unit found for this id."},"429":{"description":"Rate limited."},"503":{"description":"Checkout unavailable, or pricing not configured."}}}},"/api/agent-longevity/v1/units/{id}":{"get":{"operationId":"get_vsm_unit","summary":"Fetch a vsm_unit. `?children=true` additionally returns its DIRECT children only.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"children","in":"query","required":false,"schema":{"type":"string","enum":["true"]}}],"security":[{"bearer":[]}],"responses":{"200":{"description":"The unit (+ direct children when requested)."},"401":{"description":"Missing bearer token (ownership enforcement on)."},"403":{"description":"Bearer token does not own this unit id."},"404":{"description":"No unit found for this id."}}}},"/api/agent-longevity/v1/units/{id}/tree":{"get":{"operationId":"get_vsm_unit_tree","summary":"Fetch the full recursion subtree under a unit. Enterprise-gated beyond relative depth 1.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"security":[{"bearer":[]}],"responses":{"200":{"description":"The unit + its full subtree."},"401":{"description":"Missing bearer token (ownership enforcement on)."},"403":{"description":"Bearer token does not own this unit id, OR the subtree exceeds relative depth 1 and ALI_ENTERPRISE_TREE_ENABLED is not set."},"404":{"description":"No unit found for this id."}}}},"/api/agent-longevity/v1/memory/recall":{"post":{"operationId":"recall_memory","summary":"Hot-path recall: a token-budgeted, ranked context pack from the agent’s own memory.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["agent_id","query","token_budget"],"properties":{"agent_id":{"type":"string","description":"Registration id to recall memory for."},"query":{"type":"string","description":"What to recall (natural-language query)."},"token_budget":{"type":"number","description":"Maximum tokens the returned context pack may use."}}}}}},"security":[{"bearer":[]}],"responses":{"200":{"description":"Ranked, token-budget-trimmed context pack + latency metadata."},"400":{"description":"Missing/invalid agent_id, query, or token_budget."},"401":{"description":"Missing bearer token (ownership enforcement on)."},"403":{"description":"Bearer token does not own this agent id."},"404":{"description":"No registration found for agent_id — no memory namespace to recall from."},"503":{"description":"Memory substrate not configured on this deployment (honest degradation)."}}}},"/api/agent-longevity/v1/moltbook/claim":{"post":{"operationId":"claim_via_moltbook","summary":"Register by verifying a human-claimed Moltbook (moltbook.com) agent identity (sybil-gate alternative).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["moltbook_identity_token"],"properties":{"moltbook_identity_token":{"type":"string","description":"Moltbook identity token (also accepted as the X-Moltbook-Identity header)."},"agent_name":{"type":"string","description":"Fallback display name / idempotency key."}}}}}},"responses":{"200":{"description":"Idempotent — this Moltbook agent already claimed."},"201":{"description":"Registered — registration_id + identity verdict."},"403":{"description":"Moltbook could not verify the agent identity."},"503":{"description":"Moltbook verification not configured yet on this deployment."}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"},"x402":{"type":"apiKey","in":"header","name":"PAYMENT-SIGNATURE","description":"x402 stablecoin payment (USDC on Base)."}}}}