tencent cloud

Feedback

CreateDnsRecord

Last updated: 2024-12-30 11:48:45

    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 Name Required Type Description
    Action Yes String Common Params. The value used for this API: CreateDnsRecord.
    Version Yes String Common Params. The value used for this API: 2022-09-01.
    Region No String Common Params. This parameter is not required.
    ZoneId Yes String The site ID of the DNS record.
    Name Yes String The DNS record name.If the domain name is in Chinese, Korean, or Japanese, it needs to be converted to Punycode before being entered.
    Type Yes String DNS 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.
    Content Yes String DNS 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.
    Location No String DNS 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.
    TTL No Integer TTL (in seconds). The smaller the value, the faster the record changes take effect. Default value: 300
    Weight No Integer DNS 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.
    Priority No Integer The 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 Name Type Description
    RecordId String The ID of the DNS record.
    RequestId String The 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.

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support