> For the complete documentation index, see [llms.txt](https://docs.mailofly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mailofly.com/rest-api/templates.md).

# Templates

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

## GET `/api/v1/templates`

**List templates**

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

### Examples

#### 200 — OK

```json
{ "data": [ … ] }
```

### cURL

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

## POST `/api/v1/templates`

**Create template**

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

### Request body — Body

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

### Examples

#### 201 — Created

```json
{ "data": { … } }
```

### cURL

```bash
curl -sS -X POST "https://www.mailofly.com/api/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 `/api/v1/templates/{id}`

**Get template**

Fetch one template.

### Examples

#### 200 — OK

```json
{ "data": { … } }
```

### cURL

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

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

**Update template**

Partial update of name, subject, body.

### Request body — Body

```json
{ "subject": "Updated" }
```

### Examples

#### 200 — OK

```json
{ "data": { … } }
```

### cURL

```bash
curl -sS -X PATCH "https://www.mailofly.com/api/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 `/api/v1/templates/{id}`

**Delete template**

Deletes the template.

### Examples

#### 200 — OK

```json
{ "ok": true }
```

### cURL

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

## Related

* [Product: Templates](/product-guides/templates.md)
* [Campaigns API](/rest-api/campaigns.md)
* [← API overview](/rest-api/api.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mailofly.com/rest-api/templates.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
