Skip to documentation
Dashboard
Templates

Create a template

Create a workspace template with a server-backed draft.

POST/api/v1/templates
On this page

Authentication

Send a RouteKite API key as a Bearer token. This endpoint requires the template:write scope.

Required headers
NameTypeRequirementDescription
AuthorizationstringRequiredBearer API key with the required workspace scope.Example: Bearer rk_your_key
Content-TypestringRequiredMust be application/json.Example: application/json

Request body

Request fields
NameTypeRequirementDescription
namestringRequiredTemplate name from 2 to 120 characters.
descriptionstring | nullOptionalDescription up to 500 characters.
purposemarketing | transactionalRequiredImmutable compliance purpose.
source_modevisual | htmlOptionalImmutable authoring mode. Defaults to visual.
subjectstringOptionalInitial subject from 1 to 998 characters. Defaults to the name.
preview_textstringOptionalInitial preview text up to 240 characters.
documentRouteKite documentOptionalCanonical document matching purpose and source_mode. A blank document is generated when omitted.

Response

Response fields
NameTypeRequirementDescription
objectstringAlwaysAlways template.
iduuidAlwaysThe template identifier.
namestringAlwaysThe template name.
descriptionstring | nullAlwaysOptional template description.
purposemarketing | transactionalAlwaysThe immutable compliance purpose.
source_modevisual | htmlAlwaysThe immutable authoring mode.
statedraft | publishedAlwaysThe current template state.
industrystring | nullAlwaysOptional industry metadata.
tonestring | nullAlwaysOptional tone metadata.
published_version_iduuid | nullAlwaysThe current immutable published version.
created_atdate-timeAlwaysWhen the template was created.
updated_atdate-timeAlwaysWhen the template metadata or state last changed.
draft.revisionintegerWhen savedThe server-authoritative draft revision.
draft.base_published_version_iduuid | nullWhen savedThe published version the draft was based on.
draft.schema_versionintegerWhen savedThe canonical document schema version.
draft.source_documentobjectWhen savedThe canonical editable document.
draft.requires_savebooleanWhen savedTrue only when RouteKite presented the exact prior canonical compliance footer with current locked markers. Save this returned document before Publish.
draft.subjectstringWhen savedThe saved subject.
draft.preview_textstringWhen savedThe saved inbox preview text.

Immutable identity

purpose and source_mode are fixed at creation. Omit document to start with RouteKite's canonical blank document for that purpose and mode.

Errors

StatusCodeWhat it meansWhat to do
400INVALID_REQUEST / INVALID_JSON / INVALID_CURSORThe JSON, identifier, field, document, or cursor is invalid.Correct the reported input.
400INVALID_TEMPLATE_DOCUMENTThe document is invalid or its purpose and source mode do not match the template.Submit a canonical RouteKite document matching the template.
401UNAUTHORIZEDThe API key is missing, invalid, revoked, or expired.Check the Bearer header and active key.
403FORBIDDENThe key lacks the required template scope.Use template:read or template:write as documented for the operation.
429RATE_LIMITEDToo many template requests were sent.Honor Retry-After before retrying.
500TEMPLATE_OPERATION_FAILED / INTERNAL_ERRORThe template operation could not complete.Retry after a short delay.
403API_KEY_ACTOR_UNAVAILABLEThe key creator is no longer a workspace member.Replace the API key with one created by a current member.
413PAYLOAD_TOO_LARGEThe request body exceeds 1,100,000 bytes.Reduce the document or request metadata.
422COMPLIANCE_REQUIRED / TEMPLATE_COMPILATION_FAILED / SOURCE_UNAVAILABLEA marketing compliance block is missing or hidden, the draft cannot compile, or a source has no saved content to duplicate.Restore the canonical visible compliance block, or correct and save the source content.