Appearance
Autosaves
Autosaves write a draft copy of the current template to your backend at a fixed interval, so an interrupted session can be restored from the editor's autosave panel.
Autosaving is off until enabled, and every draft travels through your own API endpoints, which keeps the stored history on your infrastructure.
Enabling autosaves
Add the following setting to TOPOL_OPTIONS:
ts
enableAutosaves: true,Setting the autosave frequency
The autosaveInterval option controls how often a draft is written. The value is in seconds, and the default is 60 seconds when the option is omitted.
ts
autosaveInterval: 60 * 3, // Saves every 3 minutesValues below 30 are raised to 30 seconds. A request is only sent when the template has unsaved changes, so an idle editor produces no autosave traffic at all.
Autosaves also keep the template as it was opened. Before the first autosave of a session, the editor stores a copy of the template as it was when opened, so the state before the first change can be restored. The copy is skipped when:
- the newest autosave already matches the opened template, typically the last autosave of the previous session
- the autosave list or the newest autosave fails to load, so the editor can't rule out a duplicate
To find the newest autosave, the editor calls List Autosaves, then Get a Specific Autosave for every entry that shares the newest time. These calls happen once per session, before the first autosave.
Until a template has any autosaves, the autosave panel shows "No autosaves yet".
Autosaves are attributed to a person through the current user object described in Current user.
INFO
editor.toggleAutosaves() opens and closes the autosave panel from your own UI.
API integration for autosaves
Autosaves use a single API path, AUTOSAVES, as a RESTful collection URL. The editor lists, creates and retrieves drafts on that one base URL, distinguished by HTTP method and path:
| Call | Method and URL |
|---|---|
| List autosaves | GET /{API.AUTOSAVES} |
| Create an autosave | POST /{API.AUTOSAVES} |
| Get one autosave by key | GET /{API.AUTOSAVES}/{autosave-key} |
Changed in V4
Earlier versions used three separate path keys (AUTOSAVES, AUTOSAVE, GET_AUTOSAVE). The AUTOSAVE and GET_AUTOSAVE keys were removed — point AUTOSAVES at a collection endpoint that handles all three calls above.
WARNING
Before implementing the endpoints, check how to work with API endpoints.
Key names
All keys are camelCase. Until the next major the editor also sends the old names (uuid for entityId, current_user_id for currentUserId) and accepts the old snake_case names in responses (created_by, user_id, profile_photo_url), so backends written against them keep working. Every key and type is listed in the backend key reference.
The Landing Page Editor uses this same contract, so one backend implementation serves both editors.
List Autosaves
Called to fetch the list of autosaved drafts for the current template and user.
- URL:
/{API.AUTOSAVES} - Method:
GET - Params:
key,hostname,templateId,entityId
Response:
json
{
"success": true,
"data": [
{
"key": "autosaveKey", // appended to the AUTOSAVES path when retrieving this autosave
"time": "2025-05-01T12:00:00Z", // ISO 8601 time
"createdBy": {
"userId": 0,
"name": "John Doe",
"profilePhotoUrl": "https://example.com/profile.jpg"
}
}
]
}key and time are both required, and time has to be a parseable date. The list is validated as a whole, so a single malformed entry leaves the panel empty rather than dropping just that row.
createdBy is optional and only enriches the display. When it is omitted the panel shows the timestamp alone. When it is present, all three of userId, name and profilePhotoUrl have to be there, otherwise the editor discards the object and falls back to the timestamp.
Create Autosave
Called when the editor creates a new autosave. Store the template JSON, the creation time, the user ID and a unique key, since that key is what the editor sends back when restoring.
- URL:
/{API.AUTOSAVES} - Method:
POST
Request:
json
{
"definition": "{...}", // JSON string of the email template (MJML in JSON)
"key": "api key value",
"hostname": "origin",
"templateId": "id of the template",
"entityId": "entity id",
"currentUserId": "id of the current user" // provided in the current user identification object
}definition arrives as a serialized JSON string, not an object. currentUserId is only included when a current user is configured.
Response:
HTTP 201 Created (any 2xx status is accepted)
Get a Specific Autosave
Called to retrieve a previously saved autosave by its key, which the editor appends to the AUTOSAVES path.
- URL:
/{API.AUTOSAVES}/{autosave-key} - Method:
GET - Params:
key,hostname,templateId,entityId
Response:
json
{
"success": true,
"data": {
"template": "{...}" // JSON string of the saved template
}
}template is the JSON string that was sent as definition.
