---
updatedAt: 2026-07-17T21:11:16.000Z
agentTools:
  projectIndex: https://hub.locally.com/llms.txt
---

# Send email

Send an email using a template.

## Request Parameters

*🏷️ header · unmarked parameters are query params*

| Parameter               | Type   | Required | Description                                                                             |
| ----------------------- | ------ | -------- | --------------------------------------------------------------------------------------- |
| `Locally-Api-Token` 🏷️ | string | Yes      | Locally API token must be passed in the header to authenticate the API consumer.        |
| `email`                 | string | Yes      | The email address to send the product details to.                                       |
| `link`                  | string | Yes      | The link to the product details page.                                                   |
| `template`              | string | Yes      | The email template. E.g. 'save\_for\_later' (Save for Later), 'save\_cart' (Save Cart). |

## Example Request

```curl cURL
curl --get 'https://www.locally.com/headless/api/1.0/email/template/send' \
--header 'Locally-Api-Token: {{API_TOKEN}}' \
--data-urlencode 'email=shopper@example.com' \
--data-urlencode 'link=https://www.locally.com/product/12345' \
--data-urlencode 'template=save_for_later'
```
```javascript JavaScript
const params = new URLSearchParams({
  email: 'shopper@example.com',
  link: 'https://www.locally.com/product/12345',
  template: 'save_for_later'
});

const response = await fetch(`https://www.locally.com/headless/api/1.0/email/template/send?${params}`, {
  headers: {
    'Locally-Api-Token': '{{API_TOKEN}}'
  }
});
const data = await response.json();
console.log(data);
```
```python Python
import requests

url = "https://www.locally.com/headless/api/1.0/email/template/send"
params = {
    "email": "shopper@example.com",
    "link": "https://www.locally.com/product/12345",
    "template": "save_for_later"
}
headers = {"Locally-Api-Token": "{{API_TOKEN}}"}

response = requests.get(url, params=params, headers=headers)
print(response.json())
```

`template` accepts `save_for_later` or `save_cart`. The `link` value must be a `locally.com` URL — links pointing at other domains are rejected.

## Example Response

```json JSON
{
  "success": true,
  "data": {
    "success": 1,
    "session": {
      "id": "abc999"
    }
  },
  "msg": ""
}
```

## Response Explanation

* `success` — `true` means the request was processed and stays `true` even when the email is rejected — check `data.success` for the send outcome; auth and server errors return `false` with an `error_code`.
* `data.success` — `1` when the email was queued, `0` on a validation failure or unrecognized `template` value; booleans inside `data` serialize as `1`/`0`. `save_for_later` sends the same email as [Send Save for Later email](https://hub.locally.com/lcly/docs/headlessapicontrollersend_save_for_later_email).
* `data.session.id` — Session ID returned on every response. Pass it as the `Locally-Api-Session-Id` header on later calls to persist location and cart state; expired or missing IDs are replaced with fresh ones.
* `msg` — Human-readable envelope message: an empty string on success, the error text when `success` is `false` (which also adds an `error_code` field).

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "External Headless API",
    "description": "Welcome to Locally's Headless API documentation. With our Headless API.",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://www.locally.com"
    }
  ],
  "paths": {
    "/headless/api/1.0/email/template/send": {
      "get": {
        "tags": [
          "Utility"
        ],
        "summary": "Send email",
        "description": "Send an email using a template.",
        "operationId": "HeadlessAPIController::email_template_send",
        "parameters": [
          {
            "name": "Locally-Api-Token",
            "in": "header",
            "description": "Locally API token must be passed in the header to authenticate the API consumer",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "description": "The email address to send the product details to.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "link",
            "in": "query",
            "description": "The link to the product details page.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "template",
            "in": "query",
            "description": "The email template. E.g. 'save_for_later' (Save for Later), 'save_cart' (Save Cart)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful"
          },
          "400": {
            "description": "Bad Request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "402": {
            "description": "Request Failed"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          },
          "429": {
            "description": "Too Many Requests"
          },
          "500": {
            "description": "Server Error"
          }
        },
        "security": [
          {
            "HeaderAuthentication": []
          }
        ]
      }
    }
  }
}
```