Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time

REST API: POST templates (Publisher)

This method is used to create a new template with the REST API. It uses an HTTP POST request to the following address:

After a successful call the ID of the created request is returned.

Available parameters

  • name: name of the new template (required)
  • description: description of the template
  • from_address: array with a 'name' and 'email' for the from address
  • subject: subject of the template
  • source: the HTML source of the template (required)
  • amp: the AMP source of the template
  • text: the text version of the template

PHP example

The following PHP script demonstrates how to use the API method:

// dependencies

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

// data to be sent to the api
$data = array(
    'name'          =>  'my-test-template',
    'source'        =>  '
        This is a test template.

// do the call
$api->post("templates", $data);

// return id of created request if successful

The example above requires the CopernicaRestApi class.

More information