apyhub
Back

Generate Report Document from JSON API

What it does

Report Generator turns structured JSON into a formatted report document. Send report content with a title, date, and one or more sections, then choose the output format you need: PDF, HTML, DOCX, or JSON metadata.

Use the body.data object to provide report content. The schema supports an optional subtitle, author, footer, and summary, plus up to 50 sections. Each section needs a heading and can include paragraphs, bullets, or a table with columns, rows, and an optional caption. You can also set page options such as size, margin_mm, and orientation, and control whether the result is downloaded as a file.

The response includes rendering details such as bytes, cache, pages, engine, format, data_uri, warnings, queued_ms, render_ms, media_type, and engine_version. For PDF output, pages reports the page count; for DOCX and HTML, it is null. That makes it useful for operational reports, summaries, status updates, and templated documents where you already have the content in JSON and need consistent output across runs.

Use Report Generator when your app assembles report data programmatically and you need predictable document rendering without building a layout engine yourself.

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.