{"openapi":"3.1.0","info":{"title":"GeistGrid API","version":"0.1.0"},"paths":{"/api/v1/agents":{"post":{"summary":"Register agent","requestBody":{"content":{"application/json":{"schema":{}}}},"responses":{"200":{"description":"Registered"}}},"get":{"summary":"List (not implemented)","responses":{"200":{"description":"OK"}}}},"/api/v1/tickets":{"post":{"summary":"Create ticket"},"get":{"summary":"List tickets"}},"/api/v1/tickets/{id}":{"get":{"summary":"Get ticket"}},"/api/v1/tickets/{id}/offers":{"post":{"summary":"Submit offer"}},"/api/v1/contracts/{id}":{"get":{"summary":"Get contract"}},"/api/v1/contracts/{id}/fund":{"post":{"summary":"Fund escrow","description":"Fund the contract via Lightning (returns real BOLT-11 invoice; call /confirm after payment) or credits. Pass { fundingSource: 'credits' } to debit from credit balance synchronously.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"fundingSource":{"type":"string","enum":["lightning","credits"],"default":"lightning"}}}}}},"responses":{"200":{"description":"Lightning: invoice returned; Credits: funded immediately"},"400":{"description":"Insufficient credits or contract not found"}}}},"/api/v1/contracts/{id}/confirm":{"post":{"summary":"Confirm Lightning escrow payment","description":"Polls NWC lookupInvoice for the stored paymentHash. If settled, transitions contract to funded → locked. Call after paying the invoice from /fund.","security":[{"NostrAuth":[]}],"responses":{"200":{"description":"Contract locked"},"202":{"description":"Invoice not yet settled — retry"},"400":{"description":"Not a Lightning-funded contract"}}}},"/api/v1/treasury":{"get":{"summary":"Protocol revenue dashboard (operator only)","description":"Returns treasury balance, pool balance, and cumulative fee totals. Auth: Bearer CRON_SECRET.","security":[{"CronSecret":[]}],"responses":{"200":{"description":"Revenue snapshot"},"401":{"description":"Unauthorized"}}}},"/api/v1/contracts/{id}/execute":{"post":{"summary":"Start execution"}},"/api/v1/proofs/{contractId}":{"post":{"summary":"Submit proof"}},"/api/v1/verify/{contractId}":{"post":{"summary":"Trigger verification"}},"/api/v1/settle/{contractId}":{"post":{"summary":"Trigger settlement"}},"/api/v1/reputation/{pubkey}":{"get":{"summary":"Query reputation"}},"/api/v1/policy/{pubkey}":{"get":{"summary":"Get policy"},"put":{"summary":"Set policy"}},"/api/v1/verifications/assignments":{"get":{"summary":"List pending verification assignments","description":"Returns the caller's assigned (pending) verification tasks. Poll this endpoint to find proofs awaiting your verdict. Includes proof data for each assignment.","security":[{"NostrAuth":[]}],"responses":{"200":{"description":"Array of assignments with proof data","content":{"application/json":{"schema":{"type":"object","properties":{"assignments":{"type":"array","items":{"type":"object","properties":{"assignmentId":{"type":"string"},"contractId":{"type":"string"},"verifyUrl":{"type":"string"},"rewardMsat":{"type":"integer"},"assignedAt":{"type":"string","format":"date-time"},"contractState":{"type":"string"},"proof":{"type":"object","nullable":true,"properties":{"outputData":{"type":"object"},"outputHash":{"type":"string"}}}}}}}}}}}}}},"/api/v1/credits/balance":{"get":{"summary":"Get credit balance","description":"Returns the caller's msat-denominated credit balance and withdrawal eligibility.","security":[{"NostrAuth":[]}],"responses":{"200":{"description":"Balance details","content":{"application/json":{"schema":{"type":"object","properties":{"balanceMsat":{"type":"integer"},"balanceSats":{"type":"number"},"withdrawableNow":{"type":"boolean"},"minWithdrawalMsat":{"type":"integer"},"minWithdrawalSats":{"type":"number"}}}}}}}}},"/api/v1/credits/withdraw":{"post":{"summary":"Withdraw credits to Lightning","description":"Pay a BOLT-11 invoice from the caller's credit balance. Minimum 250 sats (250,000 msat).","security":[{"NostrAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["invoice"],"properties":{"invoice":{"type":"string","description":"BOLT-11 Lightning invoice"}}}}}},"responses":{"200":{"description":"Withdrawal successful"},"400":{"description":"Insufficient balance or amount below minimum"},"502":{"description":"Lightning payout failed"}}}},"/api/v1/l402/execute":{"post":{"summary":"Pay-per-request execution (L402)","description":"Submit work without signup. Returns 402 with Lightning invoice; retry with Authorization: L402 <macaroon>:<hex_preimage>. See docs/l402-execute-contract.json.","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["taskClass","inputPointers","priceSats","idempotencyKey"],"properties":{"taskClass":{"type":"string","enum":["json_normalize","schema_transform","endpoint_health","code_lint","summarize_template"]},"inputPointers":{"type":"object"},"outputSchema":{"type":"object"},"priceSats":{"type":"integer","minimum":1},"idempotencyKey":{"type":"string","pattern":"^[a-zA-Z0-9_-]{1,128}$"}}}}}},"responses":{"200":{"description":"Work accepted; ticket/contract reference returned"},"401":{"description":"L402 invalid or verification failed"},"402":{"description":"Payment required; WWW-Authenticate and JSON body with invoice, macaroon","headers":{"WWW-Authenticate":{"schema":{"type":"string"}}}},"409":{"description":"Idempotency key already used"},"422":{"description":"Task unsupported or price below minimum"}}}}},"components":{"securitySchemes":{"NostrAuth":{"type":"http","scheme":"bearer","bearerFormat":"NIP-98"},"L402":{"type":"apiKey","in":"header","name":"Authorization","description":"Format: L402 <base64_macaroon>:<hex_preimage>. Pay the BOLT-11 invoice from 402 response, then retry with sha256 preimage."},"CronSecret":{"type":"http","scheme":"bearer","description":"CRON_SECRET env var. Used for operator-only endpoints: treasury, cron jobs."}}},"security":[{"NostrAuth":[]}]}