> 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/compose.md).

# Compose (one-off send)

Send transactional or ad-hoc email without a campaign. Authenticate with `Authorization: Bearer` (API keys). Use **account\_key** (`acc_…` from Accounts, not the account UUID). Up to 100 recipients per request; daily limits still apply.

## POST `/api/v1/compose`

**Compose (one-off send)**

Send up to 100 recipients without a campaign. Required: account\_key (public acc\_… string, not the account UUID). Content: either template\_id (saved template UUID) or both subject and body — never both. Recipients: manual To list or recipients.type "contacts" with contact\_ids (contact UUIDs from /api/v1/contacts, not template ids). variables fills {{ placeholders }}; omitted required tags return 400 with missing\_variables. Cc/Bcc are not supported on this endpoint (To only).

### Request body — Example — inline subject & body, manual To

Use template\_id instead of subject/body to load a saved template. For contacts, set recipients.type to "contacts" and pass contact\_ids.

```json
{
  "account_key": "acc_YOUR_ACCOUNT_KEY",
  "subject": "Hi {{first_name}}",
  "body": "<p>Code: <strong>{{promo_code}}</strong></p>",
  "recipients": { "emails": ["friend@example.com"] },
  "variables": { "first_name": "Alex", "promo_code": "SAVE20" }
}
```

### Response fields

* **ok** (`boolean`) — True when the request was accepted and sends were attempted.
* **sent** (`number`) — Count of messages queued or sent successfully.
* **failed** (`{ email: string; error: string }[]`) — Per-recipient failures (empty when all succeeded).

### Examples

#### 200 — OK

```json
{ "ok": true, "sent": 1, "failed": [] }
```

#### 400 — Validation

```json
{ "error": "…", "missing_variables": ["promo_code"] }
```

#### 404 — Unknown account

```json
{ "error": "…" }
```

### cURL

```bash
curl -sS -X POST "https://www.mailofly.com/api/v1/compose" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer mf_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"account_key":"acc_…","subject":"Hi {{first_name}}","body":"<p>{{promo_code}}</p>","recipients":{"emails":["friend@example.com"]},"variables":{"first_name":"Alex","promo_code":"SAVE20"}}'
```

## Related

* [Product guide: Compose](/product-guides/compose.md)
* [Templates API](/rest-api/templates.md)
* [Accounts API](/rest-api/accounts.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/compose.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.
