{
  "info": {
    "name": "AI Estimate Assistant — Partner API (v1)",
    "description": "PDF -> ESX conversion API. See docs/integration-guide.md for the full walkthrough. Set collection variables base_url and api_key before running.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "apikey",
    "apikey": [
      { "key": "key", "value": "X-API-Key", "type": "string" },
      { "key": "value", "value": "{{api_key}}", "type": "string" },
      { "key": "in", "value": "header", "type": "string" }
    ]
  },
  "variable": [
    { "key": "base_url", "value": "https://est.anterotrail.com/v1", "type": "string" },
    { "key": "api_key", "value": "at_test_REPLACE_ME", "type": "string" },
    { "key": "job_id", "value": "", "type": "string" }
  ],
  "item": [
    {
      "name": "Ping (auth check)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/ping",
          "host": ["{{base_url}}"],
          "path": ["ping"]
        },
        "description": "Confirms your API key works and reports which environment (live/test) it maps to."
      },
      "response": []
    },
    {
      "name": "Create conversion",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "if (pm.response.code === 202) {",
              "    const body = pm.response.json();",
              "    pm.collectionVariables.set('job_id', body.job_id);",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Idempotency-Key", "value": "postman-{{$guid}}" }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            { "key": "file", "type": "file", "src": [], "description": "The estimate PDF" },
            { "key": "price_list", "value": "FLTA8X_02MAY26", "type": "text" },
            { "key": "output_formats", "value": "esx", "type": "text" }
          ]
        },
        "url": {
          "raw": "{{base_url}}/conversions",
          "host": ["{{base_url}}"],
          "path": ["conversions"]
        },
        "description": "Accepts a PDF, enqueues an async conversion job, returns 202 + job_id. The test script auto-populates {{job_id}} for the next request."
      },
      "response": []
    },
    {
      "name": "Get conversion status",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/conversions/{{job_id}}",
          "host": ["{{base_url}}"],
          "path": ["conversions", "{{job_id}}"]
        },
        "description": "Poll until status is 'succeeded' (then follow esx_url) or 'failed' (see error.code)."
      },
      "response": []
    }
  ]
}
