Administrate

Document Templates

Note

The document templates endpoint is part of Version 2.5 (v2.5) of the REST API.

Document Templates allow you to specify templated communication for use with opportunities.

Fields

Attributes:

  • body
  • id
  • name

Getting Document Templates

GET /api/v2.5/system/document_templates/:id
statuscode 200:no error
statuscode 404:does not exist
Using Python:
import json
import requests

response = requests.get('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates/2',
                auth=('<username>', '<password>'))

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates/2 \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates/2';

$options = array(
  'http' => array(
    'method'  => 'GET',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
Example response:
{
    "body": "Basic document template content",
    "name": "BasicTemplate",
    "id": 2
}

Getting more than one Document Template

GET /api/v2.5/system/document_templates
statuscode 200:no error
Using Python:
import json
import requests

response = requests.get('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates',
                auth=('<username>', '<password>'))

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates';

$options = array(
  'http' => array(
    'method'  => 'GET',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
Example response:
[
    {
        "body": "Basic document template content",
        "name": "BasicTemplate",
        "id": 3
    }
]

Filtering

The results for a list of document templates can be filtered. See Version 2.5 (v2.5) for more details.

Creating an Document Template

POST /api/v2.5/system/document_templates
statuscode 200:no error
statuscode 400:bad request
Using Python:
import json
import requests

data = {'body': 'Includes even some {{contact.name}} merge fields', 'name': 'Test document template'}

response = requests.post('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates',
                data=json.dumps(data),
                headers={'content-type': 'application/json'},
                auth=('<username>', '<password>'))

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates \ 
    -H "Content-Type: application/json" \
    -d '{
    "body": "Includes even some {{contact.name}} merge fields", 
    "name": "Test document template"
  }' \ 
    -X POST \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates';

$data = array("body" => "Includes even some {{contact.name}} merge fields",
  "name" => "Test document template");
$options = array(
  'http' => array(
  'method'  => 'POST',
  'content' => json_encode($data),
  'header'=>  "Content-Type: application/json\r\n" .
        "Accept: application/json\r\n" .
        "Authorization: Basic " . base64_encode($credentials)
  )
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
Example response:
{
    "body": "Includes even some {{contact.name}} merge fields",
    "name": "Test document template",
    "id": 4
}

Updating an Document Template

PUT /api/v2.5/system/document_templates/:id
statuscode 200:no error
statuscode 400:bad request
Using Python:
import json
import requests

data = {'name': 'Let us update the name'}

response = requests.put('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates/5',
                data=json.dumps(data),
                headers={'content-type': 'application/json'},
                auth=('<username>', '<password>'))

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates/5 \ 
    -H "Content-Type: application/json" \
    -d '{
    "name": "Let us update the name"
  }' \ 
    -X PUT \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates/5';

$data = array("name" => "Let us update the name");
$options = array(
  'http' => array(
  'method'  => 'PUT',
  'content' => json_encode($data),
  'header'=>  "Content-Type: application/json\r\n" .
        "Accept: application/json\r\n" .
        "Authorization: Basic " . base64_encode($credentials)
  )
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
Example response:
{
    "body": "Includes even some {{contact.name}} merge fields",
    "name": "Let us update the name",
    "id": 5
}

Deleting an Document Template

DELETE /api/v2.5/system/document_templates/:id
statuscode 200:no error
Using Python:
import json
import requests

response = requests.delete('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates/1',
                auth=('<username>', '<password>'))

print response.json
Using Curl:
curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates/1 \ 
    -X DELETE \ 
    -k -u (login):(password)
Using PHP:
<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2.5/system/document_templates/1';

$options = array(
  'http' => array(
    'method'  => 'DELETE',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
Example response:
{
    "body": "Includes even some {{contact.name}} merge fields",
    "name": "Test document template",
    "id": 1
}