
# Roll back an email template

`POST /v1/email-templates/{family}/{locale}:rollback` · permission `email-templates:write` · Startup plan and above

Validates the content of an earlier published (now archived) version again and publishes it as a new version, with `source_version` set to the version you rolled back to. History is not rewritten. The audit record `email_template.rolled_back` is written in the same transaction.

A version that was never published, or the one that is published now, returns `409`.

## Path parameters

| Parameter | Description |
|---|---|
| `family` | Email family, for example `verify_email` or `email_otp` (see [List email templates](list.md)). |
| `locale` | Locale tag, for example `en` or `de`. |

## Request

| Field | Type | Required | Description |
|---|---|---|---|
| `version` | integer | yes | The archived version to republish (1 or more). |

## Response

`200 OK` with the new published version.

```json
{
  "family": "verify_email",
  "locale": "en",
  "version": 4,
  "status": "published",
  "subject": "Confirm your email for {{ application.name }}",
  "html": "<p><a href=\"{{ link }}\">Confirm your email</a></p>",
  "text_body": "Confirm your email: {{ link }}",
  "from_name": null,
  "source_version": 1,
  "created_at": "2026-10-19T10:00:00Z",
  "published_at": "2026-10-19T10:00:00Z",
  "latest_version": 4,
  "published_version": 4
}
```

## Errors

| HTTP | code | When |
|---|---|---|
| 400 | `unknown_field` | The body has an unknown field or is not a JSON object. |
| 404 | `not_found` | The family or locale is unknown, or the version does not exist. |
| 403 | `plan_feature_unavailable` | The environment's plan does not include custom email templates (Startup and above; `required_plan` says which). |
| 409 | `conflict` | The version was never published, or is the published one. |
| 422 | `validation_failed` | `version` is missing or less than 1, or the content no longer passes validation. |
| 401 | `unauthenticated` | The credential is missing, invalid or revoked. |
| 403 | `insufficient_permissions` | The credential lacks the required permission. |
| 429 | `rate_limited` | The rate limit was exceeded; retry after the `Retry-After` period. |
| 503 | `service_unavailable` | A dependency is temporarily unavailable; retry after the `Retry-After` period. |

## Example

```bash
curl -X POST https://api.eu.keenauth.com/v1/email-templates/verify_email/en:rollback \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"version":1}'
```

CLI: `keenauth email-templates rollback verify_email en --version 1 --yes`
