Preview a template
POST/v1/templates/{id}/preview
Renders a template version with sample variables and sends nothing. It renders whatever it can and lists problems (missing or mistyped variables, or a mistake in the template), so a preview never fails just because a sample value is not filled in yet. Omit version for the latest, and pass language to preview a translation.
Required scope: templates:manage
Parameters
| Name | In | Description |
|---|---|---|
idrequired | path | The template id. |
Example
curl -X POST 'https://api.sendsend.email/v1/templates/ID/preview' \
-H "Authorization: Bearer $SENDSEND_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"variables": {
"first_name": "Maria"
}
}'Response 200
{
"version": 1,
"subject": "Welcome, Maria",
"html": "<p>Hi Maria!</p>",
"text": null,
"variables": {
"first_name": {
"type": "string",
"required": true
}
},
"problems": []
}Errors
| Status | Code | When |
|---|---|---|
| 404 | not_found | No such resource in this project. |
| 400 | validation_error | The request body or parameters are invalid. The message says which field. |
| 401 | unauthorized | The API key is missing, invalid or revoked. |
| 403 | forbidden | The key does not have the scope this endpoint needs. |
Every error has the same shape. See Errors.