Create a template
curl --request POST \
--url https://api.craftkit.dev/v1/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Invoice",
"slug": "invoice",
"description": "Standard customer invoice",
"manifest": {
"variables": [
{
"key": "customer.name",
"label": "Customer name",
"dataType": "text",
"required": true
}
],
"loops": []
},
"pageConfig": {
"format": "A4",
"orientation": "portrait",
"margin": "20mm",
"printBackground": true
}
}
'import requests
url = "https://api.craftkit.dev/v1/templates"
payload = {
"name": "Invoice",
"slug": "invoice",
"description": "Standard customer invoice",
"manifest": {
"variables": [
{
"key": "customer.name",
"label": "Customer name",
"dataType": "text",
"required": True
}
],
"loops": []
},
"pageConfig": {
"format": "A4",
"orientation": "portrait",
"margin": "20mm",
"printBackground": True
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Invoice',
slug: 'invoice',
description: 'Standard customer invoice',
manifest: {
variables: [
{key: 'customer.name', label: 'Customer name', dataType: 'text', required: true}
],
loops: []
},
pageConfig: {format: 'A4', orientation: 'portrait', margin: '20mm', printBackground: true}
})
};
fetch('https://api.craftkit.dev/v1/templates', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.craftkit.dev/v1/templates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Invoice',
'slug' => 'invoice',
'description' => 'Standard customer invoice',
'manifest' => [
'variables' => [
[
'key' => 'customer.name',
'label' => 'Customer name',
'dataType' => 'text',
'required' => true
]
],
'loops' => [
]
],
'pageConfig' => [
'format' => 'A4',
'orientation' => 'portrait',
'margin' => '20mm',
'printBackground' => true
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.craftkit.dev/v1/templates"
payload := strings.NewReader("{\n \"name\": \"Invoice\",\n \"slug\": \"invoice\",\n \"description\": \"Standard customer invoice\",\n \"manifest\": {\n \"variables\": [\n {\n \"key\": \"customer.name\",\n \"label\": \"Customer name\",\n \"dataType\": \"text\",\n \"required\": true\n }\n ],\n \"loops\": []\n },\n \"pageConfig\": {\n \"format\": \"A4\",\n \"orientation\": \"portrait\",\n \"margin\": \"20mm\",\n \"printBackground\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.craftkit.dev/v1/templates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Invoice\",\n \"slug\": \"invoice\",\n \"description\": \"Standard customer invoice\",\n \"manifest\": {\n \"variables\": [\n {\n \"key\": \"customer.name\",\n \"label\": \"Customer name\",\n \"dataType\": \"text\",\n \"required\": true\n }\n ],\n \"loops\": []\n },\n \"pageConfig\": {\n \"format\": \"A4\",\n \"orientation\": \"portrait\",\n \"margin\": \"20mm\",\n \"printBackground\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.craftkit.dev/v1/templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Invoice\",\n \"slug\": \"invoice\",\n \"description\": \"Standard customer invoice\",\n \"manifest\": {\n \"variables\": [\n {\n \"key\": \"customer.name\",\n \"label\": \"Customer name\",\n \"dataType\": \"text\",\n \"required\": true\n }\n ],\n \"loops\": []\n },\n \"pageConfig\": {\n \"format\": \"A4\",\n \"orientation\": \"portrait\",\n \"margin\": \"20mm\",\n \"printBackground\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "7c9f0b2e-2b1a-4f3d-9c8e-1a2b3c4d5e6f",
"slug": "invoice",
"currentVersionNumber": 1,
"manifest": {
"variables": [
{
"key": "customer.name",
"label": "Customer name",
"dataType": "text",
"required": true
}
],
"loops": []
}
}{
"error": {
"code": "invalid_request",
"message": "Request body did not match expected shape."
}
}{
"error": {
"code": "unauthorized",
"message": "Missing Bearer token."
}
}{
"error": {
"code": "slug_conflict",
"message": "A template with slug 'invoice' already exists in this project."
}
}Templates
Create a template
Create a template from a variable manifest (and optional layout). When
layout is omitted a CanvasDocument layout is synthesized from the
manifest. Publishes version 1.
POST
/
v1
/
templates
Create a template
curl --request POST \
--url https://api.craftkit.dev/v1/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Invoice",
"slug": "invoice",
"description": "Standard customer invoice",
"manifest": {
"variables": [
{
"key": "customer.name",
"label": "Customer name",
"dataType": "text",
"required": true
}
],
"loops": []
},
"pageConfig": {
"format": "A4",
"orientation": "portrait",
"margin": "20mm",
"printBackground": true
}
}
'import requests
url = "https://api.craftkit.dev/v1/templates"
payload = {
"name": "Invoice",
"slug": "invoice",
"description": "Standard customer invoice",
"manifest": {
"variables": [
{
"key": "customer.name",
"label": "Customer name",
"dataType": "text",
"required": True
}
],
"loops": []
},
"pageConfig": {
"format": "A4",
"orientation": "portrait",
"margin": "20mm",
"printBackground": True
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Invoice',
slug: 'invoice',
description: 'Standard customer invoice',
manifest: {
variables: [
{key: 'customer.name', label: 'Customer name', dataType: 'text', required: true}
],
loops: []
},
pageConfig: {format: 'A4', orientation: 'portrait', margin: '20mm', printBackground: true}
})
};
fetch('https://api.craftkit.dev/v1/templates', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.craftkit.dev/v1/templates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Invoice',
'slug' => 'invoice',
'description' => 'Standard customer invoice',
'manifest' => [
'variables' => [
[
'key' => 'customer.name',
'label' => 'Customer name',
'dataType' => 'text',
'required' => true
]
],
'loops' => [
]
],
'pageConfig' => [
'format' => 'A4',
'orientation' => 'portrait',
'margin' => '20mm',
'printBackground' => true
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.craftkit.dev/v1/templates"
payload := strings.NewReader("{\n \"name\": \"Invoice\",\n \"slug\": \"invoice\",\n \"description\": \"Standard customer invoice\",\n \"manifest\": {\n \"variables\": [\n {\n \"key\": \"customer.name\",\n \"label\": \"Customer name\",\n \"dataType\": \"text\",\n \"required\": true\n }\n ],\n \"loops\": []\n },\n \"pageConfig\": {\n \"format\": \"A4\",\n \"orientation\": \"portrait\",\n \"margin\": \"20mm\",\n \"printBackground\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.craftkit.dev/v1/templates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Invoice\",\n \"slug\": \"invoice\",\n \"description\": \"Standard customer invoice\",\n \"manifest\": {\n \"variables\": [\n {\n \"key\": \"customer.name\",\n \"label\": \"Customer name\",\n \"dataType\": \"text\",\n \"required\": true\n }\n ],\n \"loops\": []\n },\n \"pageConfig\": {\n \"format\": \"A4\",\n \"orientation\": \"portrait\",\n \"margin\": \"20mm\",\n \"printBackground\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.craftkit.dev/v1/templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Invoice\",\n \"slug\": \"invoice\",\n \"description\": \"Standard customer invoice\",\n \"manifest\": {\n \"variables\": [\n {\n \"key\": \"customer.name\",\n \"label\": \"Customer name\",\n \"dataType\": \"text\",\n \"required\": true\n }\n ],\n \"loops\": []\n },\n \"pageConfig\": {\n \"format\": \"A4\",\n \"orientation\": \"portrait\",\n \"margin\": \"20mm\",\n \"printBackground\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "7c9f0b2e-2b1a-4f3d-9c8e-1a2b3c4d5e6f",
"slug": "invoice",
"currentVersionNumber": 1,
"manifest": {
"variables": [
{
"key": "customer.name",
"label": "Customer name",
"dataType": "text",
"required": true
}
],
"loops": []
}
}{
"error": {
"code": "invalid_request",
"message": "Request body did not match expected shape."
}
}{
"error": {
"code": "unauthorized",
"message": "Missing Bearer token."
}
}{
"error": {
"code": "slug_conflict",
"message": "A template with slug 'invoice' already exists in this project."
}
}Authorizations
Project API key (ck_live_… or ck_test_…) presented as a bearer token.
For embed partner endpoints this is the partner secret key, which is the
same credential type.
Body
application/json
Create/upsert body. manifest and pageConfig are validated against the
shared schema package; layout is an optional explicit CanvasDocument.
Required string length:
1 - 120Show child attributes
Show child attributes
Optional on create (auto-derived from name); ignored by PUT (URL is canonical).
Maximum string length:
120Pattern:
^[a-z0-9]+(?:-[a-z0-9]+)*$Maximum string length:
280Optional CanvasDocument contentJson; synthesized from the manifest when omitted.
Show child attributes
Show child attributes
⌘I