> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailofly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

# Templates

`name` is required; `subject` and `body` (HTML or text) are optional on create (default empty strings).

## GET `/v1/templates`

**List templates**

Lists email templates (name, subject, body HTML).

### Examples

#### 200 — OK

```json theme={null}
{ "data": [ … ] }
```

### cURL

```bash theme={null}
curl -sS -X GET "https://api.mailofly.com/v1/templates" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer mf_live_your_key_here"
```

## POST `/v1/templates`

**Create template**

name is required; subject and body (HTML or text) default to empty strings.

### Request body — Body

```json theme={null}
{
  "name": "Welcome",
  "subject": "Hi there",
  "body": "<p>Thanks for joining.</p>"
}
```

### Examples

#### 201 — Created

```json theme={null}
{ "data": { … } }
```

### cURL

```bash theme={null}
curl -sS -X POST "https://api.mailofly.com/v1/templates" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer mf_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"name":"Welcome","subject":"Hi there","body":"<p>Thanks for joining.</p>"}'
```

## GET `/v1/templates/{id}`

**Get template**

Fetch one template.

### Examples

#### 200 — OK

```json theme={null}
{ "data": { … } }
```

### cURL

```bash theme={null}
curl -sS -X GET "https://api.mailofly.com/v1/templates/00000000-0000-0000-0000-000000000001" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer mf_live_your_key_here"
```

## PATCH `/v1/templates/{id}`

**Update template**

Partial update of name, subject, body.

### Request body — Body

```json theme={null}
{ "subject": "Updated" }
```

### Examples

#### 200 — OK

```json theme={null}
{ "data": { … } }
```

### cURL

```bash theme={null}
curl -sS -X PATCH "https://api.mailofly.com/v1/templates/00000000-0000-0000-0000-000000000001" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer mf_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"subject":"Updated"}'
```

## DELETE `/v1/templates/{id}`

**Delete template**

Deletes the template.

### Examples

#### 200 — OK

```json theme={null}
{ "ok": true }
```

### cURL

```bash theme={null}
curl -sS -X DELETE "https://api.mailofly.com/v1/templates/00000000-0000-0000-0000-000000000001" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer mf_live_your_key_here"
```

## Related

* [Product: Templates](../product/templates.md)
* [Campaigns API](campaigns.md)
* [← API overview](README.md)


## Related topics

- [Introduction](/templates/introduction.md)
- [Create Template](/api/templates/create-template.md)
- [Delete Template](/api/templates/delete-template.md)
- [Retrieve Template](/api/templates/get-template.md)
- [List Templates](/api/templates/list-templates.md)
