---
title: "Upsert a reusable block language"
canonical: "https://bird.com/docs/api/reference/upsert-email-block-language"
---

# Upsert a reusable block language

`PUT /v1/email/blocks/{block_id}/languages/{language}`

Replaces one language's draft with a complete section, or copies a published revision back into the draft with `from_revision_id`. Send the draft `revision` you last read, or `0` to add a language. A stale revision returns a `409` `conflict_error`.

Unfinished content can be saved, and saving never publishes. A language keeps the authoring mode of its first section, so a section in the other mode returns a `422` `validation_error`.

## Servers

- `https://{region}.platform.bird.com`: Regional API endpoint. Use the host for the region your organization is hosted in. Official Bird SDKs and the CLI select it automatically from your API key, so you rarely need to set it by hand.
  - `region`: `us1`, `eu1`. Default: `us1`. The region your organization's data is hosted in.

## Authentication

Use one authentication option:

- `BearerAuth`: HTTP bearer authentication. Pass the API key as a bearer token in the `Authorization` header. Workspace
keys use `bk_{region}_*`; organization master keys use `bm_{region}_*`.
The prefix identifies the region and selects the
API endpoint. Official Bird SDKs and the CLI derive the region from the key.

## Code samples

**TypeScript**

```ts
// Requires email_management:write permission in the target workspace.
const section =
  '<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tbody><tr>' +
  '<td lang="fr" style="font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; ' +
  "line-height: 20px; letter-spacing: normal; text-align: left; text-transform: none; color: #333333; margin: 0; padding: 16px;\">" +
  '<p style="margin: 0;">Offre valable jusqu\'au {{ expiry_date }}.</p></td></tr></tbody></table>';
const draft = await bird.email.blocks.languages.set("ebl_01krdgeqcxet5s7t44vh8rt9mg", "fr", {
  revision: 0,
  fragment: { serializer_version: 2, fragment_html: section },
});
console.log(draft.revision);
```

Examples: [TypeScript](/docs/api/reference/upsert-email-block-language.ts.md) · [Python](/docs/api/reference/upsert-email-block-language.py.md) · [Go](/docs/api/reference/upsert-email-block-language.go.md) · [PHP](/docs/api/reference/upsert-email-block-language.php.md) · [CLI](/docs/api/reference/upsert-email-block-language.cli.md) · [MCP](/docs/api/reference/upsert-email-block-language.mcp.md) · [cURL](/docs/api/reference/upsert-email-block-language.curl.md)

## Example response `200`

```json
{
  "language": "en",
  "revision": 2,
  "authoring_mode": "html",
  "published_revision_id": "ebr_01krdgeqcxet5s7t44vh8rt9mg",
  "fragment": {
    "serializer_version": 2,
    "fragment_html": "<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tbody><tr><td lang=\"en\" style=\"font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; line-height: 20px; letter-spacing: normal; text-align: left; text-transform: none; color: #333333; margin: 0; padding: 16px;\"><p style=\"margin: 0;\">Your disclosure text.</p></td></tr></tbody></table>"
  },
  "created_at": "2026-05-20T09:14:52Z",
  "updated_at": "2026-05-25T16:42:01Z"
}
```

## Path parameters

- `block_id` (string, required): Block to read or edit.
- `language` (string, required): Exact block language as a BCP-47 tag. No fallback is applied.

## Header parameters

- `Idempotency-Key` (string, optional)

  Client-supplied key. On operations supporting request deduplication, a retained
  response is replayed for duplicate requests with the same key within the
  idempotency window (3 hours by default). This protection requires a workspace,
  organization, or staff-account scope. User-only and unscoped unauthenticated operations,
  streams, and operations with a separate replay contract do not use this
  response replay.

  On a supported operation, if idempotency protection is unavailable before execution, the API returns
  `503 IdempotencyUnavailable` (E01033) without executing this attempt. Retry with
  backoff using the same key and request. An operation that takes effect before
  its response is retained can still execute again on retry.

  Two distinct 409 errors signal misuse:

  - `request_in_progress` (E01004): The same key is currently being
    processed by a concurrent request. Wait briefly and retry. The lock expires within 30 seconds.
  - `idempotency_key_reuse` (E01005): The same key has already completed
    against a different request body or method. Generate a new key.

  Recommended key format is `<event-type>/<entity-id>` (for example `welcome-user/usr_abc123`).
- `X-Workspace-Id` (string, optional): Workspace context for the request. Required for dashboard authentication and master keys. Workspace keys and access tokens already identify their workspace; send that workspace or omit the header. A different one is rejected.
- `X-Organization-Id` (string, optional): Organization context for the request. Required for dashboard authentication. An API key or access token carries its own organization, so send either that organization or no header at all; a different one is rejected.

## Request body

- `revision` (integer, required): Draft revision last read, or zero to create a missing language. A concurrent change returns 409.
- `fragment` (object): One self-contained email section. Version 2 is a section written as HTML and sends `fragment_html` alone; the API, SDKs, CLI and MCP write version 2. Version 1 is reserved for sections built in the Bird dashboard's visual editor, and only the dashboard saves it. A block language keeps the version it was created with.
- `fragment.serializer_version` (integer, required): How this section is written. 2 is HTML written directly, and is the value to send from the API, SDKs, CLI and MCP. 1 is reserved for the Bird dashboard's visual editor; other callers get a `422` for it.
- `fragment.fragment_html` (string, required): Section HTML. Unfinished markup can be saved as a draft; validation checks readiness separately. A version 2 section is one presentation table with one `tbody`, `tr` and `td`, and all layout stays inside that cell. The cell sets `lang` to the block language and its own typography: `font-family`, a `font-size` in pixels, `font-style`, `font-weight`, `line-height`, `letter-spacing`, `text-align` (not `start` or `end`), `text-transform`, `color`, `margin` and `padding`. Root-relative units such as `rem` are refused; use px, em or percentages. Liquid stays balanced inside the cell, cannot use `assign`, `capture`, `increment` or `decrement`, and puts no control tag inside an attribute or style value. `{{ bird.unsubscribe_url }}` appears only as bare text or as the entire `href` of an `<a>`, and never inside an `if !mso` conditional comment, which Outlook skips. No document wrapper, `<style>`, script, form, `class` or `id` attribute. A table nested in the cell needs its own `<tbody>`. Inside a complete Outlook conditional comment, prefixed Office and VML elements such as `v:fill` may self-close, and a balanced `if !mso` conditional comment that shows its content outside Outlook is accepted when it holds no other conditional comment.
- `source_revision_id` (string): Published source-language revision this translation was made from. Accepted with `fragment` only; leaving it out clears the reference.
- `from_revision_id` (string): Published revision of this language to copy back into the draft, sent instead of `fragment`. Copying never publishes.

## Response body

- `language` (string, required): A language tag in BCP-47 form, for example `en` or `pt-BR`.
- `revision` (integer, required): Draft revision to send back when saving or publishing this language, as last returned. It is not a publication number; a published revision is a separate record numbered by `version_number`.
- `authoring_mode` (string, required)

  How this language is edited. `html` content is written as HTML and can be changed through the API, CLI and MCP. `visual` content is built in the Bird dashboard's visual editor; outside the dashboard, a visual section can still be copied by duplicating its block or restoring a published revision. The mode follows from the stored content and cannot be set directly. New values may be added; treat an unknown value as content you cannot edit through the API, CLI or MCP.

  Possible values (may grow over time): `visual`, `html`
- `source_revision_id` (string): Published source-language revision used for this translation. Omitted when untracked.
- `published_revision_id` (string): Current published revision for this exact language. Omitted before publication.
- `fragment` (object, required): One self-contained email section. Version 2 is a section written as HTML and sends `fragment_html` alone; the API, SDKs, CLI and MCP write version 2. Version 1 is reserved for sections built in the Bird dashboard's visual editor, and only the dashboard saves it. A block language keeps the version it was created with.
- `fragment.serializer_version` (integer, required): How this section is written. 2 is HTML written directly, and is the value to send from the API, SDKs, CLI and MCP. 1 is reserved for the Bird dashboard's visual editor; other callers get a `422` for it.
- `fragment.fragment_html` (string, required): Section HTML. Unfinished markup can be saved as a draft; validation checks readiness separately. A version 2 section is one presentation table with one `tbody`, `tr` and `td`, and all layout stays inside that cell. The cell sets `lang` to the block language and its own typography: `font-family`, a `font-size` in pixels, `font-style`, `font-weight`, `line-height`, `letter-spacing`, `text-align` (not `start` or `end`), `text-transform`, `color`, `margin` and `padding`. Root-relative units such as `rem` are refused; use px, em or percentages. Liquid stays balanced inside the cell, cannot use `assign`, `capture`, `increment` or `decrement`, and puts no control tag inside an attribute or style value. `{{ bird.unsubscribe_url }}` appears only as bare text or as the entire `href` of an `<a>`, and never inside an `if !mso` conditional comment, which Outlook skips. No document wrapper, `<style>`, script, form, `class` or `id` attribute. A table nested in the cell needs its own `<tbody>`. Inside a complete Outlook conditional comment, prefixed Office and VML elements such as `v:fill` may self-close, and a balanced `if !mso` conditional comment that shows its content outside Outlook is accepted when it holds no other conditional comment.
- `created_at` (string, required)
- `updated_at` (string, required)

## Related resources

- [Should I use a Bird SDK or call the API directly?](/explained/platform/should-i-use-an-sdk-or-call-the-api-directly) (answer)
- [Build your first integration](/learn/paths/integration) (course)
- [Send your first email](/docs/get-started/send-your-first-email) (docs)

[Get an implementation brief](/learn/workspace?topic=api-basics)
