> For the complete documentation index, see [llms.txt](https://docs.tsgglobal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tsgglobal.com/api-reference/programmable-mms/send-an-mms-message-using-templates/create-mms-template.md).

# Create MMS Template

### Authentication

{% hint style="info" %}
Authentication is done by passing your TSG Global API key via the Authorization header in the format "Authorization: Bearer \<api\_key>" (using the messaging API key specifically). API credentials can be found here: <https://customer-portal.tsgglobal.com/account>
{% endhint %}

<mark style="color:green;">`POST`</mark> `https://mmsc.tsgglobal.world/mms/templates`

Creates a new MMS template, the template has placeholders so you can use it to fill per-customer information as needed.

### **Request body**

| Name                                       | Type   | Description                                                                        |
| ------------------------------------------ | ------ | ---------------------------------------------------------------------------------- |
| `data.type`                                | string | Must be `"mms-template"`                                                           |
| `data.attributes.name`                     | string | **Required.** Template name                                                        |
| `data.attributes.body_template`            | string | **Required.** Body text with `{placeholder}` syntax                                |
| `data.attributes.subject_template`         | string | Optional. Subject line with `{placeholder}` syntax                                 |
| `data.attributes.parts`                    | array  | Optional. List of attachment parts (see below)                                     |
| `data.attributes.parts[].kind`             | string | **Required.** One of `"data-uri"`, `"uri"`, `"plain"`, `"embedded"`                |
| `data.attributes.parts[].content_location` | string | Optional. Filename for the attachment                                              |
| `data.attributes.parts[].uri`              | string | Required for `"uri"` and `"data-uri"` kinds. The resource URI or RFC 2397 data URI |
| `data.attributes.parts[].body`             | string | Required for `"plain"` kind                                                        |
| `data.attributes.parts[].content_type`     | string | Optional. MIME type (default: `"text/plain"`)                                      |

Placeholders use the pattern `{key}` where key matches `[a-zA-Z_][a-zA-Z0-9_]*`. Extracted placeholders are returned in the response.

### &#x20;Example with placeholders

#### Example of a request

Besides the text in `body_template` there's 2 parts: a Base64 encoded attachment (`kind: "data-uri"`) and a image that's referenced by a URL (`"kind": "uri"`).

```json
{
  "data": {
    "type": "mms-template",
    "attributes": {
      "name": "visit-thank-you",
      "subject_template": "Hello {name}",
      "body_template": "Dear {name}, welcome to {company}.",
      "parts": [
        {
          "kind": "data-uri",
          "content_location": "brochure.txt",
          "uri": "data:text/plain,Hello%20Brochure"
        },
        {
          "kind": "uri",
          "content_location": "unnamed-1.png",
          "uri": "https://www.tsgglobal.com/wp-content/uploads/2025/01/unnamed-1.png"
        }
      ]
    }
  }
}
```

#### Example response

```json
{
  "data": {
    "attributes": {
      "name": "visit-thank-you",
      "parts": [
        {
          "uri": "https://content-mms.staging.smshub.world/templates/491aa990-1fbb-4058-8af0-c78049010d2f/attachments/1-brochure.txt",
          "content_type": "text/plain",
          "content_location": "brochure.txt"
        },
        {
          "uri": "https://content-mms.staging.smshub.world/templates/491aa990-1fbb-4058-8af0-c78049010d2f/attachments/2-unnamed-1.png",
          "content_type": "image/png",
          "content_location": "unnamed-1.png"
        }
      ],
      "inserted_at": "2026-03-20T19:53:02.165449",
      "updated_at": "2026-03-20T19:53:02.165449",
      "placeholders": [
        "name",
        "company"
      ],
      "body_template": "Dear {name}, welcome to {company}.",
      "subject_template": "Hello {name}"
    },
    "id": "491aa990-1fbb-4058-8af0-c78049010d2f",
    "type": "mms-template"
  }
}

```

### Example without placeholders

This is an example with no placeholders (notice the lack of `{placeholder}` syntax.

#### Example of a request

This is an example without placeholders and a single image attachment provided via  (`"kind": "uri"`). **Note:** the attachment has to be publicly accessible.&#x20;

```json
{
  "data": {
    "type": "mms-template",
    "attributes": {
      "name": "no-placeholder-example",
      "subject_template": "New deals!",
      "body_template": "Check our new deals!",
      "parts": [
        {
          "kind": "uri",
          "content_location": "unnamed-1.png",
          "uri": "https://www.tsgglobal.com/wp-content/uploads/2025/01/unnamed-1.png"
        }
      ]
    }
  }
}
```

#### Example response

```json
{
  "data": {
    "attributes": {
      "name": "no-placeholder-example",
      "parts": [
        {
          "uri": "https://content-mms.staging.smshub.world/templates/491aa990-1fbb-4058-8af0-c78049010d2f/attachments/2-unnamed-1.png",
          "content_type": "image/png",
          "content_location": "unnamed-1.png"
        }
      ],
      "inserted_at": "2026-03-20T19:53:02.165449",
      "updated_at": "2026-03-20T19:53:02.165449",
      "placeholders": [
        "name",
        "company"
      ],
      "body_template": "Check out our new deals!",
      "subject_template": "New deals!"
    },
    "id": "491aa990-1fbb-4058-8af0-c78049010d2f",
    "type": "mms-template"
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tsgglobal.com/api-reference/programmable-mms/send-an-mms-message-using-templates/create-mms-template.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
