---
title: "Restore DNS from a snapshot"
method: POST
path: "/api/domains/{domain}/dns/restore"
tags: ["DNS"]
---

# Restore DNS from a snapshot

`POST /api/domains/{domain}/dns/restore`

## Request

- Base URL: `https://domani.run`
- URL: `https://domani.run/api/domains/{domain}/dns/restore`
- Auth: HTTP bearer

Applies DNS records from a snapshot to the domain's current registrar. Uses a diff algorithm to avoid duplicating records that already exist. If no snapshot is provided in the body, restores from the server-side backup (created by snapshot or transfer).

Mail routing: a change to where the domain's mail is delivered (its MX or NS records, the address records an MX host inside the zone resolves through, or those of a host that receives Domani mail and publishes no MX) needs the `email:auth_secrets` scope, since whoever receives the mail receives its sign-in codes. Without it the request answers 403 INSUFFICIENT_SCOPE before anything changes, and a token confined to mailboxes answers 403 MAILBOX_CONFINED even with it. Other records need only `domains:write`. Every routing change is recorded in the audit log.

## Path parameters

- `domain` string, required

## Request body

- object
  - `snapshot` object: A DNS snapshot object (as returned by the snapshot endpoint). If omitted, the stored server-side backup is used.
    - `domain` string
    - `records` DnsRecord[]
      - `type` 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA' | 'TLSA', required: DNS record type. TLSA publishes a DANE record; its value is the rdata 'usage selector matching-type hex-data'.
      - `name` string, required: Record name (@ for root, or subdomain, e.g. _443._tcp for TLSA)
      - `value` string, required: Record value (IP address, hostname, or TLSA rdata like '3 1 1 abc123...')
      - `ttl` integer, required: Time to live in seconds
      - `priority` integer: Priority value (required for MX records)
      - `required` boolean: False when the zone Domani manages for the domain cannot hold the record (a TXT longer than the registrar accepts); such a record is shown but not needed for mail to work. Absent on plain zone records.
    - `subdomains` string[]
    - `sources` string[]
    - `capturedAt` string, date-time
  - `dry_run` boolean: Preview only: returns what the restore would create (would_apply) and skip, without writing anything.

## Response `200`

DNS restored from snapshot

- object
  - `domain` string
  - `applied` integer: Number of records created
  - `skipped` integer: Number of records already present
  - `recordCount` integer: Total records in the snapshot
  - `errors` string[]
  - `dry_run` boolean: True when this was a preview - nothing was written
  - `would_apply` DnsRecord[]: Dry run only: the records the restore would create
    - `type` 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA' | 'TLSA', required: DNS record type. TLSA publishes a DANE record; its value is the rdata 'usage selector matching-type hex-data'.
    - `name` string, required: Record name (@ for root, or subdomain, e.g. _443._tcp for TLSA)
    - `value` string, required: Record value (IP address, hostname, or TLSA rdata like '3 1 1 abc123...')
    - `ttl` integer, required: Time to live in seconds
    - `priority` integer: Priority value (required for MX records)
    - `required` boolean: False when the zone Domani manages for the domain cannot hold the record (a TXT longer than the registrar accepts); such a record is shown but not needed for mail to work. Absent on plain zone records.

## Other responses

- `400`: Invalid request parameters
- `401`: Missing or invalid API key
- `403`: Moving the domain's mail needs the email:auth_secrets scope (INSUFFICIENT_SCOPE) and a token not confined to mailboxes (MAILBOX_CONFINED)
- `404`: Domain not found
- `409`: Domain not active
- `429`: Rate limit exceeded - wait and retry

---

[API](https://skmtc.dev/domani/apis/domani-run-api.md) · [All operations](https://skmtc.dev/domani/apis/domani-run-api/llms.txt) · [OpenAPI document](https://skmtc.dev/domani/apis/domani-run-api/revisions/7679f8159533?raw)
