<p>Hello ###nombre###,
This is a custom email </p>
The data ###nombre### (name) will be obtained from the data of each contact and will be personalized for each of the participants of an email or campaign
The contact variables are enclosed between three hash marks (###) and the name of the fields of the contact record can be consulted in:
Contact Fields or POST /campaign/
The launch variables are data that are exclusively associated with the shipment and will be sent to all the participants of said shipment or campaign (a single contact in a transactional email).
These variables are provided in the sending request and it is a dictionary, hash or associative array in json whose key is the name of the variable and the value is the data to be parsed.
Wildcards for send variables will be the passed variable names enclosed in square brackets ( [[[var_name]]])
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,"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())
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,"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);});
If we assume that the name field of the contact id 1 is "Ana", the result of the sending would be the following content:
<p>Hola Ana, Aprovecha
el descuento del 20% antes de que termine Enero.</p>
SMS custom vars
For SMS we always have to take into account the limitation on the number of characters (160 characters per SMS/credit). For this reason, the personalization of SMS is simpler, with a single wildcard that can be personalized by a single variable and in order to control the length of the SMS, a maximum length is requested for the content of the personalized field.
The following data will be used to personalize the SMS:
custom_field: Name of the field to use to customize the text
custom_field_length: Field length
The wildcard to be used within the text of the SMS will be:
curl -X POST https://app.teenvio.com/v4/public/api/rest/v3/sms \-H "X-Token: $token"\-H "content-type: application/json"\-d '{ "name": "hola mundo", "email": "contact@domain.com", "tel": "+34666666666", "src": "teenvio", "custom_field": "nombre", "custom_field_length": 20, "text":"Hola ###personalizado###, este es un test por api desde curl"}'
<?php$curl=curl_init();$url_base='https://app.teenvio.com/v4/public/api/rest/v3'curl_setopt_array($curl,array(CURLOPT_CUSTOMREQUEST=>'POST',CURLOPT_URL=>$url_base.'/sms/',CURLOPT_RETURNTRANSFER=>true,CURLOPT_HTTPHEADER=>array('Accept: application/json','X-Token: $token','Content-Type: application/json'),CURLOPT_POSTFIELDS=>'{ "name": "hola mundo", "email": "contact@domain.com", "tel": "+34666666666", "src": "teenvio", "custom_field": "nombre", "custom_field_length": 20, "text":"Hola ###personalizado###, este es un test por api desde curl" }'));$response=curl_exec($curl);curl_close($curl);echo$response;
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={"name":"hola mundo","email":"contact@domain.com","tel":"+34666666666","src":"teenvio","custom_field":"nombre","custom_field_length":20,"text":"Hola ###personalizado###, este es un test por api desde curl"}response=requests.post(url_base+"/sms/",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={"name":"hola mundo","email":"contact@domain.com","tel":"+34666666666","src":"teenvio","custom_field":"nombre","custom_field_length":20,"text":"Hola ###personalizado###, este es un test por api desde curl"}axios.post(url_base+'/sms/',post_request,{headers:my_headers}).then(resp=>{console.log(resp.data);});