Skip to main content

Quickstart

Generate your first PDF document in under 5 minutes.

1. Get your API key

Sign in to DocPayload and navigate to Settings > API Keys to create a new key.

2. Create a document definition

A document definition is a JSON object that describes your PDF layout, styles, and content.

{
"document": {
"metadata": {
"title": "My First Document",
"author": "DocPayload"
},
"pageSetup": {
"size": "A4",
"orientation": "portrait",
"margins": [50, 40, 50, 40]
},
"styles": {
"title": { "fontSize": 22, "bold": true, "fontColor": "#1A1A2E" },
"body": { "fontSize": 11, "fontColor": "#333333", "textAlign": "justified" }
},
"content": [
{ "p": "Hello from DocPayload!", "style": "title" },
{ "p": "This PDF was generated from a JSON definition using the DocPayload API. You can add [b]bold text[/b], [i]italic text[/i], [fontcolor, #0066CC]colored text[/fontcolor], tables, lists, images, barcodes, and much more.", "style": "body" }
]
}
}

3. Generate the PDF

curl -X POST https://api.docpayload.com/v1/documents/generate-from-payload \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d @definition.json \
-o output.pdf

4. Open your PDF

That's it! Open output.pdf to see your generated document.

Works with any stack

You just generated a PDF with a standard HTTP request. That's the entire integration — if your stack can POST JSON, you're ready.

PHP with curl_exec, Java with HttpClient, Ruby with Net::HTTP, Go with net/http, WordPress with wp_remote_post, legacy systems with any HTTP library — they all work. The code you just saw in the examples above is all you need. No special library to install or keep updated.

Point your IDE at the published JSON Schema and you'll get autocomplete on every property and red squiggles on typos before you ever hit the API:

{
"$schema": "https://docpayload.com/docs/schemas/v1/document-definition.schema.json",
"document": { "content": [{ "p": "Hello." }] }
}

That one line in your JSON file is all most editors need.

Next steps