REST API v4: GET emailing templates (drag and drop template)

You can use the REST API to retrieve all emailing templates for an account with an HTTP GET call to the following URL:

https://api.copernica.com/v4/draganddrop/templates

Available parameters

The following parameters are available for this call:

  • name: Retrieve templates with this name.
  • keyword: Retrieve templates with this keyword.
  • type: Type of template ('json' or 'html').
  • created_before: Date after which the templates should have been created in YYYY-MM-DD HH:MM:SS format.
  • created_after: Date before which the templates should have been created in YYYY-MM-DD HH:MM:SS format.

Returned fields

The method returns a JSON object where the *data field contains an array with emailing templates. Each template contains the following information:

  • id: The ID of the template.
  • name: The name of the template.
  • from_address: The from address for the template. Array containing a 'name' and 'email' field.
  • subject: The template subject.
  • type: The template type ('json' or 'html').
  • archived: Whether or not the template is archived.
  • directory: The directory in which the template is located (if any).

JSON example

A single template will look something like this:

{  
   "id":"2820",
   "name":"Theme: conference",
   "from_address":{  
      "name":"Infinity",
      "email":"info@valtaf.nl"
   },
   "subject":"Infinity conference",
   "type":"json",
   "archived":false,
   "directory":"78"
}

PHP example

The script below demonstrates how to use this API method.

// dependencies
require_once('CopernicaRestAPI.php');

// change this into your access token
$api = new CopernicaRestAPI("your-access-token", 4);

// parameters for the call (only retrieve JSON templates)
$params = array(
    type    = 'json'
);

// execute the call
print_r($api->get("draganddrop/templates", $params));

This example requires the REST API class

More information