Templates API

List templates

GET /:account/templates

List templates in the account.

Parameters

Name Type Description
:account integer The account id

Example

List all templates in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      https://api.dnsimple.com/v2/1010/templates

Response

Responds with HTTP 200.

{
  "data": [
    {
      "id": 1,
      "account_id": 1010,
      "name": "Alpha",
      "sid": "alpha",
      "description": "An alpha template.",
      "created_at": "2016-03-22T11:08:58Z",
      "updated_at": "2016-03-22T11:08:58Z"
    },
    {
      "id": 2,
      "account_id": 1010,
      "name": "Beta",
      "sid": "beta",
      "description": "A beta template.",
      "created_at": "2016-03-22T11:11:26Z",
      "updated_at": "2016-03-22T11:11:26Z"
    }
  ],
  "pagination": {
    "current_page": 1,
    "per_page": 30,
    "total_entries": 2,
    "total_pages": 1
  }
}

Sorting

For general information about sorting, please refer to the main guide.

Name Description
id Sort templates by ID
name Sort templates by name (alphabetical order)
sid Sort templates by string ID (alphabetical order)

The default sorting policy is by ascending id.

Create a template

POST /:account/templates

Parameters

Name Type Description
:account integer The account id

Example

Create a template in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X POST \
      -d '{"name": "Alpha","sid": "alpha","description": "This is an Alpha template."}' \
      https://api.dnsimple.com/v2/1010/templates

Input

Name Type Description
name string Required.
sid string Required.
description string Required.
Example
{
  "name": "Alpha",
  "sid": "alpha",
  "description": "This is an Alpha template."
}

Response

Responds with HTTP 201 on success.

{
  "data": {
    "id": 1,
    "account_id": 1010,
    "name": "Beta",
    "sid": "beta",
    "description": "A beta template.",
    "created_at": "2016-03-24T11:09:16Z",
    "updated_at": "2016-03-24T11:09:16Z"
  }
}

Responds with HTTP 400 if the validation fails.

Get a template

GET /:account/templates/:template

Parameters

Name Type Description
:account integer The account id
:template integer, string The template id or short name

Example

Get the template with ID 1 in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      https://api.dnsimple.com/v2/1010/template/1

Get the template with short name example in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      https://api.dnsimple.com/v2/1010/template/example

Response

{
  "data": {
    "id": 1,
    "account_id": 1010,
    "name": "Alpha",
    "sid": "alpha",
    "description": "An alpha template.",
    "created_at": "2016-03-22T11:08:58Z",
    "updated_at": "2016-03-22T11:08:58Z"
  }
}

Update a template

PATCH /:account/templates/:template

Parameters

Name Type Description
:account integer The account id
:template integer, string The template id or short name

Example

Update the template with ID 1 in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X PATCH \
      -d '{"name":"Alpha"}' \
      https://api.dnsimple.com/v2/1010/templates/1

Update the template with short name example in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X PATCH \
      -d '{"name":"Alpha"}' \
      https://api.dnsimple.com/v2/1010/templates/example

Input

See create.

Response

Responds with HTTP 200 on success.

{
  "data": {
    "id": 1,
    "account_id": 1010,
    "name": "Alpha",
    "sid": "alpha",
    "description": "An alpha template.",
    "created_at": "2016-03-22T11:08:58Z",
    "updated_at": "2016-03-22T11:08:58Z"
  }
}

Responds with HTTP 400 if the validation fails.

Delete a template

DELETE /:account/templates/:template

Parameters

Name Type Description
:account integer The account id
:template integer, string The template id or short name

Example

Delete the template with ID 1 in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      -X DELETE \
      https://api.dnsimple.com/v2/1010/templates/1

Delete the template with short name example in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      -X DELETE \
      https://api.dnsimple.com/v2/1010/templates/example

Response

Responds with HTTP 204 on success.