{"info":{"title":"Polygraph gateway","version":"0.1.0"},"openapi":"3.1.0","paths":{"/offers":{"get":{"summary":"List signed offers","responses":{"200":{"description":"Array of signed offers","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","description":"A signed offer: the seller's manifest, a compact EdDSA JWS over its canonical JSON, and the seller's public key as a JWK.","required":["manifest","jws","publicKey"],"properties":{"manifest":{"type":"object"},"jws":{"type":"string"},"publicKey":{"type":"object"}}}}}}}}}},"/offers/{id}":{"get":{"summary":"Get one signed offer","parameters":[{"name":"id","in":"path","required":true,"description":"offerId from the manifest","schema":{"type":"string"}}],"responses":{"200":{"description":"Signed offer","content":{"application/json":{"schema":{"type":"object","description":"A signed offer: the seller's manifest, a compact EdDSA JWS over its canonical JSON, and the seller's public key as a JWK.","required":["manifest","jws","publicKey"],"properties":{"manifest":{"type":"object"},"jws":{"type":"string"},"publicKey":{"type":"object"}}}}}},"404":{"description":"No such offer"}}}},"/offers/{id}/inspect":{"get":{"summary":"Get a short-lived CreateOS token for the offer's paused parent sandbox, to check its egress and status before paying. Revoked about 60 s after it is issued; the next inspect replaces it.","parameters":[{"name":"id","in":"path","required":true,"description":"offerId from the manifest","schema":{"type":"string"}}],"responses":{"200":{"description":"Inspection token","content":{"application/json":{"schema":{"type":"object","properties":{"parentSandboxId":{"type":"string"},"token":{"type":"string"},"platformUrl":{"type":"string"},"expiresAt":{"type":"string","format":"date-time","description":"The token is revoked about this time, or earlier if another inspect of the same offer replaces it."}}}}}},"404":{"description":"No such offer"},"429":{"description":"Rate limited, per client address and per offer; see Retry-After"},"502":{"description":"CreateOS did not issue a token"}}}},"/purchases/{id}/refund":{"post":{"summary":"Ask for a refund. The gateway re-checks the worker's lineage, egress and tool digest itself and refunds only if one fails and no job input has been uploaded; the worker is then destroyed.","parameters":[{"name":"id","in":"path","required":true,"description":"purchaseId from the purchase grant","schema":{"type":"string"}},{"name":"x-purchase-secret","in":"header","required":true,"description":"purchaseSecret from the purchase grant","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string"}}}}}},"responses":{"200":{"description":"A check failed; refunded","content":{"application/json":{"schema":{"type":"object","properties":{"refunded":{"const":true},"refundId":{"type":"string"},"checks":{"type":"array","description":"The gateway's own checks of the worker, made with the owner key","items":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"status":{"enum":["pass","fail"]},"detail":{"type":"string"}}}}}}}}},"401":{"description":"Missing or wrong purchase secret"},"404":{"description":"No such purchase"},"409":{"description":"Not refunded: every check passed, a job already started, or the purchase is not active","content":{"application/json":{"schema":{"type":"object","properties":{"refunded":{"const":false},"error":{"type":"string"},"checks":{"type":"array","description":"The gateway's own checks of the worker, made with the owner key","items":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"status":{"enum":["pass","fail"]},"detail":{"type":"string"}}}}}}}}},"502":{"description":"The worker could not be checked, or Stripe refused the refund"}}}},"/purchases/{id}/done":{"post":{"summary":"Destroy the purchase's worker after the job","parameters":[{"name":"id","in":"path","required":true,"description":"purchaseId from the purchase grant","schema":{"type":"string"}},{"name":"x-purchase-secret","in":"header","required":true,"description":"purchaseSecret from the purchase grant","schema":{"type":"string"}}],"responses":{"200":{"description":"Worker destroyed"},"401":{"description":"Missing or wrong purchase secret"},"404":{"description":"No such purchase"}}}},"/events":{"get":{"summary":"Server-Sent Events feed; replays the last 200 events, then streams","responses":{"200":{"description":"text/event-stream"}}},"post":{"summary":"Add an event to the feed","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["type"],"properties":{"type":{"type":"string"}}}}}},"responses":{"202":{"description":"Accepted"},"400":{"description":"Not an event"}}}},"/offers/{id}/buy":{"post":{"responses":{"200":{"description":"Purchase grant, with a Payment-Receipt header","content":{"application/json":{"schema":{"type":"object","required":["purchaseId","offerId","workerSandboxId","workerToken","platformUrl","paymentIntentId","expiresAt","purchaseSecret"],"properties":{"purchaseId":{"type":"string"},"offerId":{"type":"string"},"workerSandboxId":{"type":"string","description":"Worker forked from the offer's parent for this purchase only."},"workerToken":{"type":"string","description":"CreateOS access token scoped to that worker."},"platformUrl":{"type":"string"},"paymentIntentId":{"type":"string"},"expiresAt":{"type":"string","format":"date-time"},"purchaseSecret":{"type":"string","description":"Send as the x-purchase-secret header to refund and done. Returned only here."}}}}}},"402":{"description":"Payment Required"},"404":{"description":"No such offer"},"502":{"description":"The worker could not be created; the payment was refunded"},"503":{"description":"The worker did not start in time; the payment was refunded and the worker is kept for a retry after Retry-After"}},"x-payment-info":{"offers":[{"amount":"50","currency":"usd","description":"One job in a fresh worker forked from the offer's verified parent sandbox","intent":"charge","method":"stripe"}]},"summary":"Pay for one job and receive a fresh worker forked from the offer's parent sandbox. The amount is the offer's priceUsd; the 402 challenge is authoritative.","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","description":"No body is needed; the offer is named in the path."}}}},"parameters":[{"name":"id","in":"path","required":true,"description":"offerId from the manifest","schema":{"type":"string"}}]}}},"x-service-info":{"categories":["compute","documents"],"docs":{"homepage":"https://production-polygraph.tyzo.nodeops.app","llms":"https://production-polygraph.tyzo.nodeops.app/llms.txt"}},"servers":[{"url":"https://production-polygraph.tyzo.nodeops.app"}]}