# Templates (RCS) | Signal House API Docs

> Store authored RCS messages as raw channel templates in your group with the Signal House API.

Source: https://docs.signalhouse.io/templates

---

## Templates (RCS)

## Raw channel templates

A message template stores one authored RCS message as **raw channel content**: you send the RCS contract itself, not a channel-neutral format, and the API never converts it to another channel. Templates belong to a group and live under`/template`. Filter a list by `channel` when you need to; the body's own `channel` says what a new template is.

**Availability.** Template routes are only enabled where RCS is enabled. Templates cannot be sent yet: sending arrives in a later release.

## The RCS body

- `channel: "rcs"`. `contentFormat` is optional: omitted means `"content.v1"`, the block contract below, which is the only format the API stores and returns. `"google.rcs"` sends Google's RCS format instead (see below).
- `content.blocks`: ordered blocks, each with a unique `id` and a `kind` of `text`, `richCard`, `video`, `carousel`, `suggestions` or `attachment`. A `suggestions` block attaches to the message block before it; card buttons go in a card's own `suggestions`.
- Suggestions have a `type` of `REPLY`, `OPEN_URL` (`url`, `application` BROWSER or WEBVIEW, `webviewViewMode` for WEBVIEW), `DIAL` (`phoneNumber` in E.164), `VIEW_LOCATION` (`latitude` and `longitude`, or an `address` of at most 512 characters the API resolves to them on create, update and validate when a geocoding provider is configured, plus `locationLabel`. Each distinct address is looked up once, an address containing `{{` is not looked up, and at most 25 addresses not already cached are resolved per request, each counted against the group's window of 60 lookups a minute shared with `GET /template/geocode`. An address that stays unresolved blocks publishing with `LOCATION_UNRESOLVED`), `SHARE_LOCATION` or `CALENDAR` (`title` of at most 100 characters, `description` of at most 500, `startTime`, `endTime` as ISO-8601 with an offset), plus `label` and `postbackData`.
- `variables`: `{{key}}` placeholders, with keys of lowercase letters, digits and underscores. They are allowed in message text, card titles and descriptions, button labels and fallback text, and under the rules below in links, media, dial numbers, calendar events and postback data. Each declares `type` (text, number, dateTime, phoneNumber or url), `required`, and an optional `missingPolicy`, `default` and `sample`. Samples are for previews only and are never sent. `{{sender_name}}` is reserved and filled from the sender.
- `missingPolicy` says what a recipient with no value for the variable gets. An empty value, or one of only spaces, counts as no value. `default`: the variable's `default`, or an empty value when none is declared. `block`: the recipient is blocked with `VARIABLE_MISSING`, even when a `default` is declared. `drop`: the send leaves out each block that uses the variable, and a message block takes its suggestions blocks with it; in fallback text the variable is empty. The billing class and the generated fallback come from the blocks that remain, and a drop that leaves nothing to send blocks the recipient with `VARIABLE_MISSING`. With a `missingPolicy`, `required` is not read at send. Without one, a missing value takes the `default`; with no default, a `required` variable blocks the recipient with `VARIABLE_MISSING` and an optional one is empty.
- Placeholders outside text. A `url` variable may fill a whole link (`url`, `fallbackUrl`) or media field (`mediaUrl`, `thumbnailUrl`, `fileUrl`, fallback `mediaUrls`). Any variable may fill the path, query or fragment of a URL whose scheme and host are written out, and its value is percent-encoded there. A dial `phoneNumber` takes one `phoneNumber` variable for the whole field, and a calendar `startTime` and `endTime` take one `dateTime` variable each. A calendar `title` and `description` take text. `postbackData` takes text: the API wraps it as `sh1|<messageId>|<buttonId>|<postbackData>` at send and gives back only your part. A location's `address` and `locationLabel` take no variables. Publish checks only where a placeholder sits (`PLACEHOLDER_NOT_ALLOWED`). The send checks each recipient's filled field as publish checks a written one (`INVALID_URL`, `INVALID_PHONE`, `INVALID_DATE_TIME`, `EVENT_END_BEFORE_START`, `POSTBACK_REQUIRED`, `EVENT_TITLE_REQUIRED`, `EVENT_TITLE_TOO_LONG`, `EVENT_DESCRIPTION_TOO_LONG`), and a failure blocks that recipient with `CONTENT_INVALID`. The generated fallback writes a filled link as "Label: URL".
- `defaults`: optional `trafficType` and `ttlSeconds` (10 seconds to 48 hours, the carrier partner's floor and cap).
- `fallback`: `{}` for none, or `delivery` with the SMS or MMS content you wrote (`channel` sms or mms, `campaignId` of one of your campaigns and a `phoneNumber` on that campaign to send it from (digits only, as `/number` lists it), `content.text`, plus `mediaUrls` and an optional `subject` for MMS) and an optional `validitySeconds`. It is sent when RCS cannot be delivered. With `{}`, a send that allows a fallback and sets no `fallback.content` gets text the API generates from the RCS content.

Unknown fields are rejected at every level. Drafts may have empty fields; publishing requires complete content within the channel limits returned by `/capabilities`, and a fallback `campaignId` that belongs to the template's group with a `phoneNumber` assigned to that campaign.

## Sending Google's RCS format

Send `contentFormat: "google.rcs"` with `content` set to an RBM `AgentContentMessage`, the object Google's API takes under `contentMessage`: exactly one of `text`, `richCard` (`standaloneCard` or`carouselCard`) or `contentInfo`, plus `suggestions` (`reply` or `action` with one of `openUrlAction`, `dialAction`, `viewLocationAction`, `shareLocationAction`,`createCalendarEventAction`). The API converts it to `content.v1` before anything else happens, so the stored, validated and returned body is always `content.v1`. `variables`, `defaults` and `fallback`are the same as above.

- A `viewLocationAction.query` (an address) becomes the suggestion's `address` and is resolved to coordinates the same way. `latLong` maps to `latitude` and `longitude`; `label` to `locationLabel`.
- Fields with no carrier equivalent are accepted and dropped: `uploadedRbmFile`, `composeAction` (a suggestion with only a compose action is dropped), `openUrlAction.description`, `contentInfo.forceRefresh` and `altText`. Google's `*_UNSPECIFIED` enum members read as absent. Any other unknown field is rejected with its path.
- `/capabilities` lists the accepted formats as `contentFormats`.

## Versions and concurrent edits

Each template has a head with a `draftVersion` and a `publishedVersion`. Publishing freezes the draft; editing a published template creates the next draft and leaves the published version unchanged. Every change increments the head's `revision`. Writes apply directly: the last write wins, and the API keeps each write whole. The `409` codes are `TEMPLATE_ARCHIVED`,`TEMPLATE_NAME_TAKEN`, `NO_DRAFT` when publishing without a draft, and `DRAFT_CHANGED` when the draft changed while it was being published (publish again). Send an `Idempotency-Key` header to retry a write safely.

## How you hear about a problem

The API checks content at the earliest stage that can know the answer, and every stage says why. The SDKs check required parameters only, so each response carries its result. Read `validation` on every save, and call `POST /message/rcs/validate` before a large send.

| Stage | Call | What runs | What you get |
| --- | --- | --- | --- |
| Save | `POST /template, PUT /template/:templateId` | Structure rejects the request. Every publish check but content moderation runs and is reported. | 400 for bad structure. Otherwise the draft saves, and validation lists what would stop it publishing. |
| Check | `POST /template/:templateId/validate` | Every publish check, content moderation included, with nothing written. | { valid, errors, warnings } |
| Publish | `POST /template/:templateId/publish` | Every publish check, content moderation included. | 400 TEMPLATE\_INVALID with every error and warning, or the published version with its warnings. |
| Check a send | `POST /message/rcs/validate` | Every check a send runs for your recipients and agent, with nothing written and no funds held. | { valid, errors, warnings, billingClass, segments, estimatedCostMicros, unsupportedFiles, recipients }. valid is true only with no errors. |
| Send | `POST /message/rcs` | The full send plan. | 400 for a problem with the whole request. A blocked recipient is a BLOCKED row with blockReason, reason and issues; the rest still send. |
| After queueing | `Webhooks, GET /message` | The carrier partner's answer. | reason in failed, blocked, expired and fallback webhooks, with fallbackReason or blockReason. |

| Code | When | How to fix it |
| --- | --- | --- |
| `CARD_EMPTY` | Save, publish and send | Give the card media or a title. A description alone is not enough. |
| `MEDIA_HEIGHT_REQUIRES_VERTICAL` | Save and publish | Remove mediaHeight from a horizontal card. |
| `ALIGNMENT_REQUIRES_HORIZONTAL` | Save and publish | Remove thumbnailImageAlignment from a vertical card. |
| `TTL_OUT_OF_RANGE` | Save and publish | Set defaults.ttlSeconds inside the range of defaults.trafficType. |
| `INFOBIP_TOO_MANY_MESSAGES` | Save and publish | Use at most 10 messages. A message is one content block and the suggestions after it. |
| `INFOBIP_PERSISTENT_UNSUPPORTED` | Save and publish | Remove persistent from the suggestion. |
| `INFOBIP_FALLBACK_URL_UNSUPPORTED` | Save and publish | Remove fallbackUrl from the suggestion. |
| `EVENT_IN_PAST` | A warning on save and publish; blocks the recipient at send | Move the calendar event's startTime into the future, then publish again. |
| `IOS_CHIPS_COLLAPSE` | A warning on save, publish, estimate and check | Keep a message to two suggested actions, or accept the Options menu on iPhone. |
| `IOS_CARD_BUTTONS_COLLAPSE` | A warning on save, publish, estimate and check | Keep a card to one button, or accept the Options menu on iPhone. |
| `IOS_GIF_STATIC` | A warning on save, publish, estimate and check | Send the GIF as a file to animate it on iPhone. |
| `IOS_TEXT_CLIPPED` | A warning on save, publish, estimate and check | Keep a card title or description to three lines. |
| `IOS_HORIZONTAL_CARD` | A warning on save, publish, estimate and check | Use a vertical card, or accept a vertical card with a cropped image on iPhone. |
| `IOS_CARD_LINK_PLAIN` | A warning on save, publish, estimate and check | Use an Open URL button in place of a link in card text. |
| `IOS_CARD_CODE_NOT_COPYABLE` | A warning on save, publish, estimate and check | Send a one-time code as plain text, not in a card. |
| `CONTENT_POLICY_FLAGGED` | Check and publish | Content moderation flagged a block's text or image, or the fallback text, for the category the message names. Change that content. When the moderation service cannot answer, the check passes, as a send does. An image URL with a variable is moderated at send instead, with its value filled in, and a refused image blocks the recipient with MODERATION. |
| `VARIABLE_MISSING` | Send | Send a value in recipients\[\].variables for each variable whose missingPolicy is block, or that is required with no default and no missingPolicy. A drop variable blocks the recipient when leaving out the blocks that use it leaves nothing to send. An empty value, or one of only spaces, counts as none. |
| `MEDIA_REDIRECT` | Send, check a send and estimate | Replace the external media URL with the URL its redirect leads to. |
| `TEMPLATE_ARCHIVED` | Send, check a send and estimate (409) | Send a template that is not archived. An archived template cannot be sent, edited or published. |

### /template

### POST /template

Create a template with draft version 1 (head revision 1). The draft may be incomplete: it saves, and validation lists what would stop it publishing.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Body Param | Required | Group that owns the template. Must be your active group, with RCS enabled (otherwise 403). |
| `name` | Body Param | Required | Library name, 1–120 characters, unique per group and channel. |
| `tag` | Body Param | Optional | Tag shown in the portal (1–60 characters). Presentation only; it never affects delivery. |
| `body` | Body Param | Required | The raw RCS template body (see the contract above). contentFormat is optional: omitted means content.v1; "google.rcs" sends Google's RBM content, which is converted and stored as content.v1. Drafts may be incomplete. |

#### Example Request

Request

```json
{
  "groupId": "G1234567",
  "name": "Order ready",
  "tag": "Order Confirmation",
  "body": {
    "channel": "rcs",
    "contentFormat": "content.v1",
    "content": {
      "blocks": [
        {
          "id": "b1",
          "kind": "text",
          "text": "Order {{order_number}} is ready."
        },
        {
          "id": "b2",
          "kind": "suggestions",
          "suggestions": [
            {
              "type": "REPLY",
              "label": "Thanks",
              "postbackData": "order_ack"
            }
          ]
        }
      ]
    },
    "variables": [
      {
        "key": "order_number",
        "type": "text",
        "required": true,
        "sample": "A-48213"
      }
    ],
    "defaults": {
      "trafficType": "TRANSACTION"
    },
    "fallback": {
      "delivery": {
        "channel": "sms",
        "campaignId": "CABC123",
        "phoneNumber": "15551234567",
        "content": {
          "text": "Order {{order_number}} is ready."
        }
      }
    }
  }
}
```

#### Example Response 201

Response

```json
{
  "head": {
    "templateId": "TPL7K3M9QXR2V",
    "groupId": "G1234567",
    "channel": "rcs",
    "name": "Order ready",
    "tag": "Order Confirmation",
    "archivedAt": null,
    "draftVersion": 1,
    "publishedVersion": null,
    "revision": 1,
    "createdBy": "60f7b2a1c9e77c001a2b3c4d",
    "createdAt": "2026-10-12T15:00:00.000Z",
    "updatedAt": "2026-10-12T15:00:00.000Z",
    "state": "DRAFT",
    "hasUnpublishedChanges": false
  },
  "version": {
    "templateId": "TPL7K3M9QXR2V",
    "groupId": "G1234567",
    "version": 1,
    "state": "DRAFT",
    "body": {
      "channel": "rcs",
      "contentFormat": "content.v1",
      "content": {
        "blocks": [
          {
            "id": "b1",
            "kind": "text",
            "text": "Order {{order_number}} is ready."
          },
          {
            "id": "b2",
            "kind": "suggestions",
            "suggestions": [
              {
                "type": "REPLY",
                "label": "Thanks",
                "postbackData": "order_ack"
              }
            ]
          }
        ]
      },
      "variables": [
        {
          "key": "order_number",
          "type": "text",
          "required": true,
          "sample": "A-48213"
        }
      ],
      "defaults": {
        "trafficType": "TRANSACTION"
      },
      "fallback": {
        "delivery": {
          "channel": "sms",
          "campaignId": "CABC123",
          "phoneNumber": "15551234567",
          "content": {
            "text": "Order {{order_number}} is ready."
          }
        }
      }
    },
    "contentHash": "9f2c4e…",
    "createdBy": "60f7b2a1c9e77c001a2b3c4d",
    "createdAt": "2026-10-12T15:00:00.000Z",
    "updatedAt": "2026-10-12T15:00:00.000Z",
    "publishedAt": null
  },
  "validation": {
    "valid": true,
    "errors": [],
    "warnings": []
  }
}
```

### GET /template

List a group's templates with server-side filters, sorting and pagination. Each row includes the derived state and hasUnpublishedChanges.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `billing`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Query Param | Required | Group that owns the templates. Must be a group you can view, with RCS enabled (otherwise 403). |
| `state` | Query Param | Optional | DRAFT, PUBLISHED or ARCHIVED. Omitted lists every template that is not archived. |
| `tag` | Query Param | Optional | Exact tag. |
| `search` | Query Param | Optional | Case-insensitive match on the template name. |
| `sortBy` | Query Param | Optional | name, createdAt or updatedAt (default updatedAt). |
| `sortOrder` | Query Param | Optional | asc or desc (default desc). |
| `page` | Query Param | Optional | Page number (default 1). |
| `limit` | Query Param | Optional | Results per page (default 25, maximum 100). |

#### Example Response 200

Response

```json
{
  "data": [
    {
      "templateId": "TPL7K3M9QXR2V",
      "groupId": "G1234567",
      "channel": "rcs",
      "name": "Order ready",
      "tag": "Order Confirmation",
      "archivedAt": null,
      "draftVersion": 2,
      "publishedVersion": 1,
      "revision": 3,
      "createdBy": "60f7b2a1c9e77c001a2b3c4d",
      "createdAt": "2026-10-12T15:00:00.000Z",
      "updatedAt": "2026-10-12T15:00:00.000Z",
      "state": "PUBLISHED",
      "hasUnpublishedChanges": true
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 25
}
```

### GET /template/capabilities

Describe the RCS contract's block kinds, action types, limits and accepted media, and optionally one provider's adapter constraints. Not account configuration.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `billing`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Query Param | Required | Group that owns the templates. Must be a group you can view, with RCS enabled (otherwise 403). |
| `provider` | Query Param | Optional | infobip or sinch: include that provider's adapter constraints and unsupported features. |

#### Example Response 200

Response

```json
{
  "channel": "rcs",
  "contentFormat": "content.v1",
  "contentFormats": [
    "content.v1",
    "google.rcs"
  ],
  "validatorVersion": "content-1.0.0",
  "blockKinds": [
    "text",
    "richCard",
    "video",
    "carousel",
    "suggestions",
    "attachment"
  ],
  "actionTypes": [
    "REPLY",
    "OPEN_URL",
    "DIAL",
    "VIEW_LOCATION",
    "SHARE_LOCATION",
    "CALENDAR"
  ],
  "limits": {
    "maxTextLength": 3072,
    "maxCardTitle": 200,
    "maxCardDescription": 2000,
    "maxSuggestionLabel": 25,
    "maxMessageSuggestions": 11,
    "maxRecipients": 100,
    "maxCardSuggestions": 4,
    "minCarouselCards": 2,
    "maxCarouselCards": 10,
    "maxCalendarTitle": 100,
    "maxCalendarDescription": 500,
    "minTtlSeconds": 10,
    "maxTtlSeconds": 172800
  },
  "ttlPresets": {
    "AUTHENTICATION": {
      "seconds": 30,
      "min": 15,
      "max": 300
    },
    "TRANSACTION": {
      "seconds": 900,
      "min": 60,
      "max": 86400
    },
    "SERVICEREQUEST": {
      "seconds": 900,
      "min": 60,
      "max": 86400
    },
    "ACKNOWLEDGEMENT": {
      "seconds": 300,
      "min": 60,
      "max": 3600
    },
    "PROMOTION": {
      "seconds": 14400,
      "min": 600,
      "max": 172800
    }
  },
  "trafficByUseCase": {
    "OTP": [
      "AUTHENTICATION"
    ],
    "TRANSACTIONAL": [
      "TRANSACTION",
      "SERVICEREQUEST",
      "ACKNOWLEDGEMENT"
    ],
    "PROMOTIONAL": [
      "PROMOTION"
    ],
    "MULTI_USE": [
      "AUTHENTICATION",
      "TRANSACTION",
      "SERVICEREQUEST",
      "ACKNOWLEDGEMENT",
      "PROMOTION"
    ]
  },
  "defaultTrafficByUseCase": {
    "OTP": "AUTHENTICATION",
    "TRANSACTIONAL": "TRANSACTION",
    "PROMOTIONAL": "PROMOTION"
  },
  "ios": {
    "cardButtonsInline": 1,
    "suggestedActionsInline": 2,
    "linesPerField": 3,
    "charsPerLine": 30
  },
  "media": {
    "maxUploadBytes": 10485760,
    "mimeTypes": [
      "image/jpeg",
      "image/png",
      "image/gif",
      "video/mp4",
      "audio/mpeg",
      "audio/mp4",
      "application/pdf"
    ],
    "maxImageEdge": 1920,
    "imageTargetBytes": 5000000
  },
  "geocoding": {
    "available": true
  },
  "provider": {
    "provider": "sinch",
    "adapterVersion": "sinch-rcs-1.0.0",
    "unsupported": [
      {
        "feature": "carousel",
        "code": "SINCH_CARD_WIDTH_UNMAPPED",
        "message": "Sinch has no verified carousel card-width mapping"
      }
    ]
  }
}
```

### GET /template/geocode

Resolve an address to coordinates for a VIEW\_LOCATION suggestion, through the server's geocoding provider. 400 with code LOCATION\_NOT\_FOUND when nothing matches; 429 past the group's window of 60 lookups a minute, which template saves and validations share; 503 when the server has no geocoding provider (capabilities.geocoding.available is false).

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `billing`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Query Param | Required | Group that owns the templates. Must be a group you can view, with RCS enabled (otherwise 403). |
| `address` | Query Param | Required | The address to resolve, 1–512 characters. |

#### Example Response 200

Response

```json
{
  "address": "88 Lakeshore Dr, Chicago, IL 60601, USA",
  "latitude": 41.8819,
  "longitude": -87.6278,
  "partialMatch": false
}
```

### POST /template/media

Upload one media file and get its public CDN URL to use in a template. An image with a longest edge over capabilities.media.maxImageEdge (1920) or over capabilities.media.imageTargetBytes (5,000,000 bytes) is compressed to both before it is stored; a GIF keeps its animation, a PNG stays PNG when it fits, and any other image is stored as JPEG, flattened onto white. An image within both is stored as uploaded. bytes, mimeType, width and height describe the stored file. An image over the MMS size limit (700 KB) also gets an MMS copy, in variants.mms ({ url, bytes }), with a longest edge of at most 1200; an MMS fallback leg sends the copy in place of the image, and a template may use the copy's URL where an image goes. variants is {} when there is no copy. The copy counts against the group's storage quota. Uploaded files are publicly reachable by anyone with the URL; never upload confidential documents.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `groupId` | Form Field | Required | Group that will own the file. Must be your active group. |
| `file` | Form Field | Required | One file, at most 10 MiB: JPEG, PNG, GIF, MP4, MP3, M4A or PDF. The type is read from the file's bytes, not its name or declared type. |

#### Example Response 201

Response

```json
{
  "mediaId": "MED4Q8ZK2M7TX",
  "groupId": "G1234567",
  "url": "https://media.signalhouse.io/message-templates/1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed.jpg",
  "bytes": 1482130,
  "mimeType": "image/jpeg",
  "kind": "image",
  "width": 1920,
  "height": 1005,
  "variants": {
    "mms": {
      "url": "https://media.signalhouse.io/message-templates/6f1c2a9e-4b7d-4e2f-8a31-0d5c9b7e2f14.jpg",
      "bytes": 612345
    }
  },
  "createdAt": "2026-10-12T15:00:00.000Z"
}
```

### GET /template/:templateId

Read a template head with one selected version.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `billing`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `templateId` | Path Param | Required | Template ID (TPL + 10 characters). |
| `groupId` | Query Param | Required | Group that owns the templates. Must be a group you can view, with RCS enabled (otherwise 403). |
| `version` | Query Param | Optional | A version number, "draft" or "published". Omitted means the published version, otherwise the draft. An explicit selector never falls back. |

#### Example Response 200

Response

```json
{
  "head": {
    "templateId": "TPL7K3M9QXR2V",
    "groupId": "G1234567",
    "channel": "rcs",
    "name": "Order ready",
    "tag": "Order Confirmation",
    "archivedAt": null,
    "draftVersion": 1,
    "publishedVersion": null,
    "revision": 1,
    "createdBy": "60f7b2a1c9e77c001a2b3c4d",
    "createdAt": "2026-10-12T15:00:00.000Z",
    "updatedAt": "2026-10-12T15:00:00.000Z",
    "state": "DRAFT",
    "hasUnpublishedChanges": false
  },
  "version": {
    "templateId": "TPL7K3M9QXR2V",
    "groupId": "G1234567",
    "version": 1,
    "state": "DRAFT",
    "body": {
      "channel": "rcs",
      "contentFormat": "content.v1",
      "content": {
        "blocks": [
          {
            "id": "b1",
            "kind": "text",
            "text": "Order {{order_number}} is ready."
          },
          {
            "id": "b2",
            "kind": "suggestions",
            "suggestions": [
              {
                "type": "REPLY",
                "label": "Thanks",
                "postbackData": "order_ack"
              }
            ]
          }
        ]
      },
      "variables": [
        {
          "key": "order_number",
          "type": "text",
          "required": true,
          "sample": "A-48213"
        }
      ],
      "defaults": {
        "trafficType": "TRANSACTION"
      },
      "fallback": {
        "delivery": {
          "channel": "sms",
          "campaignId": "CABC123",
          "phoneNumber": "15551234567",
          "content": {
            "text": "Order {{order_number}} is ready."
          }
        }
      }
    },
    "contentHash": "9f2c4e…",
    "createdBy": "60f7b2a1c9e77c001a2b3c4d",
    "createdAt": "2026-10-12T15:00:00.000Z",
    "updatedAt": "2026-10-12T15:00:00.000Z",
    "publishedAt": null
  }
}
```

### PUT /template/:templateId

Edit metadata or the draft body. A supplied body replaces the whole draft; nothing is merged. Editing a published template opens its next draft.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `templateId` | Path Param | Required | Template ID (TPL + 10 characters). |
| `groupId` | Body Param | Required | Group that owns the template. Must be your active group, with RCS enabled (otherwise 403). |
| `name` | Body Param | Optional | New library name. Omit to keep. |
| `tag` | Body Param | Optional | New tag, or null to clear. Omit to keep. |
| `body` | Body Param | Optional | Replaces the whole draft body. On a published template with no draft, creates draft version published + 1. An update with no fields on such a template opens a draft copy of the published body. |

#### Example Request

Request

```json
{
  "groupId": "G1234567",
  "body": {
    "channel": "rcs",
    "contentFormat": "content.v1",
    "content": {
      "blocks": [
        {
          "id": "b1",
          "kind": "text",
          "text": "Order {{order_number}} is ready."
        },
        {
          "id": "b2",
          "kind": "suggestions",
          "suggestions": [
            {
              "type": "REPLY",
              "label": "Thanks",
              "postbackData": "order_ack"
            }
          ]
        }
      ]
    },
    "variables": [
      {
        "key": "order_number",
        "type": "text",
        "required": true,
        "sample": "A-48213"
      }
    ],
    "defaults": {
      "trafficType": "TRANSACTION"
    },
    "fallback": {
      "delivery": {
        "channel": "sms",
        "campaignId": "CABC123",
        "phoneNumber": "15551234567",
        "content": {
          "text": "Order {{order_number}} is ready."
        }
      }
    }
  }
}
```

#### Example Response 200

Response

```json
{
  "head": {
    "templateId": "TPL7K3M9QXR2V",
    "groupId": "G1234567",
    "channel": "rcs",
    "name": "Order ready",
    "tag": "Order Confirmation",
    "archivedAt": null,
    "draftVersion": 1,
    "publishedVersion": null,
    "revision": 2,
    "createdBy": "60f7b2a1c9e77c001a2b3c4d",
    "createdAt": "2026-10-12T15:00:00.000Z",
    "updatedAt": "2026-10-12T15:00:00.000Z",
    "state": "DRAFT",
    "hasUnpublishedChanges": false
  },
  "version": {
    "templateId": "TPL7K3M9QXR2V",
    "groupId": "G1234567",
    "version": 1,
    "state": "DRAFT",
    "body": {
      "channel": "rcs",
      "contentFormat": "content.v1",
      "content": {
        "blocks": [
          {
            "id": "b1",
            "kind": "text",
            "text": "Order {{order_number}} is ready."
          },
          {
            "id": "b2",
            "kind": "suggestions",
            "suggestions": [
              {
                "type": "REPLY",
                "label": "Thanks",
                "postbackData": "order_ack"
              }
            ]
          }
        ]
      },
      "variables": [
        {
          "key": "order_number",
          "type": "text",
          "required": true,
          "sample": "A-48213"
        }
      ],
      "defaults": {
        "trafficType": "TRANSACTION"
      },
      "fallback": {
        "delivery": {
          "channel": "sms",
          "campaignId": "CABC123",
          "phoneNumber": "15551234567",
          "content": {
            "text": "Order {{order_number}} is ready."
          }
        }
      }
    },
    "contentHash": "9f2c4e…",
    "createdBy": "60f7b2a1c9e77c001a2b3c4d",
    "createdAt": "2026-10-12T15:00:00.000Z",
    "updatedAt": "2026-10-12T15:00:00.000Z",
    "publishedAt": null
  },
  "validation": {
    "valid": true,
    "errors": [],
    "warnings": []
  }
}
```

### POST /template/:templateId/publish

Validate the current draft and publish it; with no draft this returns 409 NO\_DRAFT, and if the draft changed while it was being published, 409 DRAFT\_CHANGED. Published versions are immutable. An incomplete draft returns 400 with details.code TEMPLATE\_INVALID and per-block errors, and nothing is written. Publish moderates each block's text and images and the fallback text: a flag is a CONTENT\_POLICY\_FLAGGED error whose message names the category. When the moderation service cannot answer, the check passes, as a send does. An image URL with a variable is moderated at send instead, with its value filled in, and a refused image blocks the recipient with MODERATION.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `templateId` | Path Param | Required | Template ID (TPL + 10 characters). |
| `groupId` | Body Param | Required | Group that owns the template. Must be your active group, with RCS enabled (otherwise 403). |

#### Example Request

Request

```json
{
  "groupId": "G1234567"
}
```

#### Example Response 200

Response

```json
{
  "head": {
    "templateId": "TPL7K3M9QXR2V",
    "groupId": "G1234567",
    "channel": "rcs",
    "name": "Order ready",
    "tag": "Order Confirmation",
    "archivedAt": null,
    "draftVersion": null,
    "publishedVersion": 1,
    "revision": 2,
    "createdBy": "60f7b2a1c9e77c001a2b3c4d",
    "createdAt": "2026-10-12T15:00:00.000Z",
    "updatedAt": "2026-10-12T15:00:00.000Z",
    "state": "PUBLISHED",
    "hasUnpublishedChanges": false
  },
  "version": {
    "templateId": "TPL7K3M9QXR2V",
    "groupId": "G1234567",
    "version": 1,
    "state": "PUBLISHED",
    "body": {
      "channel": "rcs",
      "contentFormat": "content.v1",
      "content": {
        "blocks": [
          {
            "id": "b1",
            "kind": "text",
            "text": "Order {{order_number}} is ready."
          },
          {
            "id": "b2",
            "kind": "suggestions",
            "suggestions": [
              {
                "type": "REPLY",
                "label": "Thanks",
                "postbackData": "order_ack"
              }
            ]
          }
        ]
      },
      "variables": [
        {
          "key": "order_number",
          "type": "text",
          "required": true,
          "sample": "A-48213"
        }
      ],
      "defaults": {
        "trafficType": "TRANSACTION"
      },
      "fallback": {
        "delivery": {
          "channel": "sms",
          "campaignId": "CABC123",
          "phoneNumber": "15551234567",
          "content": {
            "text": "Order {{order_number}} is ready."
          }
        }
      }
    },
    "contentHash": "9f2c4e…",
    "createdBy": "60f7b2a1c9e77c001a2b3c4d",
    "createdAt": "2026-10-12T15:00:00.000Z",
    "updatedAt": "2026-10-12T15:00:00.000Z",
    "publishedAt": "2026-10-12T15:05:00.000Z"
  },
  "warnings": []
}
```

### POST /template/:templateId/archive

Archive a template. Every version stays readable; there is no delete.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `templateId` | Path Param | Required | Template ID (TPL + 10 characters). |
| `groupId` | Body Param | Required | Group that owns the template. Must be your active group, with RCS enabled (otherwise 403). |

#### Example Request

Request

```json
{
  "groupId": "G1234567"
}
```

#### Example Response 200

Response

```json
{
  "templateId": "TPL7K3M9QXR2V",
  "groupId": "G1234567",
  "channel": "rcs",
  "name": "Order ready",
  "tag": "Order Confirmation",
  "archivedAt": "2026-10-12T16:00:00.000Z",
  "draftVersion": null,
  "publishedVersion": 1,
  "revision": 3,
  "createdBy": "60f7b2a1c9e77c001a2b3c4d",
  "createdAt": "2026-10-12T15:00:00.000Z",
  "updatedAt": "2026-10-12T15:00:00.000Z",
  "state": "ARCHIVED",
  "hasUnpublishedChanges": false
}
```

### GET /template/:templateId/versions

List a template's versions, newest first, without bodies.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `billing`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `templateId` | Path Param | Required | Template ID (TPL + 10 characters). |
| `groupId` | Query Param | Required | Group that owns the templates. Must be a group you can view, with RCS enabled (otherwise 403). |
| `page` | Query Param | Optional | Page number (default 1). |
| `limit` | Query Param | Optional | Results per page (default 25, maximum 100). |

#### Example Response 200

Response

```json
{
  "data": [
    {
      "templateId": "TPL7K3M9QXR2V",
      "groupId": "G1234567",
      "version": 1,
      "state": "DRAFT",
      "contentHash": "9f2c4e…",
      "createdBy": "60f7b2a1c9e77c001a2b3c4d",
      "createdAt": "2026-10-12T15:00:00.000Z",
      "updatedAt": "2026-10-12T15:00:00.000Z",
      "publishedAt": null
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 25
}
```

### POST /template/:templateId/validate

Check a supplied body or a stored version for publication without writing anything. Hosted media must belong to your group; external media URLs are not probed. Content moderation runs as at publish, so a flagged text or image is a CONTENT\_POLICY\_FLAGGED error, and an image URL with a variable is left to the send.

**The following roles are required to use this endpoint:** `admin`, `developer`, `api`, `billing`, `user`

#### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `templateId` | Path Param | Required | Template ID (TPL + 10 characters). |
| `groupId` | Body Param | Required | Group that owns the template. Must be your active group, with RCS enabled (otherwise 403). |
| `body` | Body Param | Optional | A body to check. Send exactly one of body or version. |
| `version` | Body Param | Optional | A stored version number, "draft" or "published" to check. |

#### Example Request

Request

```json
{
  "groupId": "G1234567",
  "version": "draft"
}
```

#### Example Response 200

Response

```json
{
  "valid": false,
  "contentHash": "9f2c4e…",
  "validatorVersion": "content-1.0.0",
  "errors": [
    {
      "severity": "error",
      "code": "TEXT_REQUIRED",
      "path": "content.blocks[0].text",
      "message": "Message text is required",
      "blockId": "b1"
    }
  ],
  "warnings": [
    {
      "severity": "warning",
      "code": "VARIABLE_UNUSED",
      "path": "variables[0]",
      "message": "first_name is declared but never used"
    }
  ]
}
```
