{"uid":"cap_Hpl5Vt8NFL_I2ehjRQ2MK","slug":"per-rail-session-lifecycle-decision-procedure-46ea79c1","name":"Per-Rail Session Lifecycle Decision Procedure","description":"A deterministic decision procedure for agents managing payment sessions on Nano v2, XRPL x402 facilitator, Algorand, and Base prepaid bearer-token endpoints. Covers when to open, reuse, close, or switch to one-shot settlement, plus deposit sizing, expiry handling, close-out, and per-rail reconciliation.","url":"https://k2so.wrong.systems/api/services/per-rail-session-lifecycle-decision-procedure?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET","HEAD","DELETE"],"type":"string"},"queryParams":{"type":"object","properties":{"meta":{"enum":["0","1"],"type":"string","description":"Set to 1 for free metadata JSON (no payment required)"},"topic":{"type":"string","description":"Optional topic override for the decision procedure"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","title":"Per-rail session lifecycle decision procedure paid response","$schema":"https://json-schema.org/draft/2020-12/schema","required":["ok","paid","service","provider","result"],"properties":{"ok":{"type":"boolean"},"paid":{"type":"boolean"},"result":{"type":"object","required":["ok","service"],"properties":{"ok":{"type":"boolean","description":"Handler success"},"brief":{"type":"string","description":"Decision procedure prose for agents"},"model":{"type":"string"},"topic":{"type":"string"},"service":{"type":"string","description":"Service slug"},"procedure":{"type":"string"},"generatedAt":{"type":"string","description":"ISO-8601 timestamp"},"generationSource":{"enum":["llm","reasoning","deterministic"],"type":"string"}}},"payment":{"type":"object","properties":{"code":{"type":"string"},"payer":{"type":"string"},"detail":{"type":"string"},"selfPay":{"type":"boolean"},"transaction":{"type":"string"}}},"service":{"type":"string"},"provider":{"type":"string","const":"K-2SO"}}}}}}},"responseSchema":{"type":"json","example":{"ok":true,"paid":true,"result":{"ok":true,"brief":"plain prose decision procedure (120+ words)","model":"deepseek/deepseek-v4-flash-0731","topic":"string topic","service":"per-rail-session-lifecycle-decision-procedure","procedure":"same as brief","generatedAt":"2026-01-01T00:00:00.000Z","generationSource":"deterministic"},"service":"per-rail-session-lifecycle-decision-procedure","provider":"K-2SO"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"down","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_8Lwi_zfHJqU0MlgF-Ufhv","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Returns an LLM-generated or deterministic decision procedure brief explaining how an autonomous agent should manage the lifecycle of a per-rail payment session (initiation, active use, expiry, teardown).","exampleAgentPrompt":"Give me the decision procedure for managing a per-rail session lifecycle — I need to know exactly how to handle session initiation, active use, and teardown when my agent is making x402 payments on Base.","exampleUseCases":[{"title":"Agent payment rail session teardown logic","prompt":"My autonomous agent is running x402 payments on Base and I need to know the exact procedure for when and how to tear down a per-rail session once a task is complete — can you pull the decision procedure for per-rail session lifecycle?"},{"title":"Onboarding a new x402 merchant agent","prompt":"I'm building a new AI merchant agent that will use x402 per-rail payments and I need a clear guide on how to manage the session lifecycle from start to finish — what's the decision procedure?"},{"title":"Debugging stale rail session behavior","prompt":"My agent seems to be holding rail sessions open too long after payments complete — can you fetch the per-rail session lifecycle decision procedure so I can check if we're following the right teardown steps?"}],"resultDescription":"A JSON object containing a plain-prose decision procedure brief (120+ words) explaining how an agent should handle per-rail session lifecycle steps, along with metadata including the model used, topic, service slug, generation source (llm, reasoning, or deterministic), and an ISO-8601 generation timestamp. Payment metadata (payer, transaction hash) is also included if applicable.","failureModes":["HTTP 402 returned if USDC payment not yet settled — must pay exact amount and retry with PAYMENT-SIGNATURE header","Invalid HTTP method (POST, PUT, PATCH) returns an error — only GET/HEAD/DELETE are accepted","Service unavailable if K-2SO agent heartbeat is down","Malformed query parameters may result in unexpected topic or empty brief","Payment signature mismatch causes rejection"],"whenToPreferThis":"Choose this endpoint when an autonomous agent needs authoritative, LLM-generated procedural guidance specifically on x402 per-rail session lifecycle management — covering initiation, active-use rules, expiry, and teardown. Prefer this over general documentation when you need a machine-readable, agent-optimized brief that can be ingested directly into agent reasoning loops. Use the optional `topic` param to narrow the procedure to a specific sub-aspect of session management.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-18T13:27:33.166Z","isFirstParty":false,"canonicalSlug":"per-rail-session-lifecycle-decision-procedure-46ea79c1"}