---
title: "/chat/send-template"
method: POST
path: "/chat/send-template"
tags: ["Chat"]
---

# /chat/send-template

`POST /chat/send-template`

Create a new chat and send a template message

## Headers

- `octa-agent-email` string

## Request body

- CreateChat
  - `origin` Origin, required
    - `contact` ContactMessage, required
      - `channel` 'whatsapp', required — Channel through which the contact will send or receive the message
      - `code` string, required — This field must be filled in with the WhatsApp number.
      - `name` string — The name of the contact
      - `email` string — The email of the contact
      - `id` string — ID of the contact
  - `target` Target, required
    - `contact` ContactMessage, required
      - `channel` 'whatsapp', required — Channel through which the contact will send or receive the message
      - `code` string, required — This field must be filled in with the WhatsApp number.
      - `name` string — The name of the contact
      - `email` string — The email of the contact
      - `id` string — ID of the contact
  - `content` Content, required
    - `templateMessage` TemplateMessage, required
      - `id` string — Template ID. If code is present, this attribute is not necessary
      - `code` string — Template code. If ID is present, this attribute is not necessary
      - `variables` CustomField[] — Template variables
        - `key` string, required — Key of the field (as it is shown inside octadesk)
        - `value` union, required — Value to use on the template
          - string
          - number
  - `options` Options
    - `automaticAssign` boolean, required — Automatic assign

## Response `201`

- SendTemplateMessageResponse
  - `result` SendTemplateMessageResult, required
    - `messageKey` string, required — The key of the message that was sent. Usable for us to find the message on our system.
    - `roomKey` string, required — The key of the chat created. Use this to find the message on our app.
  - `error` object, required — The error that occurred during the execution of the method. The message was NOT sent.
  - `errorCode` string — The error code returned by the provider (e.g. Meta/WhatsApp) when available
  - `errorMessage` string — The detailed error message returned by the provider (e.g. Meta/WhatsApp) when available

---

[API](https://skmtc.net/octadesk/apis/octadesk-api.md) · [All operations](https://skmtc.net/octadesk/apis/octadesk-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/octadesk/octadesk-api/versions/bc5e6dccb979/schema)
