TSGGLOBAL Support sign in
Skip to page content
Browse TSG Global API docs

TSG Global API documentation Programmable MMS Send an MMS Message Using Templates Create MMS Template

Create MMS Template

On this page

POST /mms/templates: create a reusable MMS template with {placeholder} text and pre-staged attachments.

Authentication

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

POST https://mmsc.tsgglobal.world/mms/templates

Creates a new MMS template. The template has placeholders so you can fill in per-customer information when you send.

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. Attachments are copied to TSG-hosted storage at creation, so the uri values in the response differ from the ones you sent.

Example with placeholders

Example of a request

Besides the text in body_template there are 2 parts: a data URI attachment (kind: "data-uri") and an image referenced by URL (kind: "uri").

{
  "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

{
  "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

A template does not have to contain placeholders. This example has none and a single image attachment provided by URL (kind: "uri"). Note: the attachment has to be publicly accessible.

Example of a request

{
  "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

{
  "data": {
    "attributes": {
      "name": "no-placeholder-example",
      "parts": [
        {
          "uri": "https://content-mms.staging.smshub.world/templates/7c0e2d1a-5b3f-4c8e-9a21-0f6d4e8b2c17/attachments/1-unnamed-1.png",
          "content_type": "image/png",
          "content_location": "unnamed-1.png"
        }
      ],
      "inserted_at": "2026-03-20T19:55:10.412001",
      "updated_at": "2026-03-20T19:55:10.412001",
      "placeholders": [],
      "body_template": "Check our new deals!",
      "subject_template": "New deals!"
    },
    "id": "7c0e2d1a-5b3f-4c8e-9a21-0f6d4e8b2c17",
    "type": "mms-template"
  }
}