{
  "info": {
    "name": "QuietPDF API",
    "description": "Process a document, poll the asynchronous job, and download the output through RapidAPI. Set rapidApiKey before sending requests. For direct QuietPDF access, change baseUrl to https://quietpdf.com/api/v1 and use your direct x-api-key credential.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://quietpdf.p.rapidapi.com/api/v1"
    },
    {
      "key": "rapidApiHost",
      "value": "quietpdf.p.rapidapi.com"
    },
    {
      "key": "rapidApiKey",
      "value": "YOUR_RAPIDAPI_KEY",
      "type": "secret"
    },
    {
      "key": "apiKey",
      "value": "YOUR_QUIETPDF_API_KEY",
      "type": "secret"
    },
    {
      "key": "jobId",
      "value": ""
    }
  ],
  "auth": {
    "type": "apikey",
    "apikey": [
      {
        "key": "key",
        "value": "X-RapidAPI-Key",
        "type": "string"
      },
      {
        "key": "value",
        "value": "{{rapidApiKey}}",
        "type": "string"
      },
      {
        "key": "in",
        "value": "header",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "if (pm.collectionVariables.get('baseUrl').includes('rapidapi.com')) {",
          "  pm.request.headers.upsert({ key: 'X-RapidAPI-Host', value: pm.collectionVariables.get('rapidApiHost') });",
          "} else {",
          "  pm.request.headers.remove('X-RapidAPI-Host');",
          "  pm.request.headers.upsert({ key: 'x-api-key', value: pm.collectionVariables.get('apiKey') });",
          "}"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "Process Document",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Job accepted', function () { pm.expect(pm.response.code).to.eql(202); });",
              "const body = pm.response.json();",
              "if (body.jobId) pm.collectionVariables.set('jobId', body.jobId);"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "file",
              "type": "file",
              "src": []
            },
            {
              "key": "tool",
              "value": "compress-pdf",
              "type": "text"
            },
            {
              "key": "params",
              "value": "{\"quality\":\"ebook\"}",
              "type": "text"
            }
          ]
        },
        "url": "{{baseUrl}}/process",
        "description": "Choose a small PDF file before sending. A successful response stores jobId for the next requests."
      }
    },
    {
      "name": "Check Job Status",
      "request": {
        "method": "GET",
        "header": [],
        "url": "{{baseUrl}}/jobs/{{jobId}}",
        "description": "Poll until status is COMPLETED before downloading."
      }
    },
    {
      "name": "Download Processed File",
      "request": {
        "method": "GET",
        "header": [],
        "url": "{{baseUrl}}/jobs/{{jobId}}/download",
        "description": "Downloads the completed output or follows the signed download redirect."
      }
    }
  ]
}
