# Edit or delete a record

Change the values or TTL of a record set, or delete the set.

Replace _zone-id_ with the id of your hosted zone and _record-id_ with the id of the record set
(`dcloud dns records list zone-id` lists them). The name and type of a set cannot change:
to move a record, add a new set and delete the old one.

## Prerequisites

- Permission for `dns:ChangeRecords` on the zone. Without it, **Edit record** and **Delete record**
  are unavailable, with the note "Adding, editing or deleting a record set needs dns:ChangeRecords
  on this zone. Ask an administrator."
- In the console, also `dns:ListZones` to open **Hosted zones** (without it the page shows an
  access-denied notice), `dns:GetZone` to open the zone (without it the zone's page is not found)
  and `dns:ListRecords` to see the zone's records.

## Edit a record set

Fields you leave out keep their stored value.

**Console**
1. Open the zone. On the **Records** tab, in the row's actions menu, choose **Edit record**.
2. Change **Values, one per line** or **TTL (seconds)**. **Name** and **Type** cannot be changed.
3. Choose **Save**.

**CLI**
```sh
dcloud dns records update zone-id record-id --values 192.0.2.20 --ttl 300
```

**API**
```http
PUT /dns/api/zones/zone-id/records/record-id
{ "values": ["192.0.2.20"], "ttl": 300 }
```

The answer is `200` with the set as stored.

**Terraform**
Change `values`, `ttl` or the target arguments of the `dcloud_dns_record` and run
`terraform apply`. Changing `name`, `type` or `zone_id` replaces the record.

An edit is checked like an add (see [Add a record](add-a-record.md)) and refused with `400` and
the same reasons. It never counts against the zone's quota. To remove a health check with the API,
send `"healthCheckId": null` together with `"failoverValues": []`; with failover values still
stored, the edit is refused with "Failover values need a health check".

## Delete a record set

**Console**
1. Open the zone. On the **Records** tab, in the row's actions menu, choose **Delete record**.
2. In the dialog **Delete record set**, choose **Delete**.

If the delete fails, the reason appears above the table, after "The record set was not deleted:".

**CLI**
```sh
dcloud dns records delete zone-id record-id
```

**API**
```http
DELETE /dns/api/zones/zone-id/records/record-id
```

**Terraform**
Remove the `dcloud_dns_record` resource and run `terraform apply`.

## Result

The nameservers answer the change on their next pull. Resolvers that cached the old answer keep it
until its TTL runs out; after a delete they then get no answer for that name and type. Deleting an
`ALIAS` to a bucket website also removes the name from the bucket's website domains.

The platform's apex `NS` row in the console has no actions: it is set by the platform.

A request for a zone or set that does not exist is refused with `404` "Zone not found" or
"Record not found".

## Related

- [Add a record](add-a-record.md)
- `dns.records.update` · `dns.records.delete` · `dcloud dns records update` ·
  `dcloud_dns_record`
