{
  "openapi": "3.1.0",
  "info": {
    "title": "NEAR x402 demo paid work API",
    "version": "0.1.4",
    "contact": { "email": "mikedotexe@gmail.com" },
    "description": "Deterministic paid work demo behind the NEAR x402 facilitator at x402.mikedotexe.com. Payment is 1,000 atomic units of Circle USDC on NEAR mainnet ($0.001) per request, settled through NEP-366 signed delegates with relayer-sponsored gas.",
    "x-guidance": "POST /work with JSON {\"input\": \"<string>\"}. An unpaid request returns 402 with x402 v2 payment requirements base64-encoded in the PAYMENT-REQUIRED response header (scheme exact, network near:mainnet, 1000 atomic units of USDC). Sign the NEP-366 delegate payment payload and retry with it base64-encoded in the PAYMENT-SIGNATURE request header. The 200 response is the deterministic SHA-256 digest of the canonical request body."
  },
  "servers": [{ "url": "https://x402-demo.mikedotexe.com" }],
  "paths": {
    "/work": {
      "post": {
        "operationId": "paidWork",
        "summary": "Deterministic SHA-256 work, paid via x402 (NEAR USDC)",
        "description": "Unpaid requests receive a 402 with x402 v2 payment requirements in the base64 PAYMENT-REQUIRED header. Resubmit with a PAYMENT-SIGNATURE header containing the signed payment payload. The payment-identifier extension is optional: include it to opt into delivery-replay idempotency (replaying the identical paid request returns the cached result without a second settlement; reusing an identifier with different work is rejected).",
        "x-payment-info": {
          "protocols": [{ "x402": {} }],
          "price": { "mode": "fixed", "currency": "USD", "amount": "0.001000" }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["input"],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "string",
                    "maxLength": 4096,
                    "description": "Arbitrary input string; the result is the deterministic SHA-256 digest of the canonical request body"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deterministic work result (replayed is true when served from the delivery journal)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": { "type": "string" },
                    "replayed": { "type": "boolean" }
                  }
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required. v2 requirements are base64-encoded in the PAYMENT-REQUIRED response header (authoritative); the JSON body carries an informational hint pointing at the header"
          },
          "409": {
            "description": "Payment identifier already used for different work"
          }
        }
      }
    }
  }
}
