Skip to main content

Quickstart

Generate your first document — PDF, DOCX, or SVG — 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 document. The same definition renders to PDF, DOCX, or SVG — you choose the format at request time.

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

3. Generate a document

Append /pdf, /docx, or /svg to the endpoint to choose the output format. PDF is the default when omitted. The examples below use /pdf.

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

4. Open your document

That's it! Use the downloadUrl from the response to download or open your generated document.

Works with any stack

You just generated a document with a standard HTTP request. Replace /pdf with /docx or /svg to switch formats — same definition, same API call. 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