# Templates

Document templates: list them, add starters to a Space, import Word files and render PDFs.

Web version: https://www.svanja.com/docs/api/templates/

A template turns your details into a branded PDF, such as a letter or a report. You'll find your templates under [Skills, Templates](https://app.svanja.com/skills?tab=templates), alongside the starters Svanja ships with. Use these endpoints to render a document from your own data or turn Word files into templates. To read templates, you need the Templates area, which is included in Full access and Read-only. To render or save them, you need Full access or Templates set to **Read and write**. See [Skills, tools and templates](https://www.svanja.com/docs/skills/).

Call `GET /templates` to list the starter templates and your own, or `GET /templates/{id}` to view a single template along with its fields. Your own templates use the ID format `SPACE_ID:path`.

Use `POST /templates` to add templates to a Space. Set `action` to `add_to_space` (with `space_id` and `starter_key`) to copy a starter into a Space. Set `action` to `import_word` (with `space_id` and `paths`) to convert Word or OpenDocument files already in a Space into templates.

To render a PDF, call `POST /templates/{id}/actions` with your own `operation_id` and the template's fields under `data`:

```json
{
  "action": "render",
  "operation_id": "offer-2026-11",
  "data": { "client": "Example Ltd" }
}
```

Rendering usually runs in the background, and the response returns an `operation` with its current `status`. To check the status, send the same request again with the same `operation_id` (and a new idempotency key, if you use one). Once the status is `completed`, the response also includes the `artifact`, which is the finished document under [Artifacts](https://www.svanja.com/docs/api/artifacts/). If you're working from a terminal, see [svanja template](https://www.svanja.com/docs/cli/tools-and-templates/).

## Operations

| Operation | What it does | Effect | Endpoints |
| --- | --- | --- | --- |
| `template.import_word` | Import a Word template. | Changes data in Svanja | `POST /templates` |
| `template.read` | Read templates. | Reads only | `GET /templates`<br>`GET /templates/{id}` |
| `template.render` | Render a template. | Changes data in Svanja | `POST /templates/{id}/actions` |

## Endpoints

### GET /api/v1/templates

List templates

### POST /api/v1/templates

Add or import templates

### GET /api/v1/templates/{id}

Read a template

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |

### PATCH /api/v1/templates/{id}

Update a template

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |

### POST /api/v1/templates/{id}/actions

Render a template

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |
