Skip to main content
POST https://api.craftkit.dev/v1/embed/builder/templates
Creates a template in the authenticated partner’s project from a builder draft. The draft is stored verbatim; if the caller has publish rights and the layout parses as a render-ready document, a first version is published automatically.

Authorization

Accepts either a partner API key or an embed session JWT.
Authorization
string
required
Bearer ck_live_… (partner API key — grants saveDraft and publish) or Bearer <session_token> (embed session JWT — rights come from the session’s permissions claims, and the request must originate from an allow-listed iframe origin).

Body

documentTemplate
object
required
The builder draft to persist. Stored as-is; the whole object is returned (adapted) in the response. Only name, layout, and presetKey are interpreted server-side — all other keys round-trip through the draft.

Response

200 with the created template, adapted to the builder’s documentTemplate shape.
documentTemplate
object

Errors

StatuscodeMeaning
400invalid_jsonBody is not valid JSON.
401missing_or_invalid_authorizationNo bearer token, or neither a valid API key nor a valid session token.
403permission_deniedAuthenticated, but the session lacks saveDraft rights.
500insert_failedThe template row could not be written.
cURL
curl -X POST https://api.craftkit.dev/v1/embed/builder/templates \
  -H "Authorization: Bearer $CRAFTKIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "documentTemplate": {
      "name": "Charter Handover",
      "presetKey": "charter-handover",
      "layout": { "sections": [] }
    }
  }'
200
{
  "documentTemplate": {
    "_id": "0193c2c3-...",
    "organizationId": "proj_01j...",
    "name": "Charter Handover",
    "sD": false,
    "cAt": "2026-06-05T10:00:00.000Z",
    "presetKey": "charter-handover",
    "isCustomTemplate": true,
    "layout": { "sections": [] },
    "design": null
  }
}