Templates API
- Template attributes
- List templates
- Create a template
- Retrieve a template
- Update a template
- Delete a template
Template attributes
Please refer to the definition of the Template
data type in our OpenAPI documentation.
List templates
GET /:account/templates
List templates in the account.
Parameters
Name | Type | Description |
---|---|---|
:account |
integer |
The account id |
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
.
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 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"
},
{
"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
}
}
Errors
Responds with HTTP 401 in case of case of authentication issues.
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 |
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"
}
}
Errors
Responds with HTTP 400 if the template cannot be created.
Responds with HTTP 401 in case of case of authentication issues.
Retrieve 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
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"
}
}
Errors
Responds with HTTP 401 in case of case of authentication issues.
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"
}
}
Errors
Responds with HTTP 400 if the template cannot be updated.
Responds with HTTP 401 in case of case of authentication issues.
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.
Errors
Responds with HTTP 400 if the template cannot be deleted.
Responds with HTTP 401 in case of case of authentication issues.