{
  "info": {
    "name": "EZdoc API v1",
    "description": "EZdoc REST API for document generation, template management, and SFTP delivery.\n\nFull docs: https://ezdoc.app/api-docs\n\nAuthentication: Bearer token via API key from Settings.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{api_key}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://ezdoc.app",
      "type": "string"
    },
    {
      "key": "api_key",
      "value": "ezdoc_sk_YOUR_API_KEY_HERE",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Account",
      "item": [
        {
          "name": "Get Account Info",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/account",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "account"]
            },
            "description": "Returns your plan, page usage, and template limits."
          }
        }
      ]
    },
    {
      "name": "Templates",
      "item": [
        {
          "name": "List Templates",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/templates",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "templates"]
            },
            "description": "Returns all templates with their placeholder fields. Use the placeholders array to know what keys your data needs."
          }
        },
        {
          "name": "Get Template",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/templates/:id",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "templates", ":id"],
              "variable": [
                {
                  "key": "id",
                  "value": "1",
                  "description": "Template ID (from List Templates)"
                }
              ]
            },
            "description": "Returns a single template with its placeholder fields."
          }
        },
        {
          "name": "Upload Template",
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "name",
                  "value": "My Invoice Template",
                  "type": "text"
                },
                {
                  "key": "file",
                  "type": "file",
                  "src": "",
                  "description": "DOCX or HTML file"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}/api/v1/templates",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "templates"]
            },
            "description": "Upload a Word (.docx) or HTML template. Placeholders are auto-extracted."
          }
        },
        {
          "name": "Delete Template",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/templates/:id",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "templates", ":id"],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Merge Jobs",
      "item": [
        {
          "name": "List Merge Jobs",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/merge_jobs?limit=20",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "merge_jobs"],
              "query": [
                {
                  "key": "limit",
                  "value": "20",
                  "description": "1-100, default 20"
                }
              ]
            },
            "description": "Returns your merge jobs ordered by most recent."
          }
        },
        {
          "name": "Get Merge Job Status",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/merge_jobs/:id",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "merge_jobs", ":id"],
              "variable": [
                {
                  "key": "id",
                  "value": "1",
                  "description": "Merge job ID (from Create response)"
                }
              ]
            },
            "description": "Poll this every 2-5 seconds. When status is 'complete', download_url is included."
          }
        },
        {
          "name": "Create Merge Job (JSON data)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"template_id\": 1,\n  \"data\": [\n    {\n      \"client_name\": \"Alice Smith\",\n      \"invoice_number\": \"INV-001\",\n      \"amount\": \"$1,500.00\",\n      \"due_date\": \"May 1, 2026\"\n    },\n    {\n      \"client_name\": \"Bob Jones\",\n      \"invoice_number\": \"INV-002\",\n      \"amount\": \"$2,300.00\",\n      \"due_date\": \"May 15, 2026\"\n    }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/merge_jobs",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "merge_jobs"]
            },
            "description": "Generate PDFs from JSON data. Each object becomes one PDF. Keys must match template placeholders."
          }
        },
        {
          "name": "Create Merge Job (CSV upload)",
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "template_id",
                  "value": "1",
                  "type": "text"
                },
                {
                  "key": "file",
                  "type": "file",
                  "src": "",
                  "description": "CSV file — one row per document"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}/api/v1/merge_jobs",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "merge_jobs"]
            },
            "description": "Generate PDFs from a CSV file. Column headers must match template placeholders."
          }
        },
        {
          "name": "Create Merge Job with SFTP Delivery",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"template_id\": 1,\n  \"data\": [\n    {\n      \"client_name\": \"Alice Smith\",\n      \"amount\": \"$1,500.00\"\n    }\n  ],\n  \"deliver_to\": {\n    \"method\": \"sftp\",\n    \"connection_id\": 1\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/api/v1/merge_jobs",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "merge_jobs"]
            },
            "description": "Generate PDFs and auto-deliver the ZIP to your SFTP server. connection_id is optional if you have only one verified connection."
          }
        }
      ]
    },
    {
      "name": "SFTP Connections",
      "item": [
        {
          "name": "List SFTP Connections",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/sftp_connections",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "sftp_connections"]
            },
            "description": "Returns all SFTP connections. Credentials are never returned. Requires Growth or Scale plan."
          }
        },
        {
          "name": "Get SFTP Connection",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/sftp_connections/:id",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "sftp_connections", ":id"],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            }
          }
        },
        {
          "name": "Create SFTP Connection",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Production Server\",\n  \"host\": \"sftp.example.com\",\n  \"port\": 22,\n  \"username\": \"ezdoc\",\n  \"private_key\": \"-----BEGIN OPENSSH PRIVATE KEY-----\\n...\\n-----END OPENSSH PRIVATE KEY-----\",\n  \"remote_path\": \"/incoming/invoices/\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/api/v1/sftp_connections",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "sftp_connections"]
            },
            "description": "Create a new SFTP connection. Starts unverified — call Test to verify before use. Provide either private_key (SSH key) or password."
          }
        },
        {
          "name": "Create SFTP Connection (Password)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Production Server\",\n  \"host\": \"sftp.example.com\",\n  \"port\": 22,\n  \"username\": \"ezdoc\",\n  \"password\": \"your-password-here\",\n  \"remote_path\": \"/incoming/invoices/\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/api/v1/sftp_connections",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "sftp_connections"]
            },
            "description": "Create with password authentication instead of SSH key."
          }
        },
        {
          "name": "Test SFTP Connection",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/sftp_connections/:id/test",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "sftp_connections", ":id", "test"],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            },
            "description": "Tests SSH handshake and directory access. On success, marks the connection as verified. Must be verified before use with deliver_to."
          }
        },
        {
          "name": "Update SFTP Connection",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"remote_path\": \"/new/path/\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/api/v1/sftp_connections/:id",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "sftp_connections", ":id"],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            },
            "description": "Update connection settings. Changing host, username, or credentials resets verification."
          }
        },
        {
          "name": "Delete SFTP Connection",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/sftp_connections/:id",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "sftp_connections", ":id"],
              "variable": [
                {
                  "key": "id",
                  "value": "1"
                }
              ]
            }
          }
        }
      ]
    }
  ]
}
