Skip to content

Create a template

POST
/mail/templates
curl --request POST \
--url https://mail.work.optidata.cloud/api/mail/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form title=example \
--form content=example \
--form 'attachments=[ { "file": "binary", "url": "example", "disposition": "inline", "type": "example" } ]'

Save a reusable message body. Send it as multipart/form-data when it embeds inline images; only jpg, jpeg, png, gif, webp and avif are accepted, at up to 10 MB each. Bodies are capped at 100 000 characters, since larger HTML is clipped by common mail clients anyway.

object
title
string | null
<= 255 characters
content
required

HTML content of the template.

string
<= 100000 characters
attachments

Inline images. Only jpg, jpeg, png, gif, webp and avif are accepted, at up to 10 MB each.

Array<object> | null
object
file
required
string format: binary
url
required

The placeholder URL used inside content.

string
disposition
required
string
type
required
string

The created template. On creation — but not on the later GET /templates/{id} — the owning user is embedded.

Media typeapplication/json
object
id
integer
user_id
integer
title
string | null
content

HTML content.

string
created_at
string
updated_at
string
user

The owning user, embedded only in the template-creation response. The same user shape the suite returns elsewhere.

object
id
integer
uuid
string format: uuid
cuid
string
username
string
email
string format: email
name
string | null
company_name
string | null
role
string | null
status
string | null
created_at
string
updated_at
string
deleted_at
string | null
avatar_url
string | null format: uri
Examplegenerated
{
"id": 1,
"user_id": 1,
"title": "example",
"content": "example",
"created_at": "example",
"updated_at": "example",
"user": {
"id": 1,
"uuid": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"cuid": "example",
"username": "example",
"email": "hello@example.com",
"name": "example",
"company_name": "example",
"role": "example",
"status": "example",
"created_at": "example",
"updated_at": "example",
"deleted_at": "example",
"avatar_url": "https://example.com"
}
}

Missing, malformed or expired authentication key.

Media typeapplication/json

Authentication failures use an error key rather than message.

object
error
required
string
Examples
Examplemissing

No bearer token sent

{
"error": "JWT passport exception: Missing bearer token in request"
}

The request body or query string failed validation.

Media typeapplication/json
object
message
required

The first validation message.

string
errors
required

Validation messages keyed by field name.

object
key
additional properties
Array<string>
Examples
Exampleinvalid
{
"message": "The conversations field is required.",
"errors": {
"conversation_ids": [
"The conversations field is required."
]
}
}

Rate limit exceeded. Retry after the window resets.

Media typeapplication/json

Generic error envelope used by policy, binding and framework failures.

object
message
required

Human-readable description of the failure.

string
Examples
Examplethrottled
{
"message": "Too Many Attempts."
}