apyhub
Back
▣ OUTPUT KIT

Generate Report Document from JSON API

What it does

The Report Generator API turns structured JSON into a formatted report. Send a title, a date and sections of content, and get back a PDF, HTML or DOCX file.

Put the content in data. Add an optional subtitle, author, summary and footer. Add up to 50 sections. Each section needs a heading and can hold paragraphs, bullets, or a table with columns, rows and an optional caption. Use page to set the paper size, margin and orientation.

Set format to pdf (default), html, docx or json. With json, the response includes the file as a data_uri plus metadata. Set download to true to get the file itself. The metadata reports the bytes, any render warnings, and timing. For PDF output, pages gives the page count. For DOCX and HTML it is null.

Teams use the Report Generator API to create PDF reports from JSON for weekly operations updates, monthly summaries, status reports and data exports. The layout stays the same on every run, so recurring reports look consistent.

To add charts and diagrams, render them first with the Diagram, Math and Code Render API. For your own design, fill a template with the Validate & Generate Documents from Templates API.

POST
Generate a preset document from JSON (report)
https://api.eu.apyhub.com/callable-labs/generate-report-document-from-json-api/v1/documents/preset/report

QUICKSTART

GUIDE

Quickstart

Render a report from the required report data and return JSON metadata by default.

curl -X POST "https://api.eu.apyhub.com/callable-labs/generate-report-document-from-json-api/v1/documents/preset/report" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "title": "Quarterly Operations Review",
      "date": "18 September 2026",
      "sections": [
        {
          "heading": "Volume",
          "paragraphs": ["Requests grew steadily through the quarter."]
        }
      ]
    }
  }'

What you'll get back

Returns a JSON object with metadata about the render. The schema declares top-level fields such as bytes (integer), cache (hit or miss), pages (integer or null), engine (string), format (docx, pdf, or html), data_uri (string), warnings (string[]), queued_ms (integer), render_ms (integer), media_type (string), and engine_version (string).

{
  "bytes": 12345,
  "cache": "miss",
  "pages": 2,
  "engine": "render-report-preset",
  "format": "pdf",
  "data_uri": "data:application/pdf;base64,...",
  "warnings": [],
  "queued_ms": 12,
  "render_ms": 340,
  "media_type": "application/pdf",
  "engine_version": "1.0.0"
}
TRY ITLIVE · 200 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
ReportRequest*
ReportData*
Report content.
Sections*
Section*
Section*
Executive summary printed before the sections.
PageOptions
Paper size and margins for PDF output.

About this endpoint

What it does

Generates a rendered report from JSON report content and returns the render metadata and output payload fields defined by the response schema. You can control the output format and page options in the request body.

Request Body

ParameterTypeDescription
dataObjectReport content. Must include title, date, and sections.
data.dateStringDate string. Max length: 32.
data.titleStringTitle string. Max length: 200.
data.authorStringOptional author name. Max length: 200. Default: null.
data.footerStringOptional footer text. Max length: 200. Default: null.
data.summaryStringOptional executive summary printed before the sections. Max length: 4000. Default: null.
data.sectionsObject ArrayArray of report sections. Minimum 1 item, maximum 50 items.
data.sections[].headingStringSection heading. Max length: 200.
data.sections[].tableObjectOptional table for the section. When provided, columns is required. Default: null.
data.sections[].table.rowsObject ArrayTable rows. Each row is an array of string, number, integer, or null values. Maximum 500 rows.
data.sections[].table.captionStringOptional table caption. Max length: 200. Default: null.
data.sections[].table.columnsString ArrayTable columns. Required when the table object is given. Minimum 1 item, maximum 20 items.
data.sections[].bulletsString ArrayBullet list items for the section. Maximum 100 items.
data.sections[].paragraphsString ArrayParagraph text items for the section. Maximum 50 items.
data.subtitleStringOptional subtitle. Max length: 200. Default: null.
pageObjectPage options for PDF output. Paper size and margins.
page.sizeENUMPaper size. Allowed values: A4, Letter, Legal, A3, A5. Default: A4.
page.margin_mmNumberUniform page margin in millimetres. Minimum: 0. Maximum: 50. Default: 18.
page.orientationENUMPage orientation. Allowed values: portrait, landscape. Default: portrait.
formatENUMOutput format. Allowed values: json, html, pdf, docx. Default: json. The schema notes that pdf, html, and docx return bytes, while json returns a PDF data URI plus metadata.
downloadBooleanSends Content-Disposition: attachment so browsers save the file. Default: false.

Response

Returns a JSON object with these top-level fields: bytes integer, cache string, pages integer or null, engine string, format string, data_uri string, warnings array of strings, queued_ms integer, render_ms integer, media_type string, and engine_version string. The schema does not mark any response fields as required.

ParameterTypeDescription
bytesIntegerRendered output size in bytes.
cacheENUMCache status. Allowed values: hit, miss.
pagesIntegerPDF page count; null for DOCX/HTML.
engineStringRendering engine name.
formatENUMOutput format returned. Allowed values: docx, pdf, html.
data_uriStringData URI in the form data:<media_type>;base64,….
warningsString ArrayWarning messages emitted during rendering.
queued_msIntegerTime spent queued, in milliseconds.
render_msIntegerTime spent rendering, in milliseconds.
media_typeStringMIME type of the rendered payload.
engine_versionStringRendering engine version.

Notes

The request body includes an outer parser wrapper named body, but callers should send the inner fields directly; do not include a body object in the actual request. Also, when page is provided, its fields use the documented defaults unless overridden, and download only changes the response headers, not the JSON response shape.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.