Create a template
const url = 'https://mail.work.optidata.cloud/api/mail/templates';const form = new FormData();form.append('title', 'example');form.append('content', 'example');form.append('attachments', '[ { "file": "binary", "url": "example", "disposition": "inline", "type": "example" } ]');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
HTML content of the template.
Inline images. Only jpg, jpeg, png, gif, webp and avif are
accepted, at up to 10 MB each.
object
The placeholder URL used inside content.
object
HTML content of the template.
Inline images. Only jpg, jpeg, png, gif, webp and avif are
accepted, at up to 10 MB each.
object
The placeholder URL used inside content.
Examples
{ "title": "Invoice reminder", "content": "<p>Hi, just a reminder that invoice {{number}} is due.</p>"}Responses
Section titled “ Responses ”The created template. On creation — but not on the later
GET /templates/{id} — the owning user is embedded.
object
HTML content.
The owning user, embedded only in the template-creation response. The same user shape the suite returns elsewhere.
object
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.
Authentication failures use an error key rather than message.
object
Examples
No bearer token sent
{ "error": "JWT passport exception: Missing bearer token in request"}The request body or query string failed validation.
object
The first validation message.
Validation messages keyed by field name.
object
Examples
{ "message": "The conversations field is required.", "errors": { "conversation_ids": [ "The conversations field is required." ] }}Rate limit exceeded. Retry after the window resets.
Generic error envelope used by policy, binding and framework failures.
object
Human-readable description of the failure.
Examples
{ "message": "Too Many Attempts."}