Mailrelay API Reference

Create a new WhatsApp template

POST https://{account}/api/v1/whatsapp/templates

Authentication

Requires an API key sent in the X-AUTH-TOKEN header.

Create a new WhatsApp message template in DRAFT status.

Components Examples

Basic template:

{
  "components": [
    {
      "type": "BODY",
      "text": "Hello {{subscriber_name}}, welcome to our service!",
      "example": {
        "body_text_named_params": [{ "param_name": "subscriber_name", "example": "John" }]
      }
    }
  ]
}

Template with text header and footer:

{
  "components": [
    {
      "type": "HEADER",
      "format": "TEXT",
      "text": "Welcome to our service"
    },
    {
      "type": "BODY",
      "text": "Thank you for joining us!"
    },
    {
      "type": "FOOTER",
      "text": "Thank you for using our service"
    }
  ]
}

Template with buttons:

{
  "components": [
    {
      "type": "BODY",
      "text": "Visit our website to learn more!"
    },
    {
      "type": "BUTTONS",
      "buttons": [
        {
          "type": "URL",
          "text": "Visit Website",
          "url": "https://example.com"
        }
      ]
    }
  ]
}

Parameters

NameTypeRequiredDescription
name string Yes Name
category string Yes Category
language string Yes Language
waba_id string Yes WhatsApp Business Account
components array Yes An array of template components. Must include exactly one BODY component. Optional components: HEADER (TEXT, IMAGE, VIDEO, or DOCUMENT format), FOOTER, and BUTTONS (up to 2 URL buttons).
header_media No

Responses

StatusDescription
201 Success
400 The request is invalid. Check if the field names in the request and the request data is valid.
422 A validation error occurred. Check the response body for more information.
401 The API key wasn't sent or is invalid
429 Too many requests. You have exceeded the rate limit, wait and try again later.
500 An internal error happened. Try again later.
403 WhatsApp endpoints require the WhatsApp add-on package or a paid plan.

Response fields

NameTypeDescription
id integer ID
name string Name
template_id string Template
template_version string Template version
category string Category
language string Language
status string Status
rejected_reason string Rejected reason
waba_id string WhatsApp Business Account
created_at string Created at
updated_at string Updated at
components array An array of template components. Must include exactly one BODY component. Optional components: HEADER (TEXT, IMAGE, VIDEO, or DOCUMENT format), FOOTER, and BUTTONS (up to 2 URL buttons).
header_media object