---
title: "Publish the draft"
method: POST
path: "/v1/templates/{template_id}/publish"
tags: ["Templates"]
---

# Publish the draft

`POST /v1/templates/{template_id}/publish`

## Request

- Base URL: `https://api-eu.dynamicdocumentapi.com`
- URL: `https://api-eu.dynamicdocumentapi.com/v1/templates/{template_id}/publish`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

Validates the draft (compile, options, syntax, datasets) and publishes a new live version. `201` when the run finished, `202` when validation is still running, `422` when a step failed — the problem details then carry the run in `publish_run`.

## Path parameters

- `template_id` string, required

## Headers

- `Idempotency-Key` string

## Request body

- TemplatePublish
  - `note` string

## Response `201`

Published.

- PublishRun
  - `created_at` string, date-time, required
  - `draft_revision` integer, required
  - `error` object, nullable, required
  - `errors` object[], required: Flattened, with `step`.
  - `finished_at` string, date-time, nullable, required
  - `id` string, required: `pub_…`
  - `note` string, required
  - `object` string
  - `status` 'running' | 'succeeded' | 'failed', required: * `running` - running * `succeeded` - succeeded * `failed` - failed
  - `steps` PublishStep[], required
    - `duration_ms` integer
    - `errors` object[], required
    - `name` string, required: `lock`, `compile`, `options`, `syntax`, `datasets`, …
    - `status` 'succeeded' | 'failed' | 'skipped' | 'running', required: * `succeeded` - succeeded * `failed` - failed * `skipped` - skipped * `running` - running
    - `warnings` object[], required
  - `template_id` string, required
  - `version` object, nullable, required: `{id, number, content_hash, published_at, note}` once published.
  - `warnings` object[], required

## Other responses

- `202`: Validation is still running.
- `400`: Invalid request body (`errors[]` with JSON pointers).
- `401`: Missing, invalid, expired or revoked credentials.
- `403`: Insufficient scope, IP not allowed, workspace suspended or scheduled for deletion, or email not verified.
- `404`: Template not found.
- `410`: Template deleted.
- `422`: Validation failed; `publish_run` holds the failing steps.
- `429`: Rate limited (`Retry-After`).
- `503`: The control plane is unreachable (`Retry-After`).

---

[API](https://skmtc.dev/dynamicdocumentapi/apis/dynamic-document-api.md) · [All operations](https://skmtc.dev/dynamicdocumentapi/apis/dynamic-document-api/llms.txt) · [OpenAPI document](https://skmtc.dev/dynamicdocumentapi/apis/dynamic-document-api/revisions/0f14bc0000f4?raw)
