For an email to be technically treated as transactional, it is essential that the sender is configured with the purpose "transactional emails".
For sending mail to a single contact, specific methods are provided to optimize requests and facilitate integration.
You can send an email to a single contact following the same steps as if we were using the teenvio web interface:
Create or update the contact
Create the template
Launch the email
But this system has the following problems:
Latency: 3 requests are generated for each launch
Accumulation of creativities: We generating a creativity template for each launch.
To solve this we have this tools:
Don't generate the template for each launch
Analyze the types of communications, For example, an e-commerce has the following types:
Sing up confirmation
password recovery
order confirmation
Shipping confirmation
Whe can build 4 teenvio templates with their respective wildcards or launch vars
Use the agrupated method
We can use the POST /bulkcampaign/ request that can unify the requests for creating a template, creating or modifying contact and launching the email, as explained in the previous point, it is highly recommended to use some templates previously created instead of generating the content of the email in each request, it will be more agile and easier to maintain.
importrequeststoken='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,"name":"transactional test from api","subject":"subject transactional email","recipients":["contact1@domain.com","contact2@domain.com"],"vars":{"descuento":20,"caducidad":"noviembre"},"pid":26}response=requests.post(url_base+"/bulkcampaign/",json=post_request,headers=my_headers)print(response.json())
constaxios=require('axios');consttoken='Your token';consturl_base='https://app.teenvio.com/v4/public/api/rest/v3';constmy_headers={'Accept':'application/json','X-Token':token};constpost_request={"rid":1,"name":"transactional test from api","subject":"subject transactional email","recipients":["contact1@domain.com","contact2@domain.com"],"vars":{"descuento":20,"caducidad":"noviembre"},"pid":26}axios.post(url_base+'/bulkcampaign/',post_request,{headers:my_headers}).then(resp=>{console.log(resp.data);});