> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/zdns/private-zone-record/addprivatezonerecord.md).

# AddPrivateZoneRecord

## 1. API Description

This API (AddPrivateZoneRecord) is used to add a DNS record to a specified DNS Zone.

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type                                                              | Description                                                                                                                                                                                                                                                               |
| -------------- | -------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| zoneId         | Yes      | String                                                            | <p>DNS Zone ID.</p><p>It can be obtained by calling <a href="/api-reference/zdns/private-zone/describeprivatezones.md">DescribePrivateZones</a>.</p>                                                                                                                      |
| type           | Yes      | [RecordType](/api-reference/zdns/datastructure.md#recordtype)     | DNS record type.                                                                                                                                                                                                                                                          |
| recordName     | Yes      | String                                                            | <p>Host record.</p><p>Host records are domain prefixes. Common usages include www, @, \* (wildcard resolution), and mail (commonly used for email services).</p><p>For example, to resolve @.example.com, the host record should be filled with "@" instead of empty.</p> |
| value          | Yes      | String                                                            | DNS record value.                                                                                                                                                                                                                                                         |
| weight         | No       | Integer                                                           | <p>DNS record weight.</p><p>Value range: \[1, 100]</p><p>Default value: 1</p>                                                                                                                                                                                             |
| ttl            | No       | Integer                                                           | <p>Domain local cache time.</p><p>Unit: seconds.</p><p>Valid values: 5-86400 (up to one day).</p><p>Value range: \[5, 86400]</p><p>Default value: 60</p>                                                                                                                  |
| priority       | No       | Integer                                                           | <p>Priority of the MX record.</p><p>A smaller value indicates a higher priority.</p><p>Default value: 1.</p><p>Value range: \[1, 99]</p>                                                                                                                                  |
| remark         | No       | String                                                            | <p>Note information.</p><p>The length is up to 255 characters.</p>                                                                                                                                                                                                        |
| line           | No       | String                                                            | <p>Request source.</p><p><code>default</code> is the default value, i.e., global.</p><p>You can also specify a region ID, such as asia-east-1.</p>                                                                                                                        |
| status         | No       | [RecordStatus](/api-reference/zdns/datastructure.md#recordstatus) | <p>The state of the DNS record.</p><p>Default value: Enabled</p>                                                                                                                                                                                                          |

## 3. Output Parameters

| Parameter Name | Type   | Description                                                                                                           |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| requestId      | String | <p>The unique request ID, which is returned for each request.</p><p>RequestId is required for locating a problem.</p> |
| recordId       | String | DNS record ID of a DNS Zone.                                                                                          |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
\*\*Add an A record and enable it. \*\*

```json
POST /api/v2/zdns HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: AddPrivateZoneRecord
<Common Request Params>

Request：
{
  "zoneId": "<zoneId>",
  "type": "A",
  "recordName": "www",
  "value": "10.0.0.1",
  "weight": 10,
  "ttl": 10,
  "remark": "Test",
  "status": "Enabled"
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "recordId": "<recordId>"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](/api-reference/api-introduction/toolkit/api-sdk.md)，to make it easier for you to call APIs. More programming languages will be supported.

## 6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see [Common Error Codes](/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code                         | Description              |
| ---------------- | ---------------------------------- | ------------------------ |
| 404              | INVALID\_PRIVATE\_ZONE\_NOT\_FOUND | DNS Zone does not exist. |
| 400              | INVALID\_RECORD\_VALUE             | Invalid record value.    |
| 409              | INVALID\_RECORD\_VALUE\_CONFLICT   | Record value conflict.   |
| 404              | INVALID\_REGION\_NOT\_FOUND        | Region does not exist.   |
