Documentation / API overview
Generate
Create PDF, PPTX, and DOCX files from structured document descriptions.
A JSON or XML document description
One PDF, PPTX, or DOCX file
Define the document
Your application supplies the content and structure in JSON or XML and selects an output format. Generate produces the document file from that description; it does not require an existing source document.
Output formats
- PDF for distributing a rendered document.
- PPTX for an editable PowerPoint presentation.
- DOCX for an editable Word document.
Request and response
Proposed API contract
Submit the document’s content and structure directly. This example
uses JSON; XML is an alternate document representation. Select
pdf, pptx, or docx as the
output format.
curl https://api.moda.app/v1/documents/generate \
-H "Authorization: Bearer $MODA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "pdf",
"document": {
"title": "Quarterly report",
"blocks": [
{
"type": "heading",
"level": 1,
"text": "Quarterly report"
},
{
"type": "paragraph",
"text": "Revenue increased by 12% this quarter."
}
]
}
}'
The request starts a job. Poll the returned
poll_url until the status is completed or
failed. See
the shared job lifecycle.
{
"id": "job_generate_example",
"status": "completed",
"result": {
"file": {
"url": "https://files.example.com/report.pdf",
"format": "pdf"
},
"warnings": []
}
}
Fields
to- The output file format.
document- A JSON document description; this example contains a title and ordered blocks.
document.blocks- The content to render. Here, a heading followed by a paragraph.
result.file- The generated document’s download URL and format.
Example workflow
- Collect the content for a report in your application.
- Describe the report as JSON or XML.
- Select PDF, PPTX, or DOCX and generate the file.
Generate or Convert?
Use Generate when structured input defines a new document. Use Convert when you start with a PDF, HTML, or raster document and need another representation.