PDF Merge API — Integration Guide

Merge PDFs and images into one PDF with a single HTTPS request. This guide shows how to get your token, call the API and handle every response.

REST · HTTPS PDF · JPG · PNG Up to 20 files / request Files kept 10 min at most

1. Quick start

  1. Subscribe to a PDF Merge API plan at https://datacorpapi.com.
  2. Open your subscription in the customer portal and click Create key. Copy the token (it starts with dca_sk_). It is shown only once.
  3. Send your files to the API with the token in the Authorization header:
curl -X POST https://convert.datacorpapi.com/api/v1/merge \
  -H "Authorization: Bearer dca_sk_YOUR_TOKEN" \
  -F "files[]=@passport.pdf" \
  -F "files[]=@visa.jpg" \
  -F "output_name=merged.pdf" \
  -o merged.pdf

If the request succeeds, the response body is the merged PDF file.

2. Your token

  • Where to get it: customer portal → your PDF Merge API subscription → Create key.
  • Shown once: copy it right away and store it in a secure place (server configuration, secret manager, Zoho connection or org variable).
  • How to send it: Authorization: Bearer <token> on every request. X-API-Key: <token> also works.
  • Keep it on the server: never put the token in browser JavaScript, mobile apps or public repositories.
  • Lost or exposed? Revoke it in the portal and create a new one. The old token stops working immediately.
  • One token per subscription: to replace a token, revoke the old one first, then create the new one and update your system.

3. Users & tokens — how pricing works

  • You pay per user. A user is a person in your organization who uses the merge feature (for example, a Zoho CRM user who can click your "Merge documents" button).
  • You get one token per subscription, no matter how many users you pay for.
  • All your users share that single token. Install it once in your system and every user works through it.
  • Unlimited merges on paid plans. The free trial includes 100 merges per billing cycle.
  • Only successful merges are counted. Requests rejected because of a problem file are not counted.
MonthlyTHB 690per user / month
YearlyTHB 5,880per user / year
Example: 17 Zoho usersTHB 11,730per month · 1 token

Keep the number of users on your subscription equal to the number of people who use the service. When your team grows, contact us to add users. Your token stays the same.

4. Merge files

POSThttps://convert.datacorpapi.com/api/v1/merge

Request (multipart/form-data)

FieldRequiredDescription
files[]Yes2–20 files (PDF, JPG, JPEG, PNG). Merged in the order you send them.
Files[0], Files[1], …AlternativeIndexed field names are also accepted and are sorted by index (0, 1, 2 … 10).
output_nameNoFile name of the result, for example CA306445_documents.pdf. Thai and other Unicode names are supported. .pdf is added if missing, and / \ : * ? " < > | are removed. Default: merged.pdf.
response_typeNofile (default): the response is the PDF itself. link: the response is JSON with a temporary download link — see Download link.

output_name and response_type can also be sent in the query string, for example /api/v1/merge?response_type=link&output_name=documents.pdf. This is easier from Zoho Deluge.

What the API does with your files

  • Detects the real file type from the content, so a PNG saved as .jpg still works.
  • Places images on A4 pages. Transparent PNG backgrounds become white.
  • Checks every PDF first. Password-protected or damaged PDFs are rejected with the file name, before any merging.
  • PDFs that are only restricted (for example, printing disabled) but open without a password are merged normally.

Success response — 200

The body is the merged PDF (binary). Useful headers:

Content-Type: application/pdf
Content-Disposition: attachment; filename=documents.pdf; filename*=utf-8''CA306445_%E0%B8%A3%E0%B8%A7%E0%B8%A1.pdf
X-Merged-Count: 3        # number of source files merged
X-Page-Count: 7          # pages in the merged PDF
X-Plan: Monthly
X-Quota-Used: 152        # successful merges in this billing cycle
X-Quota-Remaining: 48    # only on plans with a limit (trial)

Error response — JSON

{
  "success": false,
  "error_code": "ENCRYPTED_PDF",
  "message": "ไฟล์ VISA.pdf มีรหัสผ่าน ไม่สามารถรวมได้",
  "file": "VISA.pdf"
}

Always check the HTTP status first. Save the body as a PDF only when the status is 200. For any other status, read the body as JSON. message is in Thai so you can show it to your users as is. file is present when one specific file caused the error.

6. Code examples

# Merge three files; save the PDF only on success
status=$(curl -s -w "%{http_code}" -o result.bin -X POST https://convert.datacorpapi.com/api/v1/merge \
  -H "Authorization: Bearer $PDF_MERGE_TOKEN" \
  -F "files[]=@passport.pdf" \
  -F "files[]=@visa.pdf" \
  -F "files[]=@photo.png" \
  -F "output_name=CA306445_documents.pdf")

if [ "$status" = "200" ]; then mv result.bin merged.pdf; else cat result.bin; fi

7. Convert one image to PDF

POSThttps://convert.datacorpapi.com/api/v1/convert/image-to-pdf

  • Send one image in the field file (JPG, JPEG or PNG). output_name is optional; by default the image's name is used with .pdf.
  • The response is the same as /merge: a PDF on success (or a download link with response_type=link), JSON on error. Sending a PDF returns UNSUPPORTED_FILE.
curl -X POST https://convert.datacorpapi.com/api/v1/convert/image-to-pdf \
  -H "Authorization: Bearer $PDF_MERGE_TOKEN" \
  -F "file=@id-card.png" -o id-card.pdf

8. Errors

Every error has the same JSON shape: success, error_code, message (Thai) and, when relevant, file or quota.

HTTPerror_codeWhat to do
401 UNAUTHORIZED Check the token. It may be mistyped, revoked, or belong to another product. Create a new token in the customer portal if needed.
422 VALIDATION_ERROR Fix the request: number of files, field names or output_name. Do not retry unchanged.
415 UNSUPPORTED_FILE Only PDF, JPG, JPEG and PNG are accepted. The file type is detected from the content, not the extension.
413 FILE_TOO_LARGE Reduce the file size or send fewer files per request.
422 CORRUPTED_PDF The PDF named in "file" is damaged. Re-export or re-scan it.
422 ENCRYPTED_PDF The PDF named in "file" needs a password to open. Remove the password first.
422 CONVERT_FAILED The image named in "file" could not be converted. Re-save it as JPG or PNG.
500 MERGE_FAILED Unexpected merge error. Retry once; if it persists, contact support.
403 HTTPS_REQUIRED Call the API with https://, never http://.
429 TOO_MANY_REQUESTS Slow down. Wait a few seconds (see the Retry-After header) and try again.
404 NOT_FOUND Check the URL and HTTP method.
500 INTERNAL_ERROR Unexpected error. Retry once; if it persists, contact support.
402 PAYMENT_REQUIRED A payment failed. Update your payment method in the customer portal.
403 SUBSCRIPTION_INACTIVE Your plan has expired, is not active yet, or the account is suspended. Renew in the customer portal or contact us.
429 QUOTA_EXCEEDED Trial limit reached for this billing cycle. Upgrade to a paid plan. The response includes a "quota" object.
503 AUTH_SERVICE_UNAVAILABLE Temporary problem verifying your token. Retry after a short wait.
503 STORAGE_UNAVAILABLE Only with response_type=link: the download link could not be created. The merge was not counted. Retry after a short wait.

Retry only on 429, 500 and 503, with a short wait (for example 2 s, then 5 s, then 15 s). Other errors will fail again until the request or the file is fixed.

9. Limits

LimitValue
Files per request2 – 20
Size per file20 MB
Total size per request100 MB
Accepted typesPDF, JPG, JPEG, PNG (detected from content)
Requests per token120 per minute
Recommended client timeout120 seconds
Download link (response_type=link)10 minutes · up to 3 downloads
MergesUnlimited on paid plans · 100 per billing cycle on the trial

10. Zoho CRM notes

  • One token for the whole organization. Save it once as an org variable (for example pdf_merge_token). Every CRM user who clicks your button uses that same token.
  • 40-second limit. Deluge stops waiting after 40 seconds. Merging many large scans may take longer, so merge fewer or smaller files per click.
  • 5 MB response limit. Deluge can receive files up to 5 MB from external services. Use response_type=link: you get a small JSON reply with a download link instead of the file, so the size of the merged PDF no longer matters.
  • Order matters. Add files to the list in the order the pages should appear, for example sorted by your "No" field.
  • Show our message. On failure, show the Thai message from the response to the user. It names the file that caused the problem.

11. Check your plan and usage

GEThttps://datacorpapi.com/api/v1/usage with the same token. Returns your plan, renewal date, usage in this billing cycle and payment links.

curl https://datacorpapi.com/api/v1/usage -H "Authorization: Bearer $PDF_MERGE_TOKEN"

Service status (no token needed): GEThttps://convert.datacorpapi.com/api/v1/health

12. Best practices

  • Call the API from your server or from Zoho functions, never from a web browser, so the token stays private.
  • Use a timeout of about 120 seconds and retry only on 429, 500 and 503.
  • Check the HTTP status before saving the response as a PDF.
  • Send files in the final page order. The API never reorders them.
  • Compress large scans (150–200 dpi is enough for documents) to keep requests fast.
  • Watch X-Quota-Remaining on the trial so you can upgrade before you reach the limit.

Privacy: your files are used only to build your PDF. Uploaded files are deleted as soon as the merge finishes. The merged PDF is deleted right after the response is sent; with response_type=link it is kept only in private cloud storage (Cloudflare R2, never on our server) for at most 10 minutes (or until it has been downloaded 3 times) and then deleted. We do not look at or share your documents, and file names and download links are not written to our logs.

13. Support