# POST /dns/zones/{name}/records

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the dns group.

Add a record to a DNS zone

- Who may call it: administrator
- Token scope, any of: dns, all
- Answers: 201 Created

Administrators can add records, including reserved records such as apex NS records and records at or below _acme-challenge. This operation returns 403 for zones held for a DNS distribution client. Add records to those zones on the client's server. Use a name relative to the zone, or @ for the apex. Supported types are A, AAAA, CNAME, MX, TXT, SRV, CAA, and NS. Use full hostnames such as mail.example.com for targets, or @ for the apex.

For SRV, format content as weight port target. For CAA, format it as flags tag "value". MX and SRV require a priority from 0 to 65535. Set ttl in seconds or omit it to inherit the zone's default TTL. Supply 1 to 4096 characters in content, excluding U+0000 through U+001F.

A CNAME must be below the apex and have exclusive use of its name. A duplicate record returns 409. Other DNS rule or zone validation failures return 400. UrbeStack saves the record only if validation succeeds. The 201 response includes the zone, the new record, and the publication outcome.

## As a command

- [urbestack-dns-record-add](https://urbestack.com/docs/commands/urbestack-dns-record-add.md): Adds a record to a DNS zone.

## Parameters

- `name` (path, DomainName, required)

## Request body

JSON, the type [DnsZoneRecordCreate](https://urbestack.com/docs/api/types/DnsZoneRecordCreate.md).

- `content` (string, up to 4096 characters, required)
- `name` (string, up to 200 characters, required)
- `type` (string, one of A, AAAA, CNAME, MX, TXT, SRV, CAA, NS, required)
- `priority` (integer, 0 to 65535)
- `ttl` (integer, 1 to 604800)

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/dns/zones/example.com/records" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "text",
    "name": "alice",
    "priority": 1,
    "ttl": 1,
    "type": "A"
  }'
```

Response, 201 Created:

```
{
  "published": true,
  "record": {
    "content": "text",
    "created_at": "2026-09-09T10:15:00Z",
    "id": 1,
    "managed_key": "text",
    "name": "alice",
    "origin": "yours",
    "priority": 1,
    "server": true,
    "system": true,
    "ttl": 1,
    "type": "A"
  },
  "reload": "text",
  "zone": "text"
}
```

## Errors

- 400: --<o> is required
- 400: <what> must be a number of seconds from 1 to 604800
- 400: Content must be text without control characters, at most 4096 characters
- 400: Domain name required
- 400: Domain name too long
- 400: Invalid domain name
- 400: Invalid record name
- 400: Priority must be a number from 0 to 65535
- 400: Record name required
- 400: Record name too long
- 400: Record type must be one of 
- 401: Authentication required
- 404: Zone '<name>' not found
