Template versions
Saving a template replaces it. Every saved state is kept, so the content a save replaced is still readable, and you can put it back.
One row per save. Version 1 is the create, and each update appends the next.
Read the history
curl -s https://api.lockally.com/v1/templates/$ID/versions \
-H "Authorization: Bearer $LOCKALLY_API_KEY"
{
"data": [
{
"version": 3,
"name": "Order receipt",
"subject": "Your order {{order_id}}",
"html": "<p>Thanks {{first_name}}.</p>",
"text": "Thanks {{first_name}}.",
"variables": ["order_id", "first_name"],
"actor": "ada@yourcompany.com",
"created_at": "2026-10-20T13:22:08Z"
},
{
"version": 2,
"name": "Order receipt",
"subject": "Your order {{order_id}}",
"html": "<p>Rewritten.</p>",
"text": "",
"variables": ["order_id"],
"actor": "API key ci-deploy",
"created_at": "2026-10-20T13:19:51Z"
}
]
}
Newest first. The first entry is always what the template says now.
actor is the administrator’s email, or API key <label> when the save came
through the API. Each version reports its own variables, derived from the
content it holds rather than from the template’s current content.
GET /v1/templates/{id}/versions/{version} returns one version on its own.
Both need templates:read.
Roll back
curl -X POST https://api.lockally.com/v1/templates/$ID/versions/2/restore \
-H "Authorization: Bearer $LOCKALLY_API_KEY"
The response is the template as it now stands. Needs templates:write, so a
read-only key can study the history and not change anything.
In the console
A template’s page has a Version history panel: every save with its time and who made it, View to read any version in full, and Restore on anything but the current one. The editor above refreshes to the restored content, so what you see is what is stored.
The cap
The last 50 versions per template are kept, pruned oldest-first as you save. Nothing warns you when an old version falls off the end, so for a template that changes constantly the history is a recent window rather than a complete record. If you need the complete record, keep the source in your own repository and push it as part of a release: that also gives you review and a diff, which this does not.
Two things history does not cover
Deleting a template deletes its history. DELETE /v1/templates/{id} is
immediate and takes the versions with it. There is no soft delete and no
recovery, so delete remains the one irreversible operation here. Export
anything you might want first:
curl -s https://api.lockally.com/v1/templates/$ID/versions \
-H "Authorization: Bearer $LOCKALLY_API_KEY" > template-$ID-history.json
Nothing before this feature existed was recorded. Templates that predate it start at version 1 holding their content as it stood when history was switched on, timestamped when that content was saved, with the actor shown as unknown because nothing recorded it at the time. Edits made before that are gone.
A save is still a full replace
Versions make the overwrite recoverable. They do not make it a patch.
curl -X PUT https://api.lockally.com/v1/templates/$ID \
-H "Authorization: Bearer $LOCKALLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Order receipt", "subject": "Your order", "html": "<p>Hi</p>" }'
That omits text and therefore erases it, and every message from the template
becomes single-part HTML. It succeeds. The difference now is that the previous
version is one restore away instead of gone.
Read the template, change what you mean to change, write the whole object back.
The id still survives an edit
Editing keeps the template id, which is what makes a hard-coded id safe to
leave in your application while the wording changes. It also means a caller
cannot pin itself to a version: there is no way to send with
template_id + version, and /v1/send always renders the current content.
If a send must be reproducible against exact content, store that content in your application and send it inline rather than referencing a template.