# Отправить

## Отправка email сообщения&#x20;

<mark style="color:green;">`POST`</mark> `https://do.myfreshcloud.com/mail/ send`

#### Request Body

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| mail<mark style="color:red;">\*</mark> | String | JSON        |

{% tabs %}
{% tab title="200: OK Стандартный объект ответа" %}

```javascript
{
  "status": "success",
  "error": null,
  "code": "0",
  "rows": 1,
  "pages": 1,
  "page": 1,
  "value": ""
}
```

{% endtab %}
{% endtabs %}

## JSON

<details>

<summary>Все доступны параметры нового объекта  </summary>

* **account\_id** - Код почтового аккаунта в системе (\*обязательное)
* **to\_address** - Кому (\*обязательное)
* **subject** - Темы в формате ⚡️**Base64** (\*обязательное)
* **body** - Содержания письма в формате ⚡️**Base64**  (\*обязательное)
* **cc -** Копия
* **bcc -** Скрытая копия
* **company\_id** - Код контрагента, к которому будет повязано письма
* **contact\_id** - Код контакта, к которому будет повязано письма
* **deal\_id** - Код сделки, к которому будет повязано письма

</details>

```
{
    "mail" : {
              "account_id" : "4",
              "to_address" : "hello@example.com",
              "subject" : "SGFwcHkh",
              "body" : "SGVsbG8h" 
              }
}

```

{% hint style="info" %}
**Обязательные параметры**\
account\_id (Можно взять в списке аккаунтов)\
to\_address\
subject\
body
{% endhint %}

## Пример

{% tabs %}
{% tab title="cURL" %}

```
url --location --request POST 'https://do.myfreshcloud.com/mail/send' \
--header 'Authorization: Bearer XXXXXX.XXXXXXXX.XXXXXXX' \
--header 'Content-Type: application/json' \
--data-raw '{
    "mail" : {
              "account_id" : "4",
              "to_address" : "exemple@gmail.com",
              "subject" : "SGFwcHkh",
              "body" : "SGVsbG8h" 
              }
}'
```

{% endtab %}

{% tab title="PHP" %}

```
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://do.myfreshcloud.com/mail/send',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "mail" : {
              "account_id" : "4",
              "to_address" : "exemple@gmail.com",
              "subject" : "SGFwcHkh",
              "body" : "SGVsbG8h" 
              }
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer XXXXXX.XXXXXXXX.XXXXXXXX',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}

{% tab title="NodeJS (Request) " %}

```
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://do.myfreshcloud.com/mail/send',
  'headers': {
    'Authorization': 'Bearer XXXXXXXX.XXXXXXXXXXX.XXXXXXX',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "mail": {
      "account_id": "4",
      "to_address": "iskuzer@gmail.com",
      "subject": "SGFwcHkh",
      "body": "SGVsbG8h"
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endtab %}
{% endtabs %}

{% content-ref url="/pages/sa5JLu6FKkBkJkbgBfvI" %}
[Почтовые аккаунты](/reference/mail/accounts.md)
{% endcontent-ref %}

## Ответ

```
{
  "status": "success",
  "error": null,
  "code": "0",
  "rows": 1,
  "pages": 1,
  "page": 1,
  "value": ""
}
```


---

# 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://apidoc.myfreshcloud.com/reference/mail/send.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.
