Skip to content
DocsGreen

Developers

The PDF API that respects your time

Simple multipart uploads, asynchronous jobs, signed result URLs and webhooks. Documentation generated from the live API contract.

Quickstart

  1. 1. Create a job

    curl -X POST https://www.docsgreen.com/api/v1/jobs \
      -H "Authorization: Bearer $PL_API_KEY" \
      -H "Idempotency-Key: $(uuidgen)" \
      -F tool=merge-pdf \
      -F file=@part-1.pdf -F file=@part-2.pdf \
      -F 'options={"bookmarks":true}'
  2. 2. Poll the job (or receive a webhook)

    curl https://www.docsgreen.com/api/v1/jobs/JOB_ID -H "Authorization: Bearer $PL_API_KEY"
    
    {
      "id": "…", "status": "succeeded",
      "files": [{ "name": "merged.pdf", "size": 48213, "sha256": "…", "url": "https://…/api/files/…" }]
    }
  3. 3. Download the result

    Result URLs are signed, time-limited and need no API key. Files are deleted when the job expires.

Verify webhooks

Every delivery carries x-webhook-id (use it to de-duplicate) and x-webhook-signature: t=<unix>,v1=<hex>, an HMAC-SHA256 of t.body with your endpoint secret. Failed deliveries are retried with backoff for about a day.

import crypto from "node:crypto";

export function verify(secret, rawBody, header) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false;
  const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1 ?? ""));
}

Scoped keys

Keys are shown once, stored hashed, and can be limited to jobs, usage or webhook scopes. Revoke or rotate any time.

Idempotent

Send an Idempotency-Key header and retries return the original job instead of charging twice.

Clear limits

x-ratelimit-* headers on every response, 429 with retry-after, and a usage endpoint for credits.

Webhooks

job.succeeded, job.failed and job.canceled events, signed and retried.

Tenant isolation

Keys can only see jobs created by their own user or organization.

OpenAPI 3.1

Machine-readable spec at /api/v1/openapi.json.

Available tools (23)

toolDescriptionCredits
merge-pdfCombine multiple PDFs into a single document in the order you choose, with optional bookmarks and a table of contents.1
split-pdfSplit a PDF by custom page ranges, every N pages, into single pages, or into parts under a maximum file size.1
extract-pagesCreate a new PDF that contains only the pages you select.1
delete-pagesRemove unwanted pages from a PDF by page number or range.1
rotate-pdfRotate all pages or selected pages by 90, 180 or 270 degrees permanently.1
reverse-pdfReverse the page order of a PDF — useful for documents scanned back to front.1
add-page-numbersNumber pages with your choice of position, format, starting number, font size and color.1
resize-pdfChange page dimensions to A4, Letter, Legal or a custom size, scaling content to fit.1
pdf-to-textExtract the text layer of a PDF as plain text or as JSON with page references.1
jpg-to-pdfConvert JPG photos into a PDF — combine many images into one document or create one PDF per image.1
png-to-pdfConvert PNG images, including screenshots with transparency, into PDF.1
webp-to-pdfConvert WebP images into a PDF document.1
tiff-to-pdfConvert single and multi-page TIFF scans into PDF.1
image-to-pdfCombine JPG, PNG, WebP, GIF, BMP and TIFF images into one PDF.1
add-watermarkStamp text or an image watermark over or behind your pages with adjustable opacity, rotation and position.1
edit-metadataChange the title, author, subject, keywords and language stored in a PDF.1
protect-pdfEncrypt a PDF with a password and control printing, copying and editing permissions.1
unlock-pdfRemove password protection from a PDF when you know the password.1
sanitize-pdfStrip metadata, JavaScript, embedded files and optionally annotations and links before sharing.1
repair-pdfRebuild the internal structure of a damaged PDF so it opens reliably.1
pdf-infoInspect page count, dimensions, orientation, metadata, encryption, permissions, fonts and whether a PDF is scanned.1
extract-textExtract text with page references as structured JSON.1
flatten-pdfFlatten form fields into regular page content so they can't be changed.1

Versioning & deprecation

The API is versioned in the path (/api/v1). Additive changes (new fields, tools, options) ship without a version bump. Breaking changes ship in a new version; the previous version remains available for at least 12 months after a deprecation notice by email and in the changelog.

Changelog

  • v1.0 — jobs, usage, webhooks, tools listing, OpenAPI spec.