---
title: "Generate a table from json input"
method: POST
path: "/render/{render_type}"
---

# Generate a table from json input

`POST /render/{render_type}`

## Request

- The document declares no server URL.
- Auth: none declared

Create an html, csv or xlsx representation of the given table for display or download

## Path parameters

- `render_type` 'html' | 'csv' | 'xlsx', required

## Request body

- RenderRequest: Properties that are present in both the RenderRequest and ParseRequest
  - `filename` string, required: A unique id for the table
  - `title` string: The main title of the table
  - `subtitle` string: An additional title or short description of the table
  - `source` string: Where the data in the table came from
  - `units` string: Name/decription of the units used in the table, if appropriate
  - `keep_headers_together` boolean: If true, the html output includes a css class designed to prevent content of heading cells being wrapped over 2 lines. Deliberate line breaks will be honoured.
  - `footnotes` string[]: Notes associated with (and potentially referenced from) the table. The order of footnotes is important, e.g. [1] will be converted into a link to the first footnote.
  - `row_formats` RowFormat[]: A list of format definitions for rows of the table
    - `row` integer: The index of the row this format applies to. Zero indexed.
    - `heading` boolean: Whether this row should be formatted as a heading
    - `height` string: The desired height of this row, as a valid css width property. E.g. '5em'
    - `vertical_align` 'Top' | 'Middle' | 'Bottom': The vertical alignment of the row. For html output this will be rendered as the name of a css class that is assumed to be defined in the containing page.
  - `column_formats` ColumnFormat[]: A list of format definitions for columns of the table
    - `col` integer: The index of the column this format applies to. Zero indexed.
    - `heading` boolean: Whether this column should be formatted as a heading
    - `width` string: The desired width of this column, as a valid css width property. E.g. '5em'
    - `align` 'Left' | 'Center' | 'Right' | 'Justify': The alignment of the column. For html output this will be rendered as the name of a css class that is assumed to be defined in the containing page.
  - `cell_formats` CellFormat[]: A list of format definitions for individual cells in the table
    - `row` integer: The row index of the cell this format applies to. Zero indexed.
    - `col` integer: The column index of the cell this format applies to. Zero indexed.
    - `align` 'Left' | 'Center' | 'Right' | 'Justify': The alignment of the column. For html output this will be rendered as the name of a css class that is assumed to be defined in the containing page.
    - `vertical_align` 'Top' | 'Middle' | 'Bottom': The vertical alignment of the cell. For html output this will be rendered as the name of a css class that is assumed to be defined in the containing page.
  - `data` array[]: The content of the cells in the table (a two-dimensional array of strings). Should contain values for each possible cell in the table, even if that cell will be hidden because another cell has a colspan or rowspan that covers it.
    - string[]

## Response `200`

An appropriate representation of the table is returned in the body

## Other responses

- `400`: Invalid request body
- `404`: Unknown render type
- `500`: Failed to process the request due to an internal error

---

[API](https://skmtc.dev/office-of-national-statistics/apis/table-renderer.md) - [All operations](https://skmtc.dev/office-of-national-statistics/apis/table-renderer/llms.txt) - [OpenAPI document](https://skmtc.dev/office-of-national-statistics/apis/table-renderer/revisions/6adcb13d0bcb?raw)
