> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.houseofapps.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.houseofapps.ai/_mcp/server.

# Create an email template

POST https://api-dev.houseofapps.ai/v1/integrations/email-templates
Content-Type: application/json

Create a TRIGGER or LAYOUT email template for the organization specified in `organization_id`. Authenticate with the House of Apps AI key (`House-Of-Apps-Ai-Key`).

Reference: https://docs.houseofapps.ai/api-reference/overview/platform/email-templates/external-create-email-template-v-1-integrations-email-templates-post

## Request

### Headers

- `House-Of-Apps-Ai-Key` (string, required) — House of Apps AI integration API key

### Body (application/json)

This endpoint expects an ExternalCreateEmailTemplateRequest.

- `name` (string, required)
- `template_type` (enum, required) — Email template kind: full layout shell or trigger body fragment.
  - Allowed values: `trigger`, `layout`
- `html_content` (string, required)
- `organization_id` (string, required) — Target organization UUID
- `id` (string, optional, nullable) — Optional client-provided template UUID; server-generated when omitted
- `subject` (string, optional, nullable) — Plain email subject line (no variable placeholders)
- `variables` (list of EmailTemplateVariableDefinition, optional)
- `status` (enum, optional) — Email template publish state (enforced in API; stored as text in DB).
  - Allowed values: `draft`, `published`
- `is_default` (boolean, optional, default: false) — When true on a LAYOUT, marks the org default shell used by TRIGGER render

## Response

### 201

Created

- `status` (string, required) — Response status
- `message` (string, required) — Human-readable success message
- `statusCode` (integer, required) — HTTP status code
- `code` (string, required) — Custom application status code
- `data` (SuccessResponseData, optional, nullable) — Payload for this endpoint

## Errors

### 422 Unprocessable Entity Error

Unprocessable Entity

- `status` (string, required) — Response status
- `message` (string, required) — Human-readable error message
- `statusCode` (integer, required) — HTTP status code
- `code` (string, required) — Custom application status code
- `messageKey` (string, optional) — i18n key for the message
- `errors` (list of map from string to any, optional) — Optional field-level validation errors

## Types

### EmailTemplateVariableDefinition

Client-facing variable definition (optional id; backend assigns when omitted).

- `variable_key` (string, required) — Placeholder key
- `field_name` (string, required) — Display label
- `field_type` (enum, required) — Field type
  - Allowed values: `text`, `number`, `date`, `yes_no`, `url`, `email`, `phone`, `long_text`, `rich_text`, `dropdown`, `multi_select`, `range_slider`, `currency`, `file_upload`, `image`, `address`, `object`, `list`, `api`
- `id` (string, optional, nullable) — Optional client-provided variable UUID; server-generated when omitted
- `description` (string, optional, nullable)
- `type_config` (map from string to any, optional)
- `is_required` (boolean, optional, default: false)
- `sort_order` (integer, optional, default: 0)
- `sub_fields` (list of EmailTemplateVariableDefinition, optional)

### SuccessResponseData

Payload for this endpoint

- map from string to any
- list of any
- string
- double
- boolean

## Examples

**Request**

```json
{
  "name": "string",
  "template_type": "trigger",
  "html_content": "string",
  "organization_id": "string"
}
```

**Response**

```json
{
  "status": "success",
  "message": "Created successfully",
  "statusCode": 201,
  "code": "2001",
  "data": {}
}
```

**SDK Code**

```python Created
import requests

url = "https://api-dev.houseofapps.ai/v1/integrations/email-templates"

payload = {
    "name": "string",
    "template_type": "trigger",
    "html_content": "string",
    "organization_id": "string"
}
headers = {
    "House-Of-Apps-Ai-Key": "House-Of-Apps-Ai-Key",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Created
const url = 'https://api-dev.houseofapps.ai/v1/integrations/email-templates';
const options = {
  method: 'POST',
  headers: {
    'House-Of-Apps-Ai-Key': 'House-Of-Apps-Ai-Key',
    'Content-Type': 'application/json'
  },
  body: '{"name":"string","template_type":"trigger","html_content":"string","organization_id":"string"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Created
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-dev.houseofapps.ai/v1/integrations/email-templates"

	payload := strings.NewReader("{\n  \"name\": \"string\",\n  \"template_type\": \"trigger\",\n  \"html_content\": \"string\",\n  \"organization_id\": \"string\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("House-Of-Apps-Ai-Key", "House-Of-Apps-Ai-Key")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Created
require 'uri'
require 'net/http'

url = URI("https://api-dev.houseofapps.ai/v1/integrations/email-templates")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["House-Of-Apps-Ai-Key"] = 'House-Of-Apps-Ai-Key'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"string\",\n  \"template_type\": \"trigger\",\n  \"html_content\": \"string\",\n  \"organization_id\": \"string\"\n}"

response = http.request(request)
puts response.read_body
```

```java Created
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api-dev.houseofapps.ai/v1/integrations/email-templates")
  .header("House-Of-Apps-Ai-Key", "House-Of-Apps-Ai-Key")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"string\",\n  \"template_type\": \"trigger\",\n  \"html_content\": \"string\",\n  \"organization_id\": \"string\"\n}")
  .asString();
```

```php Created
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-dev.houseofapps.ai/v1/integrations/email-templates', [
  'body' => '{
  "name": "string",
  "template_type": "trigger",
  "html_content": "string",
  "organization_id": "string"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'House-Of-Apps-Ai-Key' => 'House-Of-Apps-Ai-Key',
  ],
]);

echo $response->getBody();
```

```csharp Created
using RestSharp;

var client = new RestClient("https://api-dev.houseofapps.ai/v1/integrations/email-templates");
var request = new RestRequest(Method.POST);
request.AddHeader("House-Of-Apps-Ai-Key", "House-Of-Apps-Ai-Key");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"string\",\n  \"template_type\": \"trigger\",\n  \"html_content\": \"string\",\n  \"organization_id\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Created
import Foundation

let headers = [
  "House-Of-Apps-Ai-Key": "House-Of-Apps-Ai-Key",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "string",
  "template_type": "trigger",
  "html_content": "string",
  "organization_id": "string"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-dev.houseofapps.ai/v1/integrations/email-templates")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```