Skip to main content

domain_records

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

Overview

Namedomain_records
TypeResource
Iddigitalocean.compute.domain_records

Fields

The following fields are returned by SELECT queries:

The response will be a JSON object with a key called domain_record. The value of this will be a domain record object which contains the standard domain record attributes.

NameDatatypeDescription
idintegerA unique identifier for each domain record.
namestringThe host name, alias, or service being defined by the record. (example: @)
datastringVariable data depending on record type. For example, the "data" value for an A record would be the IPv4 address to which the domain will be mapped. For a CAA record, it would contain the domain name of the CA being granted permission to issue certificates. (example: ns1.digitalocean.com)
flagsintegerAn unsigned integer between 0-255 used for CAA records.
portintegerThe port for SRV records.
priorityintegerThe priority for SRV and MX records.
tagstringThe parameter tag for CAA records. Valid values are "issue", "issuewild", or "iodef"
ttlintegerThis value is the time to live for the record, in seconds. This defines the time frame that clients can cache queried information before a refresh should be requested.
typestringThe type of the DNS record. For example: A, CNAME, TXT, ... (example: NS)
weightintegerThe weight for SRV records.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
domains_get_recordselectdomain_name, domain_record_idTo retrieve a specific domain record, send a GET request to /v2/domains/$DOMAIN_NAME/records/$RECORD_ID.
domains_list_recordsselectdomain_namename, type, per_page, pageTo get a listing of all records configured for a domain, send a GET request to /v2/domains/$DOMAIN_NAME/records.
The list of records returned can be filtered by using the name and type query parameters. For example, to only include A records for a domain, send a GET request to /v2/domains/$DOMAIN_NAME/records?type=A. name must be a fully qualified record name. For example, to only include records matching sub.example.com, send a GET request to /v2/domains/$DOMAIN_NAME/records?name=sub.example.com. Both name and type may be used together.

domains_create_recordinsertdomain_name, data__typeTo create a new record to a domain, send a POST request to
/v2/domains/$DOMAIN_NAME/records.

The request must include all of the required fields for the domain record type
being added.

See the [attribute table]https://docs.digitalocean.com/products/networking/dns/how-to/manage-records/ for details regarding record
types and their respective required attributes.
domains_patch_recordupdatedomain_name, domain_record_id, data__typeTo update an existing record, send a PATCH request to
/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID. Any attribute valid for
the record type can be set to a new value for the record.

See the [attribute table]https://docs.digitalocean.com/products/networking/dns/how-to/manage-records/ for details regarding record
types and their respective attributes.
domains_update_recordreplacedomain_name, domain_record_id, data__typeTo update an existing record, send a PUT request to
/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID. Any attribute valid for
the record type can be set to a new value for the record.

See the [attribute table]https://docs.digitalocean.com/products/networking/dns/how-to/manage-records/ for details regarding record
types and their respective attributes.
domains_delete_recorddeletedomain_name, domain_record_idTo delete a record for a domain, send a DELETE request to
/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID.

The record will be deleted and the response status will be a 204. This
indicates a successful request with no body returned.

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)
domain_record_idintegerThe unique identifier of the domain record. (example: 3352896)
namestringA fully qualified record name. For example, to only include records matching sub.example.com, send a GET request to /v2/domains/$DOMAIN_NAME/records?name=sub.example.com. (example: sub.example.com)
pageintegerWhich 'page' of paginated results to return. (example: 1)
per_pageintegerNumber of items returned per page (example: 2)
typestringThe type of the DNS record. For example: A, CNAME, TXT, ... (example: A)

SELECT examples

To retrieve a specific domain record, send a GET request to /v2/domains/$DOMAIN_NAME/records/$RECORD_ID.

SELECT
id,
name,
data,
flags,
port,
priority,
tag,
ttl,
type,
weight
FROM digitalocean.compute.domain_records
WHERE domain_name = '{{ domain_name }}' -- required
AND domain_record_id = '{{ domain_record_id }}' -- required
;

INSERT examples

To create a new record to a domain, send a POST request to
/v2/domains/$DOMAIN_NAME/records.

The request must include all of the required fields for the domain record type
being added.

See the [attribute table]https://docs.digitalocean.com/products/networking/dns/how-to/manage-records/ for details regarding record
types and their respective required attributes.

INSERT INTO digitalocean.compute.domain_records (
data__type,
data__name,
data__data,
data__priority,
data__port,
data__ttl,
data__weight,
data__flags,
data__tag,
domain_name
)
SELECT
'{{ type }}' /* required */,
'{{ name }}',
'{{ data }}',
{{ priority }},
{{ port }},
{{ ttl }},
{{ weight }},
{{ flags }},
'{{ tag }}',
'{{ domain_name }}'
RETURNING
domain_record
;

UPDATE examples

To update an existing record, send a PATCH request to
/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID. Any attribute valid for
the record type can be set to a new value for the record.

See the [attribute table]https://docs.digitalocean.com/products/networking/dns/how-to/manage-records/ for details regarding record
types and their respective attributes.

UPDATE digitalocean.compute.domain_records
SET
data__type = '{{ type }}',
data__name = '{{ name }}',
data__data = '{{ data }}',
data__priority = {{ priority }},
data__port = {{ port }},
data__ttl = {{ ttl }},
data__weight = {{ weight }},
data__flags = {{ flags }},
data__tag = '{{ tag }}'
WHERE
domain_name = '{{ domain_name }}' --required
AND domain_record_id = '{{ domain_record_id }}' --required
AND data__type = '{{ type }}' --required
RETURNING
domain_record;

REPLACE examples

To update an existing record, send a PUT request to
/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID. Any attribute valid for
the record type can be set to a new value for the record.

See the [attribute table]https://docs.digitalocean.com/products/networking/dns/how-to/manage-records/ for details regarding record
types and their respective attributes.

REPLACE digitalocean.compute.domain_records
SET
data__type = '{{ type }}',
data__name = '{{ name }}',
data__data = '{{ data }}',
data__priority = {{ priority }},
data__port = {{ port }},
data__ttl = {{ ttl }},
data__weight = {{ weight }},
data__flags = {{ flags }},
data__tag = '{{ tag }}'
WHERE
domain_name = '{{ domain_name }}' --required
AND domain_record_id = '{{ domain_record_id }}' --required
AND data__type = '{{ type }}' --required
RETURNING
domain_record;

DELETE examples

To delete a record for a domain, send a DELETE request to
/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID.

The record will be deleted and the response status will be a 204. This
indicates a successful request with no body returned.

DELETE FROM digitalocean.compute.domain_records
WHERE domain_name = '{{ domain_name }}' --required
AND domain_record_id = '{{ domain_record_id }}' --required
;