โ† Back to blog

How to Merge PDFs Programmatically (Free API + AI Agent Guide)

July 7, 2026 ยท Eric ยท 5 min read

Combining invoices, contracts, or report appendices shouldn't require opening Adobe Acrobat. If you're building automation โ€” or asking an AI agent to handle document workflows โ€” you need a merge PDF API that accepts multiple files and returns one.

Agent Media Tools exposes POST /api/merge-pdf. Upload up to 10 PDFs, get a single merged file back. Here's how to use it from scripts, workflows, and AI agents.

When You Need Programmatic PDF Merge

curl Example

PDF tools require a free login (session cookie) for abuse prevention. For scripts, use the browser tool once or authenticate via API key on Premium.

curl -X POST https://agentmediatools.com/api/merge-pdf \
  -b "connect.sid=YOUR_SESSION_COOKIE" \
  -F "pdfs=@chapter1.pdf" \
  -F "pdfs=@chapter2.pdf" \
  -F "pdfs=@chapter3.pdf" \
  -o combined.pdf

Files are merged in upload order. Max 10 PDFs per request.

Python Example

import requests

session = requests.Session()
# Log in once, reuse session
session.post("https://agentmediatools.com/api/login", json={
    "username": "your_user", "password": "your_pass"
})

files = [
    ("pdfs", open("a.pdf", "rb")),
    ("pdfs", open("b.pdf", "rb")),
]
r = session.post("https://agentmediatools.com/api/merge-pdf", files=files)
with open("merged.pdf", "wb") as f:
    f.write(r.content)

Agent Prompt (Claude / ChatGPT)

Merge PDFs by POSTing to https://agentmediatools.com/api/merge-pdf
with multipart field "pdfs" repeated for each file (max 10).
Requires login session or Premium API key.
Response is the merged PDF binary.

n8n / Make.com Pattern

  1. Trigger: new files in Google Drive folder
  2. HTTP Request node โ†’ POST to /api/merge-pdf
  3. Save output to Dropbox or send via email

No custom server needed โ€” one HTTP node does the merge.

Related PDF Tools

Merge PDFs free: Open the tool ยท Premium โ€” 1,000/day ยท Full API docs


More at agentmediatools.com/blog