> ## Documentation Index
> Fetch the complete documentation index at: https://developers.heymarket.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates API overview and objects

> Understand the Template object, merge token syntax, and the full set of endpoints for creating and managing reusable message templates.

Templates are pre-defined messages with text and optional media. They support merge tokens that auto-populate contact fields when sending, so you can personalize messages at scale without writing custom copy for every recipient.

## The Template object

<ResponseField name="id" type="integer">
  Unique identifier for the template.
</ResponseField>

<ResponseField name="name" type="string">
  Display name of the template.
</ResponseField>

<ResponseField name="local_id" type="string">
  Client-provided unique identifier. Use this to map templates to records in your own system.
</ResponseField>

<ResponseField name="content" type="object">
  A GalleryContent object containing the message text and optional images. See the [Content object](#the-gallerycontent-object) section below.
</ResponseField>

<ResponseField name="team_id" type="integer">
  Identifier of the team that owns this template.
</ResponseField>

<ResponseField name="creator_id" type="integer">
  Identifier of the user who created the template.
</ResponseField>

<ResponseField name="shared" type="boolean">
  Whether the template is shared with all members of the team.
</ResponseField>

<ResponseField name="created" type="string">
  ISO 8601 timestamp when the template was created.
</ResponseField>

<ResponseField name="updated" type="string">
  ISO 8601 timestamp when the template was last updated.
</ResponseField>

<ResponseField name="rev" type="integer">
  Revision number. Increments on each update.
</ResponseField>

<ResponseField name="archived" type="boolean">
  Whether the template has been archived.
</ResponseField>

## The GalleryContent object

<ResponseField name="text" type="string">
  The message body. May contain merge tokens such as `{{first_name}}`.
</ResponseField>

<ResponseField name="gallery" type="object[]">
  Array of GalleryEntry objects representing images attached to the message.

  <Expandable title="GalleryEntry properties">
    <ResponseField name="url" type="string">
      URL of the image as stored by Heymarket.
    </ResponseField>

    <ResponseField name="original_url" type="string">
      Original source URL of the image before upload.
    </ResponseField>

    <ResponseField name="annotation_text" type="string">
      Optional caption or annotation text displayed with the image.
    </ResponseField>

    <ResponseField name="annotation_position" type="string">
      Position of the annotation relative to the image.
    </ResponseField>
  </Expandable>
</ResponseField>

## Merge tokens

Merge tokens let you personalize template text using contact field values. When a message is sent, Heymarket replaces each token with the corresponding value from the recipient's contact record.

| Token                   | Replaced with                   |
| ----------------------- | ------------------------------- |
| `{{first_name}}`        | Contact's first name            |
| `{{last_name}}`         | Contact's last name             |
| `{{custom_field_name}}` | Value of a custom contact field |

## Endpoints

| Method   | Endpoint            | Description          |
| -------- | ------------------- | -------------------- |
| `POST`   | `/v1/template`      | Create a template    |
| `GET`    | `/v1/template/{id}` | Get a template by ID |
| `PUT`    | `/v1/template/{id}` | Update a template    |
| `DELETE` | `/v1/template/{id}` | Delete a template    |
| `POST`   | `/v1/templates`     | List templates       |
