{"openapi":"3.1.0","info":{"title":"Subpay Document Reading API","version":"1.0.0","summary":"Construction pay applications and change orders from PDF to JSON, pay per read.","description":"Reads construction pay applications (AIA G702/G703, Procore, Textura) and change orders into structured JSON, with arithmetic checks. $0.20 in USDC per successful read over x402 on Base or Solana; no account or API key. Requests with HTTP status 400 or above are not charged. Documents are not stored. Output is automated — verify against the document before relying on it.","termsOfService":"https://subpay.ai/api-terms","contact":{"email":"support@subpay.ai","url":"https://subpay.ai/developers"}},"externalDocs":{"url":"https://subpay.ai/developers"},"servers":[{"url":"https://subpay.ai"}],"security":[],"x-x402":{"price":"$0.20","asset":"USDC","scheme":"exact","networks":["eip155:8453","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],"chargedOn":"HTTP status below 400 only"},"paths":{"/api/v1/extract":{"get":{"operationId":"describeService","summary":"Describe the service, price, and payment networks (free).","responses":{"200":{"description":"Service description.","content":{"application/json":{"schema":{"type":"object"}}}}}},"post":{"operationId":"extractDocument","summary":"Read a pay application or change order PDF into JSON ($0.20 USDC via x402).","description":"Without payment the response is 402 with x402 payment requirements; an x402 client pays and retries. Optional `subcontractor` and `gc` query parameters (or JSON fields) name the parties.","parameters":[{"name":"subcontractor","in":"query","required":false,"schema":{"type":"string"},"description":"Subcontractor company name."},{"name":"gc","in":"query","required":false,"schema":{"type":"string"},"description":"General contractor name."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["document"],"properties":{"document":{"type":"string","contentEncoding":"base64","description":"The PDF, base64-encoded. Max 4 MB decoded."},"fileName":{"type":"string"},"subcontractor":{"type":"string"},"gc":{"type":"string"}}}},"application/pdf":{"schema":{"type":"string","contentMediaType":"application/pdf"}},"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","contentMediaType":"application/pdf"}}}}}},"responses":{"200":{"description":"The read. Charged.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadResult"}}}},"400":{"$ref":"#/components/responses/NotCharged"},"402":{"description":"Payment required. The base64 `PAYMENT-REQUIRED` header carries the x402 payment requirements (price, networks, asset, receiving address).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"$ref":"#/components/responses/NotCharged"},"415":{"$ref":"#/components/responses/NotCharged"},"502":{"$ref":"#/components/responses/NotCharged"},"503":{"$ref":"#/components/responses/NotCharged"}}}}},"components":{"responses":{"NotCharged":{"description":"Request failed; the payment is not settled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]},"Check":{"type":"object","properties":{"name":{"type":"string"},"passed":{"type":["boolean","null"]},"detail":{"type":"string"}},"required":["name","passed","detail"]},"PayApplication":{"type":"object","properties":{"documentType":{"const":"PAY_APPLICATION"},"applicationNumber":{"type":["string","null"]},"periodTo":{"type":["string","null"],"format":"date"},"grossThisPeriod":{"type":["number","null"]},"retainageHeldToDate":{"type":["number","null"]},"retainageReleasedThisPeriod":{"type":["number","null"]},"retainageRatePercent":{"type":["number","null"]},"totalCompletedAndStoredToDate":{"type":["number","null"]},"contractSumToDate":{"type":["number","null"]},"balanceToFinishIncludingRetainage":{"type":["number","null"]},"currentPaymentDue":{"type":["number","null"]},"changeOrders":{"type":"array","items":{"type":"object","properties":{"number":{"type":["string","null"]},"reference":{"type":["string","null"]},"description":{"type":["string","null"]},"amount":{"type":["number","null"]}}}}},"required":["documentType"]},"ChangeOrder":{"type":"object","properties":{"documentType":{"const":"CHANGE_ORDER"},"kind":{"enum":["SUBCONTRACTOR_REQUEST","GC_CHANGE_ORDER"]},"issuer":{"type":["string","null"]},"number":{"type":["string","null"]},"description":{"type":["string","null"]},"amount":{"type":["number","null"]},"date":{"type":["string","null"],"format":"date"}},"required":["documentType","kind"]},"ReadResult":{"type":"object","properties":{"document":{"oneOf":[{"$ref":"#/components/schemas/PayApplication"},{"$ref":"#/components/schemas/ChangeOrder"}]},"checks":{"type":"array","items":{"$ref":"#/components/schemas/Check"}},"warnings":{"type":"array","items":{"type":"string"}},"confidence":{"type":"number","minimum":0,"maximum":1}},"required":["document","checks","warnings","confidence"]}}}}