---
title: "Write DNS records in one click"
method: POST
path: "/sender-domains/{id}/apply-dns"
tags: ["domains"]
---

# Write DNS records in one click

`POST /sender-domains/{id}/apply-dns`

## Request

- Base URL: `https://api.mailly.site` (the document declares no server; this is the origin it was published from)
- URL: `https://api.mailly.site/sender-domains/{id}/apply-dns`
- Auth: HTTP bearer

Writes the DNS records Mailly needs directly into your zone using the Cloudflare token (saved or passed in this request); idempotent, and conflicting records are not overwritten. The body is optional.

## Path parameters

- `id` string, required: Domain record ID

## Request body

- object
  - `provider` string: Only cloudflare is supported for now
  - `scope` 'outbound' | 'inbound' | 'all': Default all
  - `apiToken` string: Cloudflare token for this request (takes precedence over the saved one)

## Response `200`

DNS write result

- object
  - `success` boolean, required

## Other responses

- `400`: Invalid request or no saved token
- `401`: Missing or invalid API key
- `404`: Domain not found
- `409`: Ownership not verified or record conflict
- `500`: Write failed
- `502`: SES or Cloudflare upstream error
- `503`: Encryption key is not configured

---

[API](https://skmtc.dev/mailly/apis/mailly-api.md) · [All operations](https://skmtc.dev/mailly/apis/mailly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mailly/apis/mailly-api/revisions/1ceb29637301?raw)
