Skip to documentation
Dashboard
Templates

Save a template draft

Replace the canonical server draft using optimistic concurrency.

PUT/api/v1/templates/{templateId}/draft
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

Path parameters

Path parameters
NameTypeRequirementDescription
templateIduuidRequiredThe RouteKite template identifier.Example: 27fdc190-3a56-46f0-89e8-88ac64a5087d

Request body

Request fields
NameTypeRequirementDescription
revisionintegerRequiredExpected current revision, starting at 0.
published_version_iduuid | nullRequiredExpected current published version pointer.
subjectstringRequiredSaved subject up to 998 characters.
preview_textstringOptionalSaved preview text up to 240 characters. Defaults to empty.
documentRouteKite documentRequiredCanonical document matching the template purpose and source mode.

Response

Response fields
NameTypeRequirementDescription
objectstringAlwaysAlways template_draft.
template_iduuidAlwaysThe template identifier.
revisionintegerAlwaysThe new server revision.
updated_atdate-timeAlwaysWhen the revision was saved.
published_version_idnullAlwaysAlways null in this draft-save response.
statestringAlwaysAlways draft.

Optimistic concurrency

Send the revision and published pointer returned by Retrieve. A stale value returns TEMPLATE_CONFLICT. Save is distinct from Publish.

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.
404NOT_FOUNDThe template or version is unavailable in this workspace.Check the identifier and workspace.
409TEMPLATE_CONFLICT / DRAFT_REQUIRED / DRAFT_SAVE_REQUIREDThe saved revision changed, no saved draft exists, or an exact legacy compliance footer was upgraded for editing.Retrieve the template, explicitly save the returned draft, and retry with its new revision.
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.