Skip to main content

domains

Creates, updates, deletes, gets or lists a domains resource.

Overview

Namedomains
TypeResource
Iddigitalocean.compute.domains

Fields

The following fields are returned by SELECT queries:

The response will be a JSON object with a key called domain. The value of this will be an object that contains the standard attributes defined for a domain.

NameDatatypeDescription
namestringThe name of the domain itself. This should follow the standard domain format of domain.TLD. For instance, example.com is a valid domain name. (example: example.com)
ip_addressstringThis optional attribute may contain an IP address. When provided, an A record will be automatically created pointing to the apex domain. (example: 192.0.2.1)
ttlintegerThis value is the time to live for the records on this domain, in seconds. This defines the time frame that clients can cache queried information before a refresh should be requested.
zone_filestringThis attribute contains the complete contents of the zone file for the selected domain. Individual domain record resources should be used to get more granular control over records. However, this attribute can also be used to get information about the SOA record, which is created automatically and is not accessible as an individual record resource. (example: $ORIGIN example.com.
$TTL 1800
example.com. IN SOA ns1.digitalocean.com. hostmaster.example.com. 1415982609 10800 3600 604800 1800
example.com. 1800 IN NS ns1.digitalocean.com.
example.com. 1800 IN NS ns2.digitalocean.com.
example.com. 1800 IN NS ns3.digitalocean.com.
example.com. 1800 IN A 1.2.3.4
)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
domains_getselectdomain_nameTo get details about a specific domain, send a GET request to /v2/domains/$DOMAIN_NAME.
domains_listselectper_page, pageTo retrieve a list of all of the domains in your account, send a GET request to /v2/domains.
domains_createinsertTo create a new domain, send a POST request to /v2/domains. Set the "name"
attribute to the domain name you are adding. Optionally, you may set the
"ip_address" attribute, and an A record will be automatically created pointing
to the apex domain.
domains_deletedeletedomain_nameTo delete a domain, send a DELETE request to /v2/domains/$DOMAIN_NAME.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
domain_namestringThe name of the domain itself. (example: example.com)
pageintegerWhich 'page' of paginated results to return. (example: 1)
per_pageintegerNumber of items returned per page (example: 2)

SELECT examples

To get details about a specific domain, send a GET request to /v2/domains/$DOMAIN_NAME.

SELECT
name,
ip_address,
ttl,
zone_file
FROM digitalocean.compute.domains
WHERE domain_name = '{{ domain_name }}' -- required;

INSERT examples

To create a new domain, send a POST request to /v2/domains. Set the "name"
attribute to the domain name you are adding. Optionally, you may set the
"ip_address" attribute, and an A record will be automatically created pointing
to the apex domain.

INSERT INTO digitalocean.compute.domains (
data__name,
data__ip_address
)
SELECT
'{{ name }}',
'{{ ip_address }}'
RETURNING
domain
;

DELETE examples

To delete a domain, send a DELETE request to /v2/domains/$DOMAIN_NAME.

DELETE FROM digitalocean.compute.domains
WHERE domain_name = '{{ domain_name }}' --required;