---
title: Generate Letter Document from JSON API
slug: generate-letter-document-from-json-api
url: https://apyhub.com/callable-labs/service/generate-letter-document-from-json-api
provider: Callable Labs
tags: [document-generation, letter-rendering, pdf-generation, docx-export, html-rendering]
auth: api_key
version: v1
service_type: sync
endpoints: 1
atoms: 200
mcp: true
---

# Generate Letter Document from JSON API

Render structured letter data into PDF, HTML, or DOCX. Return a PDF data URI and render metadata for business letters, notices, and mail-merge workflows.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/callable-labs/generate-letter-document-from-json-api/v1/documents/preset/letter` | What it does Generates a letter document from JSON input. You provide the letter content plus optio… | 200 |

## Endpoint reference

### Generate a preset document from JSON (letter)

`POST https://api.eu.apyhub.com/callable-labs/generate-letter-document-from-json-api/v1/documents/preset/letter` · 200 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `data.date` | body | string | yes | Date Default: `18 September 2026`. Example: `18 September 2026`. |
| `data.sender.name` | body | string | yes | Name Default: `Ada Lovelace`. Example: `Callable Labs`. |
| `data.sender.email` | body | any | no | Email Default: `null`. |
| `data.sender.phone` | body | any | no | Phone Default: `null`. |
| `data.sender.tax_id` | body | any | no | VAT / tax registration number. Default: `null`. |
| `data.sender.address` | body | array of string | no | Address lines. Default: `["Ockham Park","Surrey"]`. Example: `["1 Example Street","Amsterdam"]`. |
| `data.closing` | body | string | no | Closing Default: `Yours faithfully,`. |
| `data.subject` | body | any | no | Subject Default: `Notes on the Analytical Engine`. Example: `Confirmation of engagement`. |
| `data.recipient.name` | body | string | yes | Name Default: `Charles Babbage`. Example: `Callable Labs`. |
| `data.recipient.email` | body | any | no | Email Default: `null`. |
| `data.recipient.phone` | body | any | no | Phone Default: `null`. |
| `data.recipient.tax_id` | body | any | no | VAT / tax registration number. Default: `null`. |
| `data.recipient.address` | body | array of string | no | Address lines. Default: `["1 Dorset Street","London"]`. Example: `["1 Example Street","Amsterdam"]`. |
| `data.reference` | body | any | no | Reference Default: `null`. |
| `data.signature` | body | any | no | Signature Default: `A. A. L.`. Example: `Ada Lovelace`. |
| `data.paragraphs` | body | array of string | yes | Body paragraphs. Default: `["Thank you for the drawings you sent last week. I have annotated the punched-card sequence and enclose my notes.","I believe the engine might act upon other things besides… |
| `data.salutation` | body | string | no | Salutation Default: `Dear Mr Babbage,`. |
| `page.size` | body | string | no | Paper size. One of: A4, Letter, Legal, A3, A5. Default: `A4`. |
| `page.margin_mm` | body | number | no | Uniform page margin in millimetres. Default: `18`. |
| `page.orientation` | body | string | no | Orientation One of: portrait, landscape. Default: `portrait`. |
| `format` | body | string | no | `pdf`, `html` or `docx` return the bytes; `json` (default) returns a PDF data URI plus metadata. One of: json, html, pdf, docx. Default: `pdf`. |
| `download` | body | boolean | no | Send `Content-Disposition: attachment` so browsers save the file. Default: `false`. |

#### Quickstart

Render a letter with the required sender, recipient, date, and body paragraphs.

```bash
curl -X POST "https://api.eu.apyhub.com/callable-labs/generate-letter-document-from-json-api/v1/documents/preset/letter" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "date": "18 September 2026",
      "sender": {
        "name": "Ada Lovelace"
      },
      "recipient": {
        "name": "Charles Babbage"
      },
      "paragraphs": [
        "Thank you for the drawings you sent last week.",
        "I believe the engine might act upon other things besides number."
      ]
    }
  }'
```

#### What you'll get back

Returns a JSON object with `bytes` and `queued_ms`/`render_ms` timing fields, plus `cache`, `engine`, `format`, `data_uri`, `warnings`, `media_type`, and `engine_version`. `pages` is an integer when the output is a PDF, or `null` for DOCX/HTML.

```json
{
  "bytes": 12345,
  "cache": "miss",
  "pages": 2,
  "engine": "string",
  "format": "pdf",
  "data_uri": "data:application/pdf;base64,....",
  "warnings": [],
  "queued_ms": 12,
  "render_ms": 345,
  "media_type": "application/pdf",
  "engine_version": "string"
}
```

## About

## What it does
Letter Document Generator turns structured letter content into a rendered document. Send a `body` object with `data`, plus optional page and output settings, and get back a letter in `pdf`, `html`, or `docx` form. If you choose `json`, the response includes a PDF data URI and render metadata.

Use it when you need to create formal correspondence from application data: customer notices, engagement letters, internal approvals, or mail-merge style exports. The letter payload accepts the sender and recipient parties, `date`, `paragraphs`, and optional fields such as `subject`, `salutation`, `closing`, `signature`, and `reference`. You can also control paper size, margin, and orientation through the `page` object.

The response includes the generated file’s `format`, `media_type`, `bytes`, `engine`, `engine_version`, `cache`, and timing fields such as `queued_ms` and `render_ms`. For PDF output, it can also return `pages`; if rendering produces issues or notes, they appear in `warnings`.

Use Letter Document Generator when your backend needs a consistent, template-free way to produce printable business letters from JSON.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/callable-labs/service/generate-letter-document-from-json-api
