---
title: pydo.domains.create_record()
description: Create a New Domain Record
product: Reference
url: https://docs.digitalocean.com/reference/pydo/reference/domains/create_record/
last_updated: "2026-11-06"
---

> **For AI agents:** The documentation index is at [https://docs.digitalocean.com/llms.txt](https://docs.digitalocean.com/llms.txt). Markdown versions of pages use the same URL with `index.html.md` in place of the HTML page (for example, append `index.html.md` to the directory path instead of opening the HTML document).

# pydo.domains.create_record()

Generated on 6 Nov 2026 from `pydo` version [`v0.45.0`](https://github.com/digitalocean/pydo/releases/tag/v0.45.0)

## Usage

```python
client.domains.create_record(
    domain_name="example.com",
    body={
        "type": "NS",
        "name": "@",
        "data": "ns1.digitalocean.com",
        ...,
    },
)
```

Returns `JSON` Raises `HttpResponseError`

## Description

To create a new record to a domain, send a POST request to [`/v2/domains/{domain_name}/records`](https://docs.digitalocean.com/reference/api/reference/domain-records/index.html.md).

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

See the [attribute table](#tag/Domain-Records) for details regarding record types and their respective required attributes.

## Parameters

`domain_name` string required

The name of the domain itself.

`id` integer optional read-only

Example: `28448429`

A unique identifier for each domain record.

`type` string required

Example: `NS`

The type of the DNS record. For example: A, CNAME, TXT, ...

`name` string optional

Example: `@`

The host name, alias, or service being defined by the record.

`data` string optional

Example: `ns1.digitalocean.com`

Variable 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.

`priority` integer or null optional

The priority for SRV and MX records.

`port` integer or null optional

The port for SRV records.

`ttl` integer optional

Example: `1800`

This 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.

`weight` integer or null optional

The weight for SRV records.

`flags` integer or null optional

An unsigned integer between 0-255 used for CAA records.

`tag` string or null optional

The parameter tag for CAA records. Valid values are "issue", "issuewild", or "iodef"

## Request Sample

## Show Request Sample

```python
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "type": "A",
  "name": "www",
  "data": "162.10.66.0",
  "priority": None,
  "port": None,
  "ttl": 1800,
  "weight": None,
  "flags": None,
  "tag": None
}

resp = client.domains.create_record(domain_name="example.com", body=req)
```

## Response Example

## Show Response Example

```json
{
  "domain_record": {
    "id": 28448433,
    "type": "A",
    "name": "www",
    "data": "162.10.66.0",
    "priority": null,
    "port": null,
    "ttl": 1800,
    "weight": null,
    "flags": null,
    "tag": null
  }
}
```

## More Information

See [`/v2/domains/{domain_name}/records`](https://docs.digitalocean.com/reference/api/reference/domain-records/index.html.md#domains_create_record) in the API reference for additional detail on responses, headers, parameters, and more.