Templates
Create and manage Templates
Retrieve a list of templates
GET /templates
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Number of items to return. |
after | string | no | Return items after this cursor. |
before | string | no | Return items before this cursor. |
Example
curl -X GET "$SESAMESEND_URL/templates" \
-H "Authorization: Bearer $OPENSEND_API_KEY"Responses
| Status | Description |
|---|---|
200 | OK |
{
"object": "list",
"data": [
{
"id": "string",
"name": "string",
"status": "draft",
"published_at": "2023-10-06 23:47:56.678+00",
"created_at": "2023-10-06 23:47:56.678+00",
"updated_at": "2023-10-06 23:47:56.678+00",
"alias": "string"
}
],
"has_more": true
}Create a template
POST /templates
Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | The name of the template. |
alias | string | no | The alias of the template. |
from | string | no | Sender email address. To include a friendly name, use the format "Your Name <sender@example.com>". |
subject | string | no | Email subject. |
reply_to | string[] | no | Reply-to email addresses. |
html | string | yes | The HTML version of the template. |
text | string | no | The plain text version of the template. |
variables | object[] | no | |
variables[].key | string | yes | The key of the variable. |
variables[].type | "string" | "number" | "boolean" | "object" | "list" | yes | The type of the variable. |
variables[].fallback_value | string | number | boolean | object | any[] | no | The fallback value of the variable. |
Example
curl -X POST "$SESAMESEND_URL/templates" \
-H "Authorization: Bearer $OPENSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "string",
"html": "string"
}'Responses
| Status | Description |
|---|---|
201 | OK |
{
"id": "string",
"object": "template"
}Retrieve a single template
GET /templates/{id}
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Template ID or alias. |
Example
curl -X GET "$SESAMESEND_URL/templates/<id>" \
-H "Authorization: Bearer $OPENSEND_API_KEY"Responses
| Status | Description |
|---|---|
200 | OK |
{
"object": "template",
"id": "string",
"current_version_id": "string",
"name": "string",
"alias": "string",
"from": "string",
"subject": "string",
"reply_to": null,
"html": "string",
"text": "string",
"variables": [
{
"id": "string",
"key": "string",
"type": "string",
"fallback_value": "string",
"created_at": "2023-10-06 23:47:56.678+00",
"updated_at": "2023-10-06 23:47:56.678+00"
}
],
"created_at": "2023-10-06 23:47:56.678+00",
"updated_at": "2023-10-06 23:47:56.678+00",
"status": "draft",
"published_at": "2023-10-06 23:47:56.678+00",
"has_unpublished_versions": true
}Update an existing template
PATCH /templates/{id}
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Template ID or alias. |
Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | no | The name of the template. |
alias | string | no | The alias of the template. |
from | string | no | Sender email address. To include a friendly name, use the format "Your Name <sender@example.com>". |
subject | string | no | Email subject. |
reply_to | string[] | no | Reply-to email addresses. |
html | string | no | The HTML version of the template. |
text | string | no | The plain text version of the template. |
variables | object[] | no | |
variables[].key | string | yes | The key of the variable. |
variables[].type | "string" | "number" | "boolean" | "object" | "list" | yes | The type of the variable. |
variables[].fallback_value | string | number | boolean | object | any[] | no | The fallback value of the variable. |
Example
curl -X PATCH "$SESAMESEND_URL/templates/<id>" \
-H "Authorization: Bearer $OPENSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'Responses
| Status | Description |
|---|---|
200 | OK |
{
"id": "string",
"object": "template"
}Remove an existing template
DELETE /templates/{id}
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Template ID or alias. |
Example
curl -X DELETE "$SESAMESEND_URL/templates/<id>" \
-H "Authorization: Bearer $OPENSEND_API_KEY"Responses
| Status | Description |
|---|---|
200 | OK |
{
"object": "template",
"id": "string",
"deleted": true
}Publish a template
POST /templates/{id}/publish
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Template ID or alias. |
Example
curl -X POST "$SESAMESEND_URL/templates/<id>/publish" \
-H "Authorization: Bearer $OPENSEND_API_KEY"Responses
| Status | Description |
|---|---|
200 | OK |
{
"id": "string",
"object": "template"
}Duplicate a template
POST /templates/{id}/duplicate
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Template ID or alias. |
Example
curl -X POST "$SESAMESEND_URL/templates/<id>/duplicate" \
-H "Authorization: Bearer $OPENSEND_API_KEY"Responses
| Status | Description |
|---|---|
200 | OK |
{
"id": "string",
"object": "template"
}