Implementación API transaccionales
POST https://api.envialosimple.email/api/v1/mail/send
Authorization: Bearer <clave API>
Nombre | Tipo | Descripción |
---|---|---|
from | string | Remitente del email. Requerido. Este campo puede informarse con varios formatos: Empresa <[email protected]> {"email": "[email protected] "} {"email": "[email protected] ", "name": "Empresa"} |
to | string | Destinatario del email. Requerido. Este campo puede informarse con varios formatos: Cliente <[email protected]>{"email":"[email protected]"} {"email":"[email protected]", "name": "Cliente"} |
subject | string | Asunto del correo. Requerido. |
html | string | Contenido del email en html. Requerido informar el contenido en html o text o templateID. |
text | string | Contenido del email en texto plano. Requerido informar el contenido en html o text o templateID. |
templateID | string | Contenido del email desde una plantilla. Debe informarse el ID de la plantilla. Requerido informar el contenido en html o text o templateID. |
attachments | object[] | Archivos adjuntos al email. Opcional. En el contenido del correo electrónico podrán adjuntarse como archivos normales o dejarlos embebidos en el código usando la sintaxis dentro del código html <img src="cid:id"/>. |
attachments.*.disposition | string | Tipo de adjuntos. Requerido. Valores posibles: inline -> Embebidos en el diseño. Sólo para los contenidos html, no puede usasrse en plantillas. attachment -> Adjuntos al email (comunes) |
Attachments.*.id | string | Id del adjunto para incorporarlo embebido dentro del html. Sólo requerido para attachments.disposition = inline. |
attachments.*.filename | string | Nombre del archivo adjunto. Requerido. |
attachments.*.disposition | string | Tipo de adjuntos. Requerido. Valores posibles: inline -> Embebidos en el diseño attachment -> Adjuntos normales (debajo del email) |
attachments.*.content | string | Contenido del adjunto en Base64. Máximo: 15MB. Requerido. |
substitutions | object[] | Variables. Opcional. Estos valores serán reemplazados en el contenido del correo electrónico utilizando el formato {{var}}. Se puede utilizar en los campos de asunto, html y texto. |
substitutions.*.var | string | La etiqueta tendrá el nombre de la variable y dentro el valor con el cual deberá reemplazarse. OBS: En el valor no pueden inyectarse entidades HTML (ejemplo <p>, <h1>, etc). |
cURL
PHP
Python
NodeJs
1
curl --location 'https://api.envialosimple.email/api/v1/mail/send' \
2
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYX..jE2NzgzOTA0MjYsImV' \
3
--header 'Content-Type: application/json' \
4
--data-raw '{
5
"from": "[email protected]",
6
"to": "[email protected]",
7
"subject": "Hola {{nombre}} ya está disponible tu factura",
8
"html": "<html><img src=\"cid:logo\"/> <br> <h4> <b>Hola {{nombre}} {{apellido}}</b> </h4> <p> Adjuntamos tu factura del mes {{mes}} </p> </html>",
9
"substitutions": {
10
"nombre": "Juan",
11
"apellido": "Pérez",
12
"mes": "02/2023"
13
},
14
"attachments": [
15
{
16
"id": "logo",
17
"filename": "logo.jpg",
18
"disposition": "inline",
19
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
20
},
21
{
22
"disposition": "attachment",
23
"filename": "factura.doc",
24
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
25
}
26
]
27
}'
1
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://api.envialosimple.email/api/v1/mail/send',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'POST',
14
CURLOPT_POSTFIELDS =>'{
15
"from": "[email protected]",
16
"to": "[email protected]",
17
"subject": "Hola {{nombre}} ya está disponible tu factura",
18
"html": "<html><img src=\\"cid:logo\\"/> <br> <h4> <b>Hola {{nombre}} {{apellido}}</b> </h4> <p> Adjuntamos tu factura del mes {{mes}} </p> </html>",
19
"substitutions": {
20
"nombre": "Juan",
21
"apellido": "Pérez",
22
"mes": "02/2023"
23
},
24
"attachments": [
25
{
26
"id": "logo",
27
"filename": "logo.jpg",
28
"disposition": "inline",
29
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
30
},
31
{
32
"disposition": "attachment",
33
"filename": "factura.doc",
34
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
35
}
36
]
37
}',
38
CURLOPT_HTTPHEADER => array(
39
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYX..jE2NzgzOTA0MjYsImV',
40
'Content-Type: application/json'
41
),
42
));
43
44
$response = curl_exec($curl);
45
46
curl_close($curl);
47
echo $response;
48
1
import requests
2
import json
3
4
url = "https://api.envialosimple.email/api/v1/mail/send"
5
6
payload = json.dumps({
7
"from": "[email protected]",
8
"to": "[email protected]",
9
"subject": "Hola {{nombre}} ya está disponible tu factura",
10
"html": "<html><img src=\"cid:logo\"/> <br> <h4> <b>Hola {{nombre}} {{apellido}}</b> </h4> <p> Adjuntamos tu factura del mes {{mes}} </p> </html>",
11
"substitutions": {
12
"nombre": "Juan",
13
"apellido": "Pérez",
14
"mes": "02/2023"
15
},
16
"attachments": [
17
{
18
"id": "logo",
19
"filename": "logo.jpg",
20
"disposition": "inline",
21
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
22
},
23
{
24
"disposition": "attachment",
25
"filename": "factura.doc",
26
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
27
}
28
]
29
})
30
headers = {
31
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYX..jE2NzgzOTA0MjYsImV',
32
'Content-Type': 'application/json'
33
}
34
35
response = requests.request("POST", url, headers=headers, data=payload)
36
37
print(response.text)
38
1
var axios = require('axios');
2
var data = JSON.stringify({
3
"from": "[email protected]",
4
"to": "[email protected]",
5
"subject": "Hola {{nombre}} ya está disponible tu factura",
6
"html": "<html><img src=\"cid:logo\"/> <br> <h4> <b>Hola {{nombre}} {{apellido}}</b> </h4> <p> Adjuntamos tu factura del mes {{mes}} </p> </html>",
7
"substitutions": {
8
"nombre": "Juan",
9
"apellido": "Pérez",
10
"mes": "02/2023"
11
},
12
"attachments": [
13
{
14
"id": "logo",
15
"filename": "logo.jpg",
16
"disposition": "inline",
17
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
18
},
19
{
20
"disposition": "attachment",
21
"filename": "factura.doc",
22
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
23
}
24
]
25
});
26
27
var config = {
28
method: 'post',
29
maxBodyLength: Infinity,
30
url: 'https://api.envialosimple.email/api/v1/mail/send',
31
headers: {
32
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYX..jE2NzgzOTA0MjYsImV',
33
'Content-Type': 'application/json'
34
},
35
data : data
36
};
37
38
axios(config)
39
.then(function (response) {
40
console.log(JSON.stringify(response.data));
41
})
42
.catch(function (error) {
43
console.log(error);
44
});ode
Error | Descripción |
---|---|
Missing key 'from' | Es requerido indicar el remitente del email (from). |
Missing key 'to' | Es requerido indicar el destinatario del email (to). |
Missing key 'subject' | Es requerido indicar el asunto del email (subject). |
A key 'text' or 'html' or 'templateID' must be provided. | Es requerido indicar el contenido del email: html y/o text o plantilla. |
Key 'text' too large. | El campo "text" supera la cantidad máxima de caracteres permitidos (1M). |
Key 'html' too large. | El campo "html" supera la cantidad máxima de caracteres permitidos (2M). |
Missing key 'disposition' in attachment N. | Es requerido indicar el tipo de adjunto (disposition) para el adjunto N. |
Missing key 'content' in attachment N. | Es requerido indicar el contenido (content) para el adjunto N. |
Key 'content' too large in attachment N. | El campo "content" supera la cantidad máxima de caracteres permitidos (15M) para el adjunto N. |
Missing key 'filename' in attachment N. | Es requerido indicar el contenido (filename) para el adjunto N. |
Key 'content' is not a valid base64 encoded string in attachment N. | El campo "content" no contiene un string base64 válido para el adjunto N. |
A key 'id' must be provided when content disposition is 'inline' in attachment N. | Es requerido indicar el identificador (id) para el adjunto N. |
Substitution for email <target-email> contains a key name that exceeds the N chars limit. | El nombre de la variable supera el límite establecido de N caracteres (64). |
Substitution for email <target-email> contains a value that exceeds the N chars limit at key '<key-name>'. | El valor de la variable supera el límite establecido de N caracterers (1024). |
A key 'html' or 'templateID' only. | Solo debe indicarse un único tipo de contenido: html y/o text o plantilla. |
Última actualización 1mo ago