Skip to main content

POST /templates

Create a new email template with variable placeholders.

Authentication

JWT Bearer token (dashboard auth)

Request Body

FieldTypeRequiredDescription
namestringYesTemplate name (unique per user)
subjectstringNoEmail subject with {{variables}}
html_contentstringNoHTML body with {{variables}}
text_contentstringNoPlain text body with {{variables}}
Either html_content or text_content (or both) must be provided.

Response

{
  "success": true,
  "data": {
    "template": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Welcome Email",
      "subject": "Welcome to {{company_name}}, {{name}}!",
      "html_content": "<h1>Welcome {{name}}!</h1>",
      "text_content": null,
      "variables": ["company_name", "name"],
      "created_at": "2026-03-07T12:00:00Z",
      "updated_at": "2026-03-07T12:00:00Z"
    }
  }
}

Example

curl -X POST https://app.usesendi.com/api/templates \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Welcome Email",
    "subject": "Welcome to {{company_name}}, {{name}}!",
    "html_content": "<h1>Welcome {{name}}!</h1><p>Thanks for joining {{company_name}}.</p>"
  }'

Errors

StatusErrorCause
400Invalid request dataMissing required fields
409Duplicate nameA template with this name already exists