Skip to content
Klozzo API
OpenAPI Postman

Reference

Message Templates

Reusable message bodies with @{{variable}} placeholders. Variables are auto-detected on save and resolved against contact fields (and custom fields) at render time. Templates are scoped per channel and optionally per location.

List message templates

Lists the message templates of this location, newest first. Filter by channel, location, or category.

GET /api/message-templates

Query parameters

  • channel string

    Filter by channel. One of sms, email, whatsapp, etc.

    Example: whatsapp

  • location_id integer

    Scope to a location.

    Example: 1

  • category string

    Optional grouping label.

    Example: appointment-reminders

  • per_page integer

    Rows per page. Default 20, maximum 100. See Lists, paging and filters.

    Example: 20

curl --request GET \
    --get "https://klozzo.com/api/message-templates?channel=whatsapp&location_id=1&category=appointment-reminders&per_page=20" \
    --header "Authorization: Bearer {YOUR_API_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
{
    "data": [
        {
            "id": null,
            "location_id": null,
            "user_id": 3787,
            "name": "Template aut adipisci quidem",
            "channel": "sms",
            "body": "Hi {{contact.first_name}}, thanks for reaching out!",
            "variables": [
                "contact.first_name"
            ],
            "category": "general",
            "created_at": null,
            "updated_at": null
        },
        {
            "id": null,
            "location_id": null,
            "user_id": 3788,
            "name": "Template quia officia est",
            "channel": "sms",
            "body": "Hi {{contact.first_name}}, thanks for reaching out!",
            "variables": [
                "contact.first_name"
            ],
            "category": "general",
            "created_at": null,
            "updated_at": null
        }
    ],
    "links": {
        "first": "/?page=1",
        "last": "/?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "links": [
            {
                "url": null,
                "label": "« Previous",
                "page": null,
                "active": false
            },
            {
                "url": "/?page=1",
                "label": "1",
                "page": 1,
                "active": true
            },
            {
                "url": null,
                "label": "Next »",
                "page": null,
                "active": false
            }
        ],
        "path": "/",
        "per_page": 20,
        "to": 2,
        "total": 2
    }
}
  • data object[]

    • id string

    • location_id string

    • user_id integer

    • name string

    • channel string

    • body string

    • variables string[]

    • category string

    • created_at string

    • updated_at string

  • links object

    • first string

    • last string

    • prev string

    • next string

  • meta object

    • current_page integer

    • from integer

    • last_page integer

    • links object[]

      • url string

      • label string

      • page string

      • active boolean

    • path string

    • per_page integer

    • to integer

    • total integer

Create a message template

Creates a message template for one channel. On save, @{{variable}} tokens in body are extracted into the variables column for fast lookup at render time. Re-extraction happens on every update.

POST /api/message-templates

Body parameters

  • location_id integer

    Scope to a specific location.

    Example: 1

  • name string required

    Display name (max 120).

    Example: Appointment reminder

  • channel string required

    One of sms, email, whatsapp, messenger, instagram, gmb.

    Example: whatsapp

  • body string required

    Template body with @{{variable}} placeholders.

    Example: Hi @{{first_name}}, your appointment is on @{{appointment_date}}.

  • category string

    Optional grouping label (max 60).

    Example: appointment-reminders

curl --request POST \
    "https://klozzo.com/api/message-templates" \
    --header "Authorization: Bearer {YOUR_API_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"location_id\": 1,
    \"name\": \"Appointment reminder\",
    \"channel\": \"whatsapp\",
    \"body\": \"Hi @{{first_name}}, your appointment is on @{{appointment_date}}.\",
    \"category\": \"appointment-reminders\"
}"
{
    "data": {
        "id": null,
        "location_id": null,
        "user_id": 3789,
        "name": "Template et animi quos",
        "channel": "sms",
        "body": "Hi {{contact.first_name}}, thanks for reaching out!",
        "variables": [
            "contact.first_name"
        ],
        "category": "general",
        "created_at": null,
        "updated_at": null
    }
}
  • data object

    • id string

    • location_id string

    • user_id integer

    • name string

    • channel string

    • body string

    • variables string[]

    • category string

    • created_at string

    • updated_at string

Fetch a message template

Returns one message template by id, with the variables list extracted from its body. Read that list before rendering: it is the contract of what this template needs, and it is derived from the body rather than declared, so it is never out of date.

GET /api/message-templates/{messageTemplate_id}

To get the finished text for a person, use POST /api/message-templates/{id}/render instead of substituting on your side — the CRM knows about custom fields and fallbacks, and your string replace does not.

Path parameters

  • messageTemplate_id integer required

    Template ID.

    Example: 11

curl --request GET \
    --get "https://klozzo.com/api/message-templates/11" \
    --header "Authorization: Bearer {YOUR_API_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
{
    "data": {
        "id": null,
        "location_id": null,
        "user_id": 3790,
        "name": "Template nostrum qui commodi",
        "channel": "sms",
        "body": "Hi {{contact.first_name}}, thanks for reaching out!",
        "variables": [
            "contact.first_name"
        ],
        "category": "general",
        "created_at": null,
        "updated_at": null
    }
}
  • data object

    • id string

    • location_id string

    • user_id integer

    • name string

    • channel string

    • body string

    • variables string[]

    • category string

    • created_at string

    • updated_at string

Delete a message template

Deletes a message template by id, so it stops being offered when composing. Messages already sent from it are untouched — they were rendered to plain text at send time and do not reference it.

DELETE /api/message-templates/{messageTemplate_id}

Path parameters

  • messageTemplate_id integer required

    Template ID.

    Example: 11

curl --request DELETE \
    "https://klozzo.com/api/message-templates/11" \
    --header "Authorization: Bearer {YOUR_API_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
{
    "message": "Template deleted."
}
  • message string

Render template against a contact

Returns the template body with @{{variable}} placeholders replaced by the contact's matching fields. missing lists variables that could not be resolved (useful for UI hints before sending).

POST /api/message-templates/{messageTemplate_id}/render

Path parameters

  • messageTemplate_id integer required

    Template ID.

    Example: 11

Body parameters

  • contact_id integer required

    Contact to render against.

    Example: 42

curl --request POST \
    "https://klozzo.com/api/message-templates/11/render" \
    --header "Authorization: Bearer {YOUR_API_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"contact_id\": 42
}"
{
    "rendered": "Hi Ada, your appointment is on 2026-06-08.",
    "missing": [],
    "channel": "whatsapp"
}
  • rendered string

  • missing array

  • channel string