# POST /domains/{name}/mail/check/fix

First published 7 Nov 2026 (release 0.2.27) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the mail group.

Apply a fix offered by the domain's mail DNS check

- Who may call it: administrator, reseller, customer
- Token scope, any of: mail, all
- Answers: 200 OK

Set record to a key returned by GET /domains/{name}/mail/check, such as mail-spf, mail-dmarc or mail-a. The key must contain 1 to 64 lowercase ASCII letters, digits or hyphens. Set action to publish, restore or spf-add. An invalid record format or action returns 400.

Use publish to republish the zone. Use restore to replace custom records of the same type at the same DNS name with UrbeStack's record. Restoring SPF requires the SPF record to be absent. For DKIM, use publish.

Use spf-add to add this server's sending IP addresses or the relay's SPF mechanism to the single custom SPF record. This action removes UrbeStack's SPF record if present. The additions go before the first all or redirect= term, or at the end if neither is present. For relayed mail, spf-add requires a server-wide relay with an SPF mechanism set in mail.smarthost_spf. The resulting SPF record can contain up to 4096 characters.

The domain and the record's DNS name must belong to the same zone, managed on this server. Every fix regenerates and publishes the zone with a full BIND reload. On a DNS distribution client, it also sends the zone to the DNS server again.

The operation returns 409 if the current zone contents make the fix inapplicable, including when the records have changed since the check. Run GET /domains/{name}/mail/check again before retrying. The follow-up check returns 404 if the domain has no mail configuration or 409 if it routes mail elsewhere or the mail stack is disabled or missing.

The 200 response reports the fix in fixed and the fresh check results in check. The fixed object can include record, action, zone, added, removed, record_now and dns_server.

Administrators, the customer who owns the domain and that customer's reseller can call this operation with a token that has the mail scope.

## As a command

- [urbestack-mail-check-fix](https://urbestack.com/docs/commands/urbestack-mail-check-fix.md): Applies one fix offered by the mail record check.

## Parameters

- `name` (path, DomainName, required)

## Request body

JSON, the type [MailCheckFix](https://urbestack.com/docs/api/types/MailCheckFix.md).

- `action` (string, one of publish, restore, spf-add, required)
- `record` (string, up to 64 characters, required)

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/domains/example.com/mail/check/fix" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "publish",
    "record": "text"
  }'
```

Response, 200 OK:

```
{
  "check": {
    "checked_at": "text",
    "dns": "here",
    "dns_server": "text",
    "failed": true,
    "hosted": true,
    "name": "alice",
    "nameservers": [
      "text"
    ],
    "records": [
      {
        "adds": [
          "text"
        ],
        "copy": {
          "name": "alice",
          "priority": 1,
          "type": "rebuild",
          "value": 8443
        },
        "expected": "text",
        "fix": "publish",
        "fqdn": "text",
        "inherited": "text",
        "key": "panel.port",
        "name": "alice",
        "state": "correct",
        "theirs": "text",
        "type": "A",
        "until": "text",
        "value": 8443,
        "world": [
          "text"
        ]
      }
    ],
    "resolver": "text",
    "resolvers": [
      "text"
    ],
    "reverse": [
      {
        "address": "info@example.com",
        "bound": true,
        "family": "ipv4",
        "hostname_address": true,
        "matches_hostname": true,
        "on_machine": true,
        "points_back": true,
        "ptr": "text",
        "state": "correct"
      }
    ]
  },
  "fixed": {
    "action": "text",
    "added": [
      "text"
    ],
    "dns_server": "text",
    "record": "text",
    "record_now": "text",
    "removed": [
      "text"
    ],
    "zone": "text"
  }
}
```

## Errors

- 400: <what> must be text without control characters, 1 to <max> characters
- 400: A DKIM record is published, not restored
- 400: Domain name required
- 400: Domain name too long
- 400: Give --name or --host
- 400: Invalid IPv4 address
- 400: Invalid IPv6 address
- 400: Invalid domain name
- 400: Invalid port
- 400: Invalid setting key
- 400: Only an SPF record has this server added
- 400: The SPF record would be longer than a TXT record may be
- 400: action must be publish, restore or spf-add
- 400: record must name a record of the check
- 401: Authentication required
- 404: No record <key> to fix for <what>
- 404: No such domain: <name>
- 404: Setting '<key>' not found
- 409: <md.domain> routes its mail elsewhere; this server publishes no mail records for it
- 409: <w.fqdn> belongs to the zone 
- 409: The DNS of <what> is not kept on this server
- 409: The mail stack is not installed on this server
- 409: This server sends through a relay with no SPF mechanism given; there is nothing to add
