Skip to main content
PUT https://api.craftkit.dev/v1/templates/{slug}
Create-or-republish the template at slug — the idempotent companion to POST /v1/templates. It re-runs the same manifest → layout synthesis as create, so a template authored before a layout feature shipped (for example image blocks) can be regenerated in place instead of orphaning its slug to a -v2.
  • Template does not exist → it is created and published as version 1 → 201.
  • Template exists → a new version (n+1) is published and becomes current → 200.
Use it from a provisioning script to make template setup idempotent across environments: the first run creates, every subsequent run republishes.
Existing renders are never affected. Each render pins its own templateVersionId, so republishing only changes what new renders use — previously rendered PDFs are immutable.

Authorization

string
required
Bearer ck_live_… — must own the project that holds (or will hold) the template.

Path

string
required
The canonical kebab-case slug. The URL slug wins — any slug in the body is ignored.

Body

The body is the same shape as create (minus slug, which comes from the URL).
string
required
Display name (1–120 chars). Replaces the stored name on republish.
string
Optional, up to 280 chars. Replaces the stored description on republish.
object
required
The variable manifest the render payload binds to.
select variables. A variable with dataType: "select" must include a non-empty options array of { value, label } choices (value is stored/validated, label is display text). Publishing a select with no options is rejected with invalid_request. Option values must be unique, and a defaultValue, if set, must be a string matching one of them. At render time only a declared value is accepted — see Concepts → Select variables.
object
Optional CanvasDocument contentJson override. When omitted, it is regenerated from the manifest.
object
Optional page format (format, orientation, margin, printBackground). Defaults to A4 portrait.

Response

200 (republished) or 201 (created):
string
string
The canonical slug (the one in the URL).
number
The newly published version. 1 on create; incremented by one on every republish.
object
The stored manifest, echoed back.
Each republish creates a new version even when the manifest is unchanged — calling PUT N times leaves N versions in history. This is intentional (it keeps currentVersionNumber advancing) and harmless to existing renders.

Errors

cURL
200
Prefer PUT over DELETE + POST when you only need the latest layout: it keeps the same template id and slug, and leaves prior renders intact.