---
title: "Setup DNS challenge records automatically using a DNS provider"
method: POST
path: "/domains/{domain_id}/setup-dns"
tags: ["Domains"]
---

# Setup DNS challenge records automatically using a DNS provider

`POST /domains/{domain_id}/setup-dns`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/domains/{domain_id}/setup-dns`
- Auth: HTTP bearer

This endpoint automatically creates the required DNS TXT records for ACME DNS-01 challenge
validation using a configured DNS provider. The domain must have an active DNS challenge
pending (created via POST /domains/{id}/order with dns-01 challenge type).

This is similar to how email domain DNS records are auto-provisioned.

## Path parameters

- `domain_id` integer, required

## Request body

- SetupDnsChallengeRequest: Request to setup DNS challenge records using a configured DNS provider
  - `dns_provider_id` integer, required: The ID of the DNS provider to use for creating the TXT records

## Response `200`

DNS records created successfully

- SetupDnsChallengeResponse: Response from DNS challenge setup operation
  - `message` string, required: Human-readable summary message
  - `records_created` integer, required: Number of TXT records that were successfully created
  - `results` DnsChallengeRecordResult[], required: Results for each individual TXT record
    - `message` string, required: Human-readable message about the operation
    - `name` string, required: TXT record name (e.g., "_acme-challenge.example.com")
    - `success` boolean, required: Whether the record was created successfully
    - `value` string, required: TXT record value (the ACME challenge token)
  - `success` boolean, required: Overall success status (true if all records were created)
  - `total_records` integer, required: Total number of TXT records required for the challenge

## Other responses

- `400`: Bad request - DNS provider not configured or no challenge pending
- `401`: Unauthorized
- `403`: Insufficient permissions
- `404`: Domain or DNS provider not found
- `409`: Ambiguous managed DNS zone
- `500`: Internal server error

## Changes

- **2026-09-07** `c2a1f69745e7`: 1 info
  - added the non-success response with the status `409`
- **2026-09-07** `7a3103561bd0`: 1 info
  - removed the non-success response with the status `409`
- **2026-09-07** `ebd376a7af05`: 1 info
  - added the non-success response with the status `409`
- **2026-09-07** `f7404eb7ac98`: 1 info
  - removed the non-success response with the status `409`
- **2026-09-07** `804f633e47cf`: 1 info
  - added the non-success response with the status `409`

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/domains/:domain_id/setup-dns/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
