# Emails

## Send Email

<mark style="color:green;">`POST`</mark> `https://api.codemash.io/:version/notifications/email`

Send an email message.

#### Path Parameters

| Name    | Type   | Description                    |
| ------- | ------ | ------------------------------ |
| version | string | A version of the API endpoint. |

#### Headers

| Name           | Type   | Description                                                                                            |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------ |
| Authorization  | string | Secret API key which belongs to your project or user. Not required if using cookies with a session ID. |
| x-cm-projectid | string | Your project's ID. Can be passed as a query parameter.                                                 |

#### Request Body

| Name                 | Type    | Description                                                                                                                                                            |
| -------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| templateId           | string  | The ID of the email template to use.                                                                                                                                   |
| cultureCode          | string  | Language code. If you have more than one language set in your project you can use this parameter to specify which language template to use.                            |
| forceRequestLanguage | string  | If the recipient user has a language set, user language is used to select a template language. This forces us to use cultureCode parameter instead of user's language. |
| roles                | array   | Roles of users to be set as recipients.                                                                                                                                |
| emails               | array   | An array of emails to be set as recipients.                                                                                                                            |
| users                | array   | An array of user IDs to be set as recipients.                                                                                                                          |
| ccEmails             | array   | An array of emails to be set as CC recipients.                                                                                                                         |
| ccUsers              | array   | An array of user IDs to be set as CC recipients.                                                                                                                       |
| bccEmails            | array   | An array of emails to be set as BCC recipients.                                                                                                                        |
| bccUsers             | array   | An array of user IDs to be set as BCC recipients.                                                                                                                      |
| tokens               | object  | Key-value pair (string: string) object of custom tokens.                                                                                                               |
| postpone             | integer | Amount of milliseconds to postpone sending the email.                                                                                                                  |
| respectTimeZone      | boolean | If creating a postponed email and the recipient of an email has a timezone set, then postpones according to the recipient's timezone.                                  |

{% tabs %}
{% tab title="200 Returns true if request was successfully processed." %}

```javascript
{
    "result": true
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title=".NET" %}

```csharp
var client = new CodeMashClient(apiKey, projectId);
var emailService = new CodeMashEmailService(client);

var response = await emailService.SendEmailAsync(new SendEmailRequest
{
    TemplateId = Guid.Parse("{TEMPLATE_ID}"),
    Emails = new [] { "test@email.com" }
});
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashEmail;

class CodemashService
{
    protected CodemashEmail $codemashEmail;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $this->codemashEmail = new CodemashEmail($client);
    }

    public function sendEmail()
    {
        $responseData = $this->codemashEmail->send([
            'templateId' => '{TEMPLATE_ID}',
            'emails' => [
                'test1@example.com',
                'test2@example.com',
                'test3@example.com',
            ],
        ]);
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
More about templates and template languages [here](https://docs.codemash.io/dashboard/notifications/email/templates).
{% endhint %}
