# Write one language's copy

Stores the subject and bodies for one language. A plain-text body is required; HTML is optional and builds a multipart/alternative message beside it.

## `PUT /api/v1/accounts/{accountId}/templates/{slug}/variants/{lang}`

### Path parameters

- `accountId` (string, required) — Account ULID identifier.
- `slug` (string, required, 1–64 chars, pattern `^[a-z0-9][a-z0-9_-]*$`) — The template's name within this account.
- `lang` (string, required, 2–35 chars, pattern `^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$`) — Language tag, e.g. `en` or `de-AT`. Stored lowercased.

### Request body (required)

`application/json`

- `subject` (string, required, 1–500 chars)
- `text` (string, required, min 1 chars)
- `html` (string | null)

### Responses

**200** — Stored

`application/json` → object

- `changed` (boolean, required) — False when this language already held exactly this copy: nothing was written
- `lang` (string, required)
- `slug` (string, required)
- `stored` (true, required)

**400** — template_invalid, text_required, subject_too_long or body_too_large

`application/json` → ErrorOrValidation

**401** — unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a `WWW-Authenticate: Bearer` challenge

`application/json` → ErrorBody

**404** — not_found

`application/json` → ErrorBody

**409** — variant_limit_reached

`application/json` → ErrorBody

**411** — length_required: Content-Length is required

`application/json` → ErrorBody

**413** — too_large: the JSON body exceeds 2 MiB

`application/json` → ErrorBody

**503** — temporary_failure: the platform's storage could not answer just now; retry after the Retry-After window. Any operation can answer this. A write that got it may have been applied, so retry it with the same idempotency key where it takes one, or read the state back first (see Transient failures in the API description)

`application/json` → ErrorBody

### Example request

```bash
curl -X PUT 'https://api.open.email/api/v1/accounts/{accountId}/templates/{slug}/variants/{lang}' \
  -H 'Authorization: Bearer oek_…' \
  -H 'Content-Type: application/json' \
  -d '{
    "subject": "string",
    "text": "string"
  }'
```

## TypeScript SDK

[`openemail.templates.setVariant`](/docs/sdks/typescript/templates/set-variant)

```ts
const result = await openemail.templates.setVariant(accountId, slug, lang, { subject: 'Hello', text: 'Hello from OpenEmail' })
```
