Create a template
Create a new email template. The from must be on a domain already verified for the project, or be the project's own sandbox address. A sandbox-sender template can be sent only to the project owner, and a campaign or workflow cannot send from it.
Requires the templates:write scope — Create, edit, and delete your email templates.
API key authentication. Use a sk_* (FULL) or pk_* (SENDING_ONLY) key as the bearer token. Public keys (pk_*) are restricted to the email-send endpoints and the self-serve list subscribe/unsubscribe pair; every other endpoint — event tracking included — answers 403 for them. In scope terms (used by /api/v1/* operations): FULL keys hold every scope; SENDING_ONLY keys hold only emails:send.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Body for POST /api/templates.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/templates" \ -H "Content-Type: application/json" \ -d '{ "name": "string", "subject": "string", "body": "string", "from": "user@example.com" }'{
"success": true,
"data": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"projectId": "5a8591dd-4039-49df-9202-96385ba3eff8",
"name": "string",
"description": "string",
"subject": "string",
"body": "string",
"from": "user@example.com",
"fromName": "string",
"replyTo": "user@example.com",
"emailCategory": "MARKETING",
"currentVersion": 0,
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "2019-08-24T14:15:22Z"
}
}{
"success": false,
"error": {
"message": "string",
"code": "string",
"details": {
"errors": [
null
]
}
}
}{
"success": false,
"error": {
"message": "string",
"code": "string",
"details": {
"errors": [
null
]
}
}
}{
"success": false,
"error": {
"message": "string",
"code": "string",
"details": {
"errors": [
null
]
}
}
}{
"success": false,
"error": {
"message": "string",
"code": "string",
"details": {
"errors": [
null
]
}
}
}{
"success": false,
"error": {
"message": "string",
"code": "string",
"details": {
"errors": [
null
]
}
}
}{
"success": false,
"error": {
"message": "string",
"code": "string",
"details": {
"errors": [
null
]
}
}
}