Implementación API transaccionales
Nombre del servicio
POST https://api.envialosimple.email/api/v1/mail/send
Método de autenticación
Authorization: Bearer <clave API>
Parámetros
Ejemplos
curl --location 'https://api.envialosimple.email/api/v1/mail/send' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYX..jE2NzgzOTA0MjYsImV' \
--header 'Content-Type: application/json' \
--data-raw '{
"from": "notificaciones@empresa.com",
"to": "cliente@prueba.com",
"subject": "Hola {{nombre}} ya está disponible tu factura",
"html": "<html><img src=\"cid:logo\"/> <br> <h4> <b>Hola {{nombre}} {{apellido}}</b> </h4> <p> Adjuntamos tu factura del mes {{mes}} </p> </html>",
"substitutions": {
"nombre": "Juan",
"apellido": "Pérez",
"mes": "02/2023"
},
"attachments": [
{
"id": "logo",
"filename": "logo.jpg",
"disposition": "inline",
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
},
{
"disposition": "attachment",
"filename": "factura.doc",
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
}
]
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.envialosimple.email/api/v1/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 =>'{
"from": "notificaciones@empresa.com",
"to": "cliente@prueba.com",
"subject": "Hola {{nombre}} ya está disponible tu factura",
"html": "<html><img src=\\"cid:logo\\"/> <br> <h4> <b>Hola {{nombre}} {{apellido}}</b> </h4> <p> Adjuntamos tu factura del mes {{mes}} </p> </html>",
"substitutions": {
"nombre": "Juan",
"apellido": "Pérez",
"mes": "02/2023"
},
"attachments": [
{
"id": "logo",
"filename": "logo.jpg",
"disposition": "inline",
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
},
{
"disposition": "attachment",
"filename": "factura.doc",
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
}
]
}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYX..jE2NzgzOTA0MjYsImV',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
import json
url = "https://api.envialosimple.email/api/v1/mail/send"
payload = json.dumps({
"from": "notificaciones@empresa.com",
"to": "cliente@prueba.com",
"subject": "Hola {{nombre}} ya está disponible tu factura",
"html": "<html><img src=\"cid:logo\"/> <br> <h4> <b>Hola {{nombre}} {{apellido}}</b> </h4> <p> Adjuntamos tu factura del mes {{mes}} </p> </html>",
"substitutions": {
"nombre": "Juan",
"apellido": "Pérez",
"mes": "02/2023"
},
"attachments": [
{
"id": "logo",
"filename": "logo.jpg",
"disposition": "inline",
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
},
{
"disposition": "attachment",
"filename": "factura.doc",
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
}
]
})
headers = {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYX..jE2NzgzOTA0MjYsImV',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
var data = JSON.stringify({
"from": "notificaciones@empresa.com",
"to": "cliente@prueba.com",
"subject": "Hola {{nombre}} ya está disponible tu factura",
"html": "<html><img src=\"cid:logo\"/> <br> <h4> <b>Hola {{nombre}} {{apellido}}</b> </h4> <p> Adjuntamos tu factura del mes {{mes}} </p> </html>",
"substitutions": {
"nombre": "Juan",
"apellido": "Pérez",
"mes": "02/2023"
},
"attachments": [
{
"id": "logo",
"filename": "logo.jpg",
"disposition": "inline",
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
},
{
"disposition": "attachment",
"filename": "factura.doc",
"content": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0Nvb…"
}
]
});
var config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.envialosimple.email/api/v1/mail/send',
headers: {
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYX..jE2NzgzOTA0MjYsImV',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});ode
Errores
Última actualización