{"openapi":"3.1.0","info":{"title":"CEMFORGE Datapacks Agent API","version":"0.3.0","summary":"Checkout, activation, account, and prediction endpoints for CEMFORGE Datapacks.","description":"Agent-readable API contract for purchasing prepaid CEMFORGE prediction units, activating access after compliance attestation, and requesting Open3DCP-aligned synthetic prediction outputs.","contact":{"name":"Sunnyday Technologies LLC","email":"support@sunn3d.com"}},"servers":[{"url":"https://datapacks.cemforge.ai"}],"externalDocs":{"description":"Agent integration guide","url":"https://datapacks.cemforge.ai/agent-integration.md"},"tags":[{"name":"Discovery","description":"Machine-readable discovery surfaces."},{"name":"Checkout","description":"Server-created Stripe Checkout Sessions."},{"name":"Activation","description":"Compliance attestation and one-time API key minting."},{"name":"Prediction","description":"Prepaid Open3DCP-aligned synthetic prediction service."}],"paths":{"/agents.json":{"get":{"tags":["Discovery"],"summary":"Machine-readable CEMFORGE Datapacks offer feed for agents.","operationId":"getAgentOfferFeed","responses":{"200":{"description":"Offer feed with checkout, activation, prediction, and protocol status.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentOfferFeed"}}}}}}},"/.well-known/agent-offers.json":{"get":{"tags":["Discovery"],"summary":"Well-known alias for the agent offer feed.","operationId":"getWellKnownAgentOfferFeed","responses":{"200":{"description":"Same payload as /agents.json.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentOfferFeed"}}}}}}},"/openapi.json":{"get":{"tags":["Discovery"],"summary":"OpenAPI description for agent integration.","operationId":"getOpenApiSpec","responses":{"200":{"description":"OpenAPI 3.1 JSON document.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/agent-integration.md":{"get":{"tags":["Discovery"],"summary":"Markdown guide for buyer-authorized agent integration.","operationId":"getAgentIntegrationGuide","responses":{"200":{"description":"Markdown guide.","content":{"text/markdown":{"schema":{"type":"string"}}}}}}},"/health":{"get":{"tags":["Discovery"],"summary":"Worker health and upstream reachability.","operationId":"getHealth","responses":{"200":{"description":"Health response.","content":{"application/json":{"schema":{"type":"object","required":["status","version","schema_version","model_version","upstream"],"properties":{"status":{"type":"string","enum":["ok"]},"version":{"type":"string"},"schema_version":{"type":"string"},"model_version":{"type":"string"},"upstream":{"type":"object"}}}}}}}}},"/v1/checkout/session":{"post":{"tags":["Checkout"],"summary":"Create a Stripe Checkout Session for a CEMFORGE Datapack.","operationId":"createCheckoutSession","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutSessionRequest"},"examples":{"starter10":{"value":{"package_id":"starter_10","customer_email":"buyer@example.com","terms_accepted":true,"privacy_accepted":true,"refund_policy_accepted":true,"export_terms_accepted":true}}}}}},"responses":{"201":{"description":"Checkout Session created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutSessionResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"503":{"$ref":"#/components/responses/Unavailable"}}}},"/v1/activate":{"post":{"tags":["Activation"],"summary":"Activate a purchase or refresh compliance for an existing key.","operationId":"activateAccess","security":[{},{"CemforgeBearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivationRequest"}}}},"responses":{"200":{"description":"Access active. New API keys are shown once.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivationResponse"}}}},"202":{"description":"Compliance clear but funds are pending.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivationResponse"}}}},"403":{"$ref":"#/components/responses/Forbidden"},"423":{"$ref":"#/components/responses/ReviewRequired"}}}},"/v1/account":{"get":{"tags":["Activation"],"summary":"Get wallet and compliance status for an API key.","operationId":"getAccount","security":[{"CemforgeBearer":[]}],"responses":{"200":{"description":"Account wallet and compliance status.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/v1/predict":{"post":{"tags":["Prediction"],"summary":"Generate one Open3DCP-aligned synthetic mix-design prediction.","operationId":"createPrediction","security":[{"CemforgeBearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictionRequest"},"examples":{"basic":{"value":{"target_strength":55,"materials":["Cement Type 1L","Silica Fume"]}}}}}},"responses":{"200":{"description":"Prediction generated. Response includes the canonical open3dcp envelope and compatibility fields.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictionResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"423":{"$ref":"#/components/responses/ReviewRequired"},"428":{"$ref":"#/components/responses/PreconditionRequired"},"429":{"$ref":"#/components/responses/RateLimited"},"502":{"$ref":"#/components/responses/Unavailable"},"503":{"$ref":"#/components/responses/Unavailable"}}}}},"components":{"securitySchemes":{"CemforgeBearer":{"type":"http","scheme":"bearer","description":"Sunnyday-issued CEMFORGE API key returned once by /v1/activate."}},"responses":{"BadRequest":{"description":"Bad request or invalid JSON body."},"Unauthorized":{"description":"Missing bearer API key."},"PaymentRequired":{"description":"Wallet exhausted; no upstream prediction call is made."},"Forbidden":{"description":"Invalid/suspended key or compliance denial."},"ReviewRequired":{"description":"Purchase, account, or compliance state is held for review."},"PreconditionRequired":{"description":"Compliance activation is required before prediction service."},"RateLimited":{"description":"Rate limit or cold-start quota exceeded."},"Unavailable":{"description":"Required configuration or upstream prediction service is unavailable."}},"schemas":{"AgentOfferFeed":{"type":"object","required":["schema","schema_version","merchant","service","offers","agent_protocols"],"additionalProperties":true},"CheckoutSessionRequest":{"type":"object","required":["package_id","terms_accepted","privacy_accepted","refund_policy_accepted","export_terms_accepted"],"properties":{"package_id":{"type":"string","enum":["starter_10"]},"customer_email":{"type":"string","format":"email"},"terms_accepted":{"type":"boolean","const":true},"privacy_accepted":{"type":"boolean","const":true},"refund_policy_accepted":{"type":"boolean","const":true},"export_terms_accepted":{"type":"boolean","const":true}}},"CheckoutSessionResponse":{"type":"object","required":["checkout_session_id","checkout_url","purchase_id","package_id","units"],"properties":{"checkout_session_id":{"type":"string"},"checkout_url":{"type":"string","format":"uri"},"purchase_id":{"type":"string"},"package_id":{"type":"string"},"units":{"type":"integer"}}},"ActivationRequest":{"type":"object","properties":{"purchase_id":{"type":"string"},"account_id":{"type":"string"},"buyer_name":{"type":"string"},"organization":{"type":"string"},"attestation":{"type":"object","required":["not_embargoed_jurisdiction","not_restricted_party","not_owned_50_percent_by_listed_party","civil_commercial_concrete_only"],"properties":{"not_embargoed_jurisdiction":{"type":"boolean","const":true},"not_restricted_party":{"type":"boolean","const":true},"not_owned_50_percent_by_listed_party":{"type":"boolean","const":true},"civil_commercial_concrete_only":{"type":"boolean","const":true}}}}},"ActivationResponse":{"type":"object","properties":{"compliance_status":{"type":"string"},"access_status":{"type":"string"},"wallet_available_units":{"type":"number"},"wallet_pending_units":{"type":"number"},"key_prefix":{"type":"string"},"api_key":{"type":"string","description":"Shown once only when newly minted."},"api_key_displayed_once":{"type":"boolean"}}},"AccountResponse":{"type":"object","properties":{"account_id":{"type":"string"},"wallet_available_units":{"type":"number"},"wallet_pending_units":{"type":"number"},"wallet_consumed_units":{"type":"number"},"wallet_refundable_unused_units":{"type":"number"},"credits_remaining":{"type":"number"},"status":{"type":"string"},"key_prefix":{"type":"string"},"cold_start_tier":{"type":"string"},"daily_quota":{"type":["number","null"]},"compliance_status":{"type":"string"}}},"PredictionRequest":{"type":"object","required":["target_strength"],"properties":{"target_strength":{"type":"number","description":"Target compressive strength in MPa."},"materials":{"type":"array","items":{"type":"string"},"maxItems":30},"w_c_ratio":{"type":"number"},"target_tolerance_pct":{"type":"number"},"max_strength_mpa":{"type":"number"},"application":{"type":"string"},"target_tensile":{"type":"number"},"target_flexural":{"type":"number"},"target_slump_flow":{"type":"number"}}},"PredictionResponse":{"type":"object","required":["open3dcp","mix_design","confidence","metadata","accuracy_note"],"properties":{"open3dcp":{"type":"object","description":"Canonical Open3DCP-aligned synthetic prediction record.","additionalProperties":true},"mix_design":{"type":"object","additionalProperties":{"type":["number","null"]}},"predicted_properties":{"type":"object","additionalProperties":{"type":["number","null"]}},"water_binder_ratio":{"type":["number","null"]},"confidence":{"type":["number","null"]},"model_source":{"type":"string"},"model_version":{"type":"string"},"schema_version":{"type":"string"},"accuracy_note":{"type":"string"},"metadata":{"type":"object","additionalProperties":true}}}}}}