Skip to content

Email API

From the REST API you can perform most of the actions that can be done through the web application, the most representative is sending email

Main Parameters

  • name: Name to identify the shipment
  • subject: Subject
  • pid: Template Id
  • rid: Sender Id

To select the recipients, you can indicate a group identifier (for sending to several contacts at the same time) or single contact identifier:

  • gid: Group Id
  • contact_id: Copntact Id

See the full list of parameters in POST /campaign/

export TE_TOKEN='Your token'

curl -X POST https://app.teenvio.com/v4/public/api/rest/v3/campaign/ \
-H "X-Token: $TE_TOKEN" \
-H "content-type: application/json" \
-d '{
    "rid":1,
    "pid":1,
    "contact_id":1,
    "name":"test vars",
    "subject":"This is a test",
    "vars":{
        "discount": 20,
        "expire": "Enero"
    }
}'
<?php

$token = 'Your token';

$url_base = 'https://app.teenvio.com/v4/public/api/rest/v3'

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_URL => $url_base.'/campaign/',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array(
        'Accept: application/json',
        'X-Token: $token',
        'Content-Type: appliation/json'
    ),
    CURLOPT_POSTFIELDS => '{
        "rid":1,
        "pid":1,
        "contact_id":1,
        "name":"test vars",
        "subject":"This is a test",
        "vars":{
            "discount": 20,
            "expire": "Enero"
        }
    }'
);

$response = curl_exec($curl);

curl_close($curl);
echo $response;
import requests

token = 'Your token'

url_base = 'https://app.teenvio.com/v4/public/api/rest/v3'

my_headers = {
    'Accept' : 'application/json',
    'X-Token' : token,
    'Content-Type' : 'application/json'
}
post_request = {
    "rid":1,
    "pid":1,
    "contact_id":1,
    "name":"test vars",
    "subject":"This is a test",
    "vars":{
        "discount": 20,
        "expire": "Enero"
    }
}

response = requests.post(url_base+"/campaign/", json=post_request, headers=my_headers)

print(response.json())
const axios= require('axios');

const token = 'Your token';

const url_base = 'https://app.teenvio.com/v4/public/api/rest/v3';

const my_headers = {
    'Accept' : 'application/json',
    'X-Token' : token
};

const post_request = 
    "rid":1,
    "pid":1,
    "contact_id":1,
    "name":"test vars",
    "subject":"This is a test",
    "vars":{
        "discount": 20,
        "expire": "Enero"
    }
};

axios.post(url_base+'/campaign/', post_request, {headers:my_headers}).then(resp => {
    console.log(resp.data);
});

Response:

{
    "action": "send_bulk_campaign",
    "time": "2022-10-26 14:39:29",
    "status": "OK",
    "response": 1334,
    "code": 0
}

More Info