Creating a Record Set
Function
Create a record set.
The DNS service allows you to create multi-line record sets only in public zones.
URI
POST /v2.1/zones/{zone_id}/recordsets
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
zone_id |
Yes |
String |
Zone ID. Only public zones are supported. You can obtain the value by calling the API in Querying Public Zones. |
Request
- Parameter description
Table 2 Parameters in the request Parameter
Mandatory
Type
Description
name
Yes
String
Fully qualified domain name (FQDN) suffixed with a zone name, which is a complete host name ended with a dot
A domain name is case insensitive. Uppercase letters will also be converted into lowercase letters.
description
No
String
(Optional) Description of the domain name, which cannot exceed 255 characters
The value is left blank by default.
type
Yes
String
Record set type
The value can be A, AAAA, MX, CNAME, TXT, NS, SRV, or CAA.
For details, see Record Set Type.
status
No
String
Status of the record set
The value can be:
- ENABLE: The record set will be enabled.
- DISABLE: The record set will be disabled.
If the value is left empty, the status of the record set depends on the status of the domain name:
- The status of the record set will be set to Enable if the status of the zone is ACTIVE.
- The status of the record set will be set to Disabled if the status of the zone is Disabled.
ttl
No
Integer
Record set cache duration (in seconds) on a local DNS server. The longer the duration is, the slower the update takes effect.
If your service address is frequently changed, set TTL to a smaller value.
Value range:
- Public zone: 1–2147483647
- Private zone: 300–2147483647
The default value is 300.
records
No
Array of strings
Value of the record set. The value format varies depending on record set types.
For example, the value of an AAAA record set is the IPv6 address list mapped to the domain name.
When an alias record is used, this parameter is not required.
line
No
String
Resolution line ID.
The default value is the default line.
tags
No
Array of object
Resource tag. For details, see Table 3.
The value is left blank by default.
weight
No
Integer
Weight of the record set
- If this value is left blank, the default value 1 takes effect.
- If weight is set to 0, the record set is a secondary one.
- If weight is larger than 0, the record set is a primary one.
The value ranges from 0 to 1000.
You can create a maximum of 20 record sets with the same name, type, and resolution line but different weight values.
alias_target
No
Object
Domain name alias. For details, see Table 4.
The value is left blank by default.
Table 3 Description of the tags field Parameter
Mandatory
Type
Description
key
Yes
String
Tag key
A key can contain up to 36 Unicode characters. key must be specified. Equal signs (=), asterisks (*), left angle brackets (<), right angle brackets (>), backslashes (\), commas (,), vertical bars (|), and slashes (/) are not allowed. The first and last characters cannot be spaces.
value
No
String
Tag value
Each value can contain a maximum of 43 Unicode characters and can be an empty string. Equal signs (=), asterisks (*), left angle brackets (<), right angle brackets (>), backslashes (\), commas (,), vertical bars (|), and slashes (/) are not allowed. The first and last characters cannot be spaces.
- Example request
Add record sets for the zone whose ID is 2c9eb155587194ec01587224c9f90149:
POST https://{DNS_Endpoint}/v2.1/zones/2c9eb155587194ec01587224c9f90149/recordsets
- A type
{ "name": "www.example.com.", "description": "This is an example record set.", "type": "A", "ttl": 3600, "records": [ "192.168.10.1", "192.168.10.2" ], "line":"default_view", "weight":1, "tags": [ { "key": "key1", "value": "value1" } ] }
- AAAA type
{ "name": "www.example.com.", "description": "This is an example record set.", "type": "AAAA", "ttl": 3600, "records": [ "fe80:0:0:0:202:b3ff:fe1e:8329", "ff03:0db8:85a3:0:0:8a2e:0370:7334" ], "line":"default_view", "weight":1, "tags": [ { "key": "key1", "value": "value1" } ] }
- MX type
{ "name": "www.example.com.", "description": "This is an example record set.", "type": "MX", "ttl": 3600, "records": [ "1 mail.example.com" ], "line":"default_view", "weight":1, "tags": [ { "key": "key1", "value": "value1" } ] }
- CNAME type
{ "name": "sale.example.com.", "description": "This is an example record set.", "type": "CNAME", "ttl": 3600, "records": [ "server1.example.com" ], "line":"default_view", "weight":1, "tags": [ { "key": "key1", "value": "value1" } ] }
- TXT type
{ "name": "server1.example.com.", "description": "This is an example record set.", "type": "TXT", "ttl": 300, "records": [ "\"This host is used for sale.\"" ], "line":"default_view", "weight":1, "tags": [ { "key": "key1", "value": "value1" } ] }
- NS type
{ "name": "server1.example.com.", "description": "This is an example record set.", "type": "NS", "ttl": 300, "records": [ "node1.example.com.", "node2.example.com." ], "line":"default_view", "weight": 1, "tags": [ { "key": "key1", "value": "value1" } ] }
- SRV type
{ "name": "_sip._tcp.example.com.", "description": "This is an example record set.", "type": "SRV", "ttl": 300, "records": [ "3 60 2176 sipserver.example.com.", "10 100 2176 sipserver.example.com." ], "line":"default_view", "weight":1, "tags": [ { "key": "key1", "value": "value1" } ] }
- CAA type
{ "name": "www.example.com.", "description": "This is an example record set.", "type": "CAA", "ttl": 300, "records": [ "0 issue \"example.com\"", "0 issuewild \"www.certinomis.com\"", "0 iodef \"mailto:xx@example.org\"", "0 iodef \"http://iodef.example.com\"" ], "line":"default_view", "weight":1, "tags": [ { "key": "key1", "value": "value1" } ] }
- A type (alias)
{ "name": "www.example.com.", "description": "This is an example record set.", "type": "A", "ttl": 3600, "alias_target": { "resource_type": "cloudsite", "resource_domain_name": "2018122211053616ucavdwdh.cname.ysjianzhan.cn." } }
- A type
Response
- Parameter description
Table 5 Parameters in the response Parameter
Type
Description
id
String
Record set ID
name
String
Record set name
description
String
Record set description
zone_id
String
Zone ID of the record set
zone_name
String
Zone name of the record set
type
String
Record set type
The value can be A, AAAA, MX, CNAME, TXT, NS, SRV, or CAA.
For details, see Record Set Type.
ttl
Integer
Record set cache duration (in seconds) on a local DNS server. The longer the duration is, the slower the update takes effect.
If your service address is frequently changed, set TTL to a smaller value.
records
Array of strings
Record set value
created_at
String
Time when the record set was created
The UTC time format is used: YYYY-MM-DDTHH:MM:SSZ.
updated_at
String
Time when the record set was updated
The UTC time format is used: YYYY-MM-DDTHH:MM:SSZ.
status
String
Resource status
For details, see Resource Status.
default
Boolean
Whether the record set is created by default. A default record set cannot be deleted.
project_id
String
Project ID of the record set
links
Object
Link to the current resource or other related resources. When a response is broken into pages, a next link is provided to retrieve all results. For details, see Table 6.
line
String
Resolution line ID
weight
Integer
Weight of the record set
health_check_id
String
Health check ID
alias_target
Object
Domain name alias. For details, see Table 4.
- Example response
{ "id": "2c9eb155587228570158722b6ac30007", "name": "www.example.com.", "description": "This is an example record set.", "type": "A", "ttl": 300, "records": [ "192.168.10.1", "192.168.10.2" ], "status": "PENDING_CREATE", "links": { "self": "https://Endpoint/v2.1/zones/2c9eb155587194ec01587224c9f90149/recordsets/2c9eb155587228570158722b6ac30007" }, "zone_id": "2c9eb155587194ec01587224c9f90149", "zone_name": "example.com.", "created_at": "2016-11-17T12:03:17.827", "updated_at": null, "default": false, "project_id": "e55c6f3dc4e34c9f86353b664ae0e70c", "line": "default_view", "weight": 1, "health_check_id":null }
Returned Value
If a 2xx status code is returned, for example, 200, 202, or 204, the request is successful.
For details, see Status Code.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot