{
  "openapi": "3.1.0",
  "info": {
    "title": "Doc_Conv Agent API",
    "version": "1.0.0",
    "description": "Convert PDF/Word/Excel/PowerPoint documents to Markdown. AI agents pay per conversion with USDC on Base via the x402 protocol (HTTP 402, gasless EIP-3009). No account, no API key.",
    "contact": { "name": "CREPE Foundation", "url": "https://crepe.fund" }
  },
  "servers": [{ "url": "https://converter.crepe.fund" }],
  "paths": {
    "/api/v1/agent/estimate": {
      "post": {
        "summary": "Estimate conversion price (free, no payment)",
        "description": "Upload a document to get a price quote (USDC), a jobId and a jobToken. No payment required.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": { "file": { "type": "string", "format": "binary" } },
                "required": ["file"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jobId": { "type": "string" },
                    "jobToken": { "type": "string" },
                    "fileType": { "type": "string", "enum": ["pdf", "docx", "xlsx", "pptx"] },
                    "pages": { "type": "integer" },
                    "credits": { "type": "integer" },
                    "price": {
                      "type": "object",
                      "properties": {
                        "usdc": { "type": "string" },
                        "atomic": { "type": "string" },
                        "asset": { "type": "string" },
                        "network": { "type": "string" },
                        "payTo": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/jobs/{jobId}/convert": {
      "post": {
        "summary": "Pay via x402 and start conversion",
        "description": "First call returns HTTP 402 with payment requirements. Sign an EIP-3009 USDC authorization and retry with the PAYMENT-SIGNATURE header. Returns 202 (queued) on success. Requires the X-Job-Token from /estimate.",
        "parameters": [
          { "name": "jobId", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "X-Job-Token", "in": "header", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "202": { "description": "Queued (payment accepted)" },
          "402": { "description": "Payment Required — x402 payment requirements returned in headers" }
        }
      }
    },
    "/api/v1/agent/jobs/{jobId}": {
      "get": {
        "summary": "Poll job status and get result",
        "parameters": [
          { "name": "jobId", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "X-Job-Token", "in": "header", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Job status; when done, a downloadUrl (md or zip)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "enum": ["queued", "processing", "done", "failed"] },
                    "downloadUrl": { "type": "string" },
                    "downloadFormat": { "type": "string", "enum": ["md", "zip"] }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "x-x402": {
    "network": "eip155:8453",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "assetSymbol": "USDC",
    "payTo": "0x383Cc31aC6416e5F1F57700b74f8970c894f4770",
    "pricingModel": "per-document, 50 pages = 1 credit = 0.2 USDC (dynamic; use /estimate)"
  }
}
