API 文档
  • History
  • Introduction
  • API Category
  • Making API Requests
    • Request Structure
    • Common Params
    • Signature v3
    • Signature
    • Responses
  • Site APIs
    • CreateZone
    • DescribeIdentifications
    • ModifyZone
    • DeleteZone
    • ModifyZoneStatus
    • CheckCnameStatus
    • IdentifyZone
    • DescribeZones
    • VerifyOwnership
    • ExportZoneConfig
    • ImportZoneConfig
    • DescribeZoneConfigImportResult
  • Acceleration Domain Management APIs
    • CreateAccelerationDomain
    • DescribeAccelerationDomains
    • ModifyAccelerationDomain
    • ModifyAccelerationDomainStatuses
    • DeleteAccelerationDomains
    • CreateSharedCNAME
    • BindSharedCNAME
    • DeleteSharedCNAME
  • Site Acceleration Configuration APIs
    • CreateRule
    • DeleteRules
    • DescribeHostsSetting
    • DescribeRules
    • DescribeRulesSetting
    • DescribeZoneSetting
    • ModifyRule
    • ModifyZoneSetting
  • Edge Function APIs
    • CreateFunction
    • DescribeFunctions
    • ModifyFunction
    • CreateFunctionRule
    • DeleteFunction
    • DescribeFunctionRules
    • ModifyFunctionRule
    • ModifyFunctionRulePriority
    • DeleteFunctionRules
    • DescribeFunctionRuntimeEnvironment
    • HandleFunctionRuntimeEnvironment
  • Alias Domain APIs
    • CreateAliasDomain
    • DescribeAliasDomains
    • ModifyAliasDomain
    • ModifyAliasDomainStatus
    • DeleteAliasDomain
  • Security Configuration APIs
    • CreateSecurityIPGroup
    • DescribeSecurityIPGroup
    • ModifySecurityIPGroup
    • DeleteSecurityIPGroup
    • DescribeOriginProtection
    • DescribeSecurityTemplateBindings
    • ModifySecurityPolicy
    • BindSecurityTemplateToEntity
    • DescribeSecurityIPGroupInfo
  • Layer 4 Application Proxy APIs
    • CreateL4Proxy
    • ModifyL4Proxy
    • ModifyL4ProxyStatus
    • DescribeL4Proxy
    • DeleteL4Proxy
    • CreateL4ProxyRules
    • ModifyL4ProxyRules
    • ModifyL4ProxyRulesStatus
    • DescribeL4ProxyRules
    • DeleteL4ProxyRules
    • CreateApplicationProxy
    • ModifyApplicationProxy
    • ModifyApplicationProxyStatus
    • DescribeApplicationProxies
    • DeleteApplicationProxy
    • CreateApplicationProxyRule
    • ModifyApplicationProxyRule
    • ModifyApplicationProxyRuleStatus
    • DeleteApplicationProxyRule
  • Content Management APIs
    • CreatePurgeTask
    • DescribePurgeTasks
    • CreatePrefetchTask
    • DescribePrefetchTasks
    • DescribeContentQuota
  • Data Analysis APIs
    • DescribeDDoSAttackData
    • DescribeDDoSAttackEvent
    • DescribeDDoSAttackTopData
    • DescribeOverviewL7Data
    • DescribeTimingL4Data
    • DescribeTimingL7AnalysisData
    • DescribeTopL7AnalysisData
    • DescribeTimingL7CacheData
    • DescribeTopL7CacheData
  • Log Service APIs
    • DownloadL7Logs
    • DownloadL4Logs
    • CreateCLSIndex
    • CreateRealtimeLogDeliveryTask
    • ModifyRealtimeLogDeliveryTask
    • DeleteRealtimeLogDeliveryTask
    • DescribeRealtimeLogDeliveryTasks
  • Billing APIs
    • CreatePlan
    • UpgradePlan
    • RenewPlan
    • ModifyPlan
    • IncreasePlanQuota
    • DestroyPlan
    • CreatePlanForZone
    • BindZoneToPlan
    • DescribeBillingData
    • DescribeAvailablePlans
  • Certificate APIs
    • DescribeDefaultCertificates
    • ModifyHostsCertificate
  • Load Balancing APIs
    • CreateOriginGroup
    • ModifyOriginGroup
    • DeleteOriginGroup
    • DescribeOriginGroup
    • CreateLoadBalancer
    • ModifyLoadBalancer
    • DeleteLoadBalancer
    • DescribeLoadBalancerList
    • DescribeOriginGroupHealthStatus
  • Custom Response Page APIs
    • CreateCustomizeErrorPage
    • DescribeCustomErrorPages
    • ModifyCustomErrorPage
    • DeleteCustomErrorPage
  • DNS Record APIs
    • CreateDnsRecord
    • DeleteDnsRecords
    • DescribeDnsRecords
    • ModifyDnsRecordsStatus
    • ModifyDnsRecords
  • Diagnostic Tool APIs
    • DescribeIPRegion
  • Version Management APIs
    • CreateConfigGroupVersion
    • DeployConfigGroupVersion
    • DescribeConfigGroupVersionDetail
    • DescribeConfigGroupVersions
    • DescribeDeployHistory
    • DescribeEnvironments
  • Data Types
  • Error Codes
当前内容仅提供英语版本,中文版我们将尽快补充,感谢您的理解。

CreateDnsRecord

1. API Description

Domain name for API request: teo.intl.tencentcloudapi.com.

This API is used to create a DNS record.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter NameRequiredTypeDescription
ActionYesStringCommon Params. The value used for this API: CreateDnsRecord.
VersionYesStringCommon Params. The value used for this API: 2022-09-01.
RegionNoStringCommon Params. This parameter is not required.
ZoneIdYesStringThe site ID of the DNS record.
NameYesStringThe DNS record name.If the domain name is in Chinese, Korean, or Japanese, it needs to be converted to Punycode before being entered.
TypeYesStringDNS record types include:

- A:Points the domain to an external IPv4 address, such as 8.8.8.8.
- AAAA: Points the domain to an external IPv6 address.
- MX: Used for mail servers. When multiple MX records exist, the one with the lowest priority value is preferred.
- CNAME: Points the domain to another domain, which then resolves to the final IP address.
- TXT: Provides identification and description for the domain, commonly used for domain verification and SPF records (anti-spam).
- NS: If you need to delegate a subdomain to another DNS service provider, you need to add an NS record. NS records cannot be added to the root domain.
- CAA: Specifies which Certificate Authorities (CAs) are allowed to issue certificates for the site.
- SRV: Indicates that a specific server is using a particular service, commonly used in Microsoft's directory management systems.

Different record types, such as SRV and CAA, have specific requirements for the host record name and record value format. For detailed descriptions and format examples of each record type, please refer to: Introduction to DNS Record Types.
ContentYesStringDNS record content should be filled in according to the corresponding Type value. If the domain name is in Chinese, Korean, or Japanese, it needs to be converted to Punycode before being entered.
LocationNoStringDNS record resolution location, if not specified, default to "Default," which means the default resolution location and is effective for all regions.
- Resolution location configuration is only applicable when the Type (DNS record type) is A, AAAA, or CNAME.
- Resolution location configuration is only available for Standard and Enterprise packages.

For the values, please refer to: Resolution Lines and Corresponding Codes Enumeration.
TTLNoIntegerTTL (in seconds). The smaller the value, the faster the record changes take effect. Default value: 300
WeightNoIntegerDNS record weight can be specified within the range of -1 to 100. Setting the weight to 0 means the record will not be resolved. If not specified, the default value is -1, indicating that no weight is set.

Weight configuration is only applicable when the Type (DNS record type) is A, AAAA, or CNAME.

Note: For the same subdomain, different DNS records on the same resolution line should either all have weights set or none should have weights set.
PriorityNoIntegerThe MX record priority parameter is only effective when the Type (DNS record type) is MX. The smaller the value, the higher the priority. Users can specify a value in the range of 0 to 50. If not specified, the default value is 0.

3. Output Parameters

Parameter NameTypeDescription
RecordIdStringThe ID of the DNS record.
RequestIdStringThe unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Creating a DNS record

Create a DNS record under the site with ZoneId "zone-225qgrnvbi9w". The record should have the name "www.example.com", be of type "A", contain the value "1.2.3.4", and have a TTL (Time to Live) of 60 seconds.

Input Example

POST / HTTP/1.1
Host: teo.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateDnsRecord
<Common request parameters>

{
    "Priority": 1,
    "Name": "www.example.com",
    "ZoneId": "zone-225qgrnvbi9w",
    "Content": "1.2.3.4",
    "TTL": 300,
    "Type": "A"
}

Output Example

{
    "Response": {
        "RequestId": "5e0a2b4e-df6d-4d2a-ac39-1706cbf8a707"
    }
}

Example2 Create a DNS record to assign weights

Create a DNS record under the site with ZoneId "zone-225qgrnvbi9w". The record should have the name "www.example.com", be of type "A", contain the value "1.2.3.4", have a TTL (Time to Live) of 60 seconds, and a record weight of 100.

Input Example

POST / HTTP/1.1
Host: teo.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateDnsRecord
<Common request parameters>

{
    "ZoneId": "zone-225qgrnvbi9w",
    "Name": "www.example.com",
    "Type": "A",
    "Content": "1.2.3.4",
    "TTL": 60,
    "Weight": 100
}

Output Example

{
    "Response": {
        "RequestId": "5e0a2b4e-df6d-4d2a-ac39-1706cbf8a707",
        "RecordId": "record-225rcy8bw85g"
    }
}

Example3 创建分配解析线路的 DNS 记录

在 ZoneId 为 zone-225qgrnvbi9w 的站点下,创建一个记录名为 www.example.com,记录类型为 A,解析线路为北京(CN.BJ),记录内容为1.2.3.4,缓存时间为60秒的 DNS 记录。

Input Example

POST / HTTP/1.1
Host: teo.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateDnsRecord
<common request parameters>

{
    "ZoneId": "zone-225qgrnvbi9w",
    "Name": "www.example.com",
    "Type": "A",
    "Location": "CN.BJ",
    "Content": "1.2.3.4",
    "TTL": 60
}

Output Example

{
    "Response": {
        "RequestId": "5e0a2b4e-df6d-4d2a-ac39-1706cbf8a707",
        "RecordId": "record-225rcy8bw85g"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

There is no error code related to the API business logic. For other error codes, please see Common Error Codes.