# Emails

## Get users

<mark style="color:blue;">`GET`</mark> `https://www.example.com/index.php?page=acymailing_front&option=com_acym&ctrl=api&task=getEmails`

Gets emails created in AcyMailing (campaigns, notifications, overrides, templates, etc...)

#### Query Parameters

| Name    | Type  | Description                                                                                                                                                                                                                                                                                                               |
| ------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| offset  | Int   | Defaults to 0. Used for pagination, skips the first X results.                                                                                                                                                                                                                                                            |
| limit   | Int   | Defaults to 100. Used for pagination, limits the number of results.                                                                                                                                                                                                                                                       |
| filters | Array | <p>You can filter emails by type and search by name:</p><p>\[</p><p>    "search": "christmas",</p><p>    "type": "standard"</p><p>]</p><p></p><p>Available types are:</p><p>- standard</p><p>- notification</p><p>- override</p><p>- welcome</p><p>- unsubscribe</p><p>- automation</p><p>- followup</p><p>- template</p> |

#### Headers

| Name                                      | Type   | Description                                                                                         |
| ----------------------------------------- | ------ | --------------------------------------------------------------------------------------------------- |
| Api-Key<mark style="color:red;">\*</mark> | String | The API key of a valid AcyMailing license used in the AcyMailing configuration page, tab "License". |

{% tabs %}
{% tab title="200: OK The list of found emails or an empty array" %}

```json
[
    {
        "id": "81",
        "name": "New year newsletter",
        "creation_date": "2024-12-27 14:53:54",
        "subject": "Happy new year!"
    }
]
```

{% endtab %}

{% tab title="422: Unprocessable Entity When the type specified in the filter does not exist" %}

```javascript
{
    "message": "Invalid type."
}
```

{% endtab %}
{% endtabs %}

## Send an email to a user

<mark style="color:green;">`POST`</mark> `https://www.example.com/index.php?page=acymailing_front&option=com_acym&ctrl=api&task=sendEmailToSingleUser`

This sends an email by ID to a single user, existing or not

#### Headers

| Name                                           | Type   | Description                                                                                         |
| ---------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------- |
| Api-Key<mark style="color:red;">\*</mark>      | String | The API key of a valid AcyMailing license used in the AcyMailing configuration page, tab "License". |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                                                                                    |

#### Request Body

| Name                                      | Type   | Description                                                                                                                                                                                                                                                                               |
| ----------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| email<mark style="color:red;">\*</mark>   | String | The email address of the receiver.                                                                                                                                                                                                                                                        |
| autoAddUser                               | Bool   | <p>Defaults to false.</p><p>If the email address doesn't match an existing AcyMailing user, one will be automatically created if this option is set to true.</p>                                                                                                                          |
| emailId<mark style="color:red;">\*</mark> | Int    | The mail ID to send. This is not a campaign ID but the mail ID of the table xxx\_acym\_mail in the database, or the mail\_id of a campaign.                                                                                                                                               |
| trackEmail                                | Bool   | <p>Defaults to true.</p><p>If true, the open/click statistics will be collected for this email.</p>                                                                                                                                                                                       |
| params                                    | Array  | <p>An optional array of shortcodes and values to replace in the body of the sent email.</p><p>Example:</p><p>\[</p><p>    "shortcode1": "value 1"</p><p>]</p><p>If the body of the sent email contains the text "{shortcode1}", it will be replaced by "value 1" in the sent version.</p> |

{% tabs %}
{% tab title="200: OK The email has been sent" %}

```json
{
    "message": "Email sent successfully."
}
```

{% endtab %}

{% tab title="404: Not Found The provided data don't match existing elements" %}

```json
{
    "message": "User doesn't exist"
}
```

```json
{
    "message": "Email doesn't exist"
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Missing parameters" %}

```json
{
    "message": "Receiver email address not provided in the request body."
}
```

```json
{
    "message": "Email ID not provided in the request body."
}
```

{% endtab %}

{% tab title="500: Internal Server Error An error occurred" %}

```
{
    "message": "Error sending."
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://docs.acymailing.com/rest-api/emails.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
