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

# /chat/send-template

`POST /chat/send-template`

## Request

- Base URL: `<<api-url>>` (relative, and the document’s source URL is not known)
- URL: `<<api-url>>/chat/send-template`
- Auth: API key in header `X-API-KEY`

Create a new chat and send a template message

## Headers

- `octa-agent-email` string

## Request body

- CreateChat
  - `origin` Origin, required: Information about who sent the message
    - `contact` ContactMessage, required: Information of the contact who will receive or send the message
      - `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: Information about who receive the message
    - `contact` ContactMessage, required: Information of the contact who will receive or send the message
      - `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: Message that will be sent
    - `templateMessage` TemplateMessage, required: Template info
      - `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: Options for the message
    - `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.dev/octadesk/apis/octadesk-api.md) - [All operations](https://skmtc.dev/octadesk/apis/octadesk-api/llms.txt) - [OpenAPI document](https://skmtc.dev/octadesk/apis/octadesk-api/revisions/cf3224b37a34?raw)
