Autosaves
WARNING
When working with custom endpoints don't forget to allow our server d5aoblv5p04cg.cloudfront.net
as a known origin. Otherwise, you are going to run into CORS issues.
You can take advantage of built-in autosaves to provide better experience for your users.
First you need to enable the autosaves on options using
js
enableAutosaves: true;
We can also set custom autosave interval using: (in seconds). Minimal interval is 30 seconds.
ts
autosaveInterval: 60 * 3; //seconds
List autosaves
- URL:
/{API.AUTOSAVES}
- Method:
GET
- params:
key
,hostname
,templateId
,uuid
This endpoint is called when listing all autosaves.
Response:
json
{
"success": true,
"data": [
{
"uid:": "userID",
"key:": "autosaveKey", //used in GET_AUTOSAVE param when retrieving,
"time:": "ISO 8601 time"
}
]
}
Create autosave
- URL:
/{API.AUTOSAVES}
- Method:
POST
This endpoint is called when autosave is created.
You should use this data to save JSON of the template, time when autosave was created, user id, and unique autosave identifier. This data are then used when retrieving autosave.
Request:
json
{
"definition": "MJML in JSON",
"key": "api key",
"hostname": "origin",
"templateId": "id of the template",
"uuid": "userId"
}
Expected Response: STATUS 200
List autosave
- URL:
/{API.GET_AUTOSAVE}/{autosave-key}
- Method:
GET
- Params
key
,hostname
,templateId
,uuid
INFO
This endpoint appends /{autosave-key}
automatically
This endpoint is called when retrieving created autosave.
Response:
json
{
"success": true,
"data": {
"template": "jsonTemplate"
}
}