# POST /domains/{name}/mail/dkim/rotate

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the mail group.

Rotate the domain's DKIM key

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

UrbeStack creates a DKIM key under a dated selector and starts signing with it immediately. For example, the first rotation on that date uses s20260915, the second uses s20260915a, and further rotations that day continue with suffixes.

The previous selector's DNS record stays in the zone until the next rotation so mail in transit can still be verified. UrbeStack removes older selector records. The 200 response includes name, selector, previous, retired and record in dkim. Use record to publish the new DNS record at your DNS provider if DNS is hosted elsewhere.

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-dkim-rotate](https://urbestack.com/docs/commands/urbestack-mail-dkim-rotate.md): Creates a new DKIM key for a domain and starts signing with it.

## Parameters

- `name` (path, DomainName, 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/dkim/rotate" \
  -H "Authorization: Bearer $TOKEN"
```

Response, 200 OK:

```
{
  "dkim": {
    "name": "alice",
    "previous": "text",
    "record": {},
    "retired": [
      "text"
    ],
    "selector": "text"
  }
}
```

## Errors

- 400: --name is required
- 400: <name> routes its mail elsewhere; there is nothing to sign
- 400: <what> must be text without control characters, 1 to <max> characters
- 400: Domain name required
- 400: Domain name too long
- 400: Invalid IPv4 address
- 400: Invalid IPv6 address
- 400: Invalid domain name
- 400: Invalid port
- 400: Invalid setting key
- 400: The mail stack is not installed on this server
- 401: Authentication required
- 404: Setting '<key>' not found
- 409: Too many rotations today
