## PUT /api/v2/dns-zones/{id}/records/{recordId}

**Update DNS record**

Replace a DNS record using the same validation rules as record creation. Get `id` from `GET /api/v2/dns-zones data[].id` and `recordId` from `GET /api/v2/dns-zones/{id} records[].id`. Use ALIAS, not CNAME, when the zone root should point at another hostname. NS records here delegate a subdomain only: in zone `xyz.se`, `name: "acme"` delegates `acme.xyz.se`. Changing authoritative nameservers for the domain uses `POST /api/v2/domains/{id}/nameservers`. The record being edited is excluded from duplicate checks.

### Related Endpoints

- `DELETE /api/v2/dns-zones/{id}/records/{recordId}`: Delete DNS record
- `POST /api/v2/dns-zones/{id}/records`: Create DNS record
- `GET /api/v2/dns-zones/{id}`: Get DNS zone and records

### Headers

- `Accept`: application/json
- `Authorization`: Bearer YOUR_API_KEY
- Required API scope: `write:dns`
- `Content-Type`: application/json

### Parameters

- `id` (path, string, required): Public DNS zone ID. Get it from GET /api/v2/dns-zones `data[].id`. Do not invent this value; use the exact ID returned by the referenced API response. Example: `zone_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `recordId` (path, string, required): Public DNS record ID. Get it from GET /api/v2/dns-zones/{id} `records[].id`. Do not invent this value; use the exact ID returned by the referenced API response. Example: `drr_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Body

- `type` (string, optional) Example: `TXT`
  Allowed values: A, AAAA, CNAME, ALIAS, MX, TXT, SPF, SRV, CAA, NS, TLSA
- `name` (string, optional): Record owner name relative to this DNS zone. Use `@` or an empty string for the zone root; use labels such as `www` or `_dmarc`, not the full FQDN `www.example.com`. Responses may return normalized FQDN names. For NS records, send the subdomain label only: in zone `xyz.se`, `name: "acme"` delegates `acme.xyz.se`. This does not change authoritative nameservers for `xyz.se`; use `/api/v2/domains/{id}/nameservers` for that. Example: `_dmarc`
- `value` (string, optional): Record target or content. Send TXT/SPF values without surrounding quotes; the server applies DNS-safe quoting and splits long TXT-like values into DNS protocol strings of at most 255 characters. Do not pre-split DKIM/SPF/DMARC values. Example: `v=DMARC1; p=none; rua=mailto:dmarc@example.com`
- `ttl` (integer, optional) [min: 60] Example: `3600`
- `priority` (integer, optional) [min: 0, max: 65535] Example: `10`
- `weight` (integer, optional) [min: 0, max: 65535] Example: `0`
- `port` (integer, optional) [min: 1, max: 65535] Example: `443`

### Request Examples

#### A

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "A",
    "name": "@",
    "value": "192.0.2.1",
    "ttl": 3600
  }'
```

```json
{
  "type": "A",
  "name": "@",
  "value": "192.0.2.1",
  "ttl": 3600
}
```

#### AAAA

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "AAAA",
    "name": "@",
    "value": "2001:db8::1",
    "ttl": 3600
  }'
```

```json
{
  "type": "AAAA",
  "name": "@",
  "value": "2001:db8::1",
  "ttl": 3600
}
```

#### CNAME

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "CNAME",
    "name": "www",
    "value": "target.example.com",
    "ttl": 3600
  }'
```

```json
{
  "type": "CNAME",
  "name": "www",
  "value": "target.example.com",
  "ttl": 3600
}
```

#### ALIAS

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "ALIAS",
    "name": "@",
    "value": "target.example.com",
    "ttl": 3600
  }'
```

```json
{
  "type": "ALIAS",
  "name": "@",
  "value": "target.example.com",
  "ttl": 3600
}
```

#### TXT

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "TXT",
    "name": "_dmarc",
    "value": "v=DMARC1; p=quarantine",
    "ttl": 3600
  }'
```

```json
{
  "type": "TXT",
  "name": "_dmarc",
  "value": "v=DMARC1; p=quarantine",
  "ttl": 3600
}
```

#### MX

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "MX",
    "name": "@",
    "value": "mail.example.com",
    "priority": 10,
    "ttl": 3600
  }'
```

```json
{
  "type": "MX",
  "name": "@",
  "value": "mail.example.com",
  "priority": 10,
  "ttl": 3600
}
```

#### SPF

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "SPF",
    "name": "@",
    "value": "v=spf1 include:_spf.example.com ~all",
    "ttl": 3600
  }'
```

```json
{
  "type": "SPF",
  "name": "@",
  "value": "v=spf1 include:_spf.example.com ~all",
  "ttl": 3600
}
```

#### SRV

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "SRV",
    "name": "_sip._tcp",
    "value": "sip.example.com",
    "priority": 10,
    "weight": 5,
    "port": 5060,
    "ttl": 3600
  }'
```

```json
{
  "type": "SRV",
  "name": "_sip._tcp",
  "value": "sip.example.com",
  "priority": 10,
  "weight": 5,
  "port": 5060,
  "ttl": 3600
}
```

#### CAA

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "CAA",
    "name": "@",
    "value": "0 issue \"letsencrypt.org\"",
    "ttl": 3600
  }'
```

```json
{
  "type": "CAA",
  "name": "@",
  "value": "0 issue \"letsencrypt.org\"",
  "ttl": 3600
}
```

#### TLSA

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "TLSA",
    "name": "_443._tcp",
    "value": "3 1 1 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "ttl": 3600
  }'
```

```json
{
  "type": "TLSA",
  "name": "_443._tcp",
  "value": "3 1 1 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "ttl": 3600
}
```

#### NS

```bash
curl -X PUT "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "NS",
    "name": "acme",
    "value": "ns1.acme.example.net",
    "ttl": 3600
  }'
```

```json
{
  "type": "NS",
  "name": "acme",
  "value": "ns1.acme.example.net",
  "ttl": 3600
}
```

### Response Schema

- `id` (string, optional) Example: `drr_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `type` (string, optional) Example: `TXT`
  Allowed values: A, AAAA, CNAME, ALIAS, MX, TXT, SPF, SRV, CAA, NS, TLSA
- `name` (string, optional) Example: `_dmarc.example.com`
- `value` (string, optional) Example: `v=DMARC1; p=none; rua=mailto:dmarc@example.com`
- `ttl` (integer, optional) Example: `3600`
- `priority` (integer,null, optional) Example: `null`
- `weight` (integer,null, optional) Example: `null`
- `port` (integer,null, optional) Example: `null`
- `status` (string, optional) Example: `active`
  Allowed values: active, disabled, pending, error, unknown

### Responses

#### 200 - Updated DNS record.
```json
{
  "id": "drr_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "type": "A",
  "name": "www.example.com",
  "value": "192.0.2.1",
  "ttl": 3600,
  "priority": null,
  "weight": null,
  "port": null,
  "status": "active"
}
```

#### 400 - Invalid request. The response body is an RFC 7807 Problem Details document.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "The request body failed validation.",
  "code": "invalid_request",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z",
  "errors": [
    {
      "pointer": "/items/0/domainName",
      "detail": "`domainName` is required.",
      "code": "invalid_request"
    }
  ]
}
```

#### 401 - Unauthorized. Authentication is required.
```json
{
  "type": "https://developer.hostup.se/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication is required.",
  "code": "unauthorized",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 403 - Forbidden. The caller lacks a required scope or does not own the resource.
```json
{
  "type": "https://developer.hostup.se/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "The caller lacks a required scope or does not own the resource.",
  "code": "forbidden",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 404 - Not found. The resource does not exist or is not owned by the caller.
```json
{
  "type": "https://developer.hostup.se/errors/not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 409 - Conflict. See the Problem Details `code` for the route-specific blocker and recovery fields.
```json
{
  "status": 409,
  "instance": "/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z",
  "type": "https://developer.hostup.se/errors/dns_conflict",
  "title": "DNS record conflict",
  "detail": "A CNAME record cannot coexist with A, AAAA, MX, TXT, or other records at the same name.",
  "code": "dns_conflict",
  "errors": [
    {
      "pointer": "/type",
      "detail": "Remove the existing A record at `www` before creating a CNAME there.",
      "code": "cname_conflict"
    }
  ]
}
```

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Too many requests. Retry after the limit resets.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```
