Skip to content

Send a message ​

Send a manual message from the authenticated user into a conversation. The message is persisted, delivered through the conversation's connected channel, and broadcast to any subscribed socket clients.

You can send text, attachments (or both), or an approved WhatsApp Cloud template (for example, after the 24-hour customer-service window has passed) — at least one is required.

POST/api/user/{conversation}/messages
Required scope: messages:send
Path parameters
integer
Request body (JSON)
curl -X POST "https://loopx-console.test/api/user/89328/messages" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"message":"Hi Ali, following up on your pricing question — happy to jump on a quick call this week."}'
<?php

use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('POST', 'https://loopx-console.test/api/user/89328/messages', [
    'headers' => [
        'Authorization' => 'Bearer $TOKEN',
        'Accept'        => 'application/json',
    ],
    'json' => [
        'message' => 'Hi Ali, following up on your pricing question — happy to jump on a quick call this week.'
    ]
]);

$data = json_decode($response->getBody(), true);
const res = await fetch('https://loopx-console.test/api/user/89328/messages', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer $TOKEN',
    Accept: 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "message": "Hi Ali, following up on your pricing question — happy to jump on a quick call this week."
  })
});

const data = await res.json();

Example response

{
  "status": true,
  "code": 200,
  "validation": [],
  "message": "Message Sent",
  "data": {
    "_id": "68e0f4a3c2b1a9f0d3e5a7b2",
    "role": "assistant",
    "status": "sent_to_user",
    "message": "Hi Ali, following up on your pricing question — happy to jump on a quick call this week.",
    "cost_for_user": 0,
    "external_chat_id": "120248819452900116",
    "conversation_id": 89328,
    "opportunity_id": 98314,
    "contact_id": 44016,
    "channel_id": 512,
    "stage_id": 189,
    "pipeline_id": 17,
    "call_type": "chat",
    "sender_id": 731,
    "files": [],
    "created_at": "2026-07-15T10:22:41.000000Z",
    "updated_at": "2026-07-15T10:22:43.000000Z"
  }
}

The runnable widget above sends JSON only

Attachments require a multipart/form-data request — use the curl / PHP / Node examples in the Sending attachments section below.

Path parameters ​

NameTypeRequiredDescription
conversationintegeryesConversation id — must belong to your workspace (or a workspace you manage)

Request body ​

Provide message, files (or both), or template. Sending none of them returns a 422.

FieldTypeDescription
messagestring | nullMessage text. Max 10,000 characters. Overridden by the rendered template body when template is sent.
filesfile[] | nullUp to 10 files, each ≤ 25 MB. Requires multipart/form-data. Cannot be combined with template.
templateobject | nullAn approved WhatsApp Cloud template with one text variable and no media header, sent instead of message (for example, once the 24-hour customer-service window has closed). Only supported on Meta WhatsApp Cloud channels. Cannot be combined with files.
template.idstringRequired with template. The Meta template id (max 255 chars).
template.namestringRequired with template. The approved template name on Meta (max 255 chars).
template.languagestringRequired with template. Template language code, e.g. en, en_US, ar (max 20 chars).
template.variablestringRequired with template. The text value that fills the template's single variable (max 1,024 chars).

Sending a WhatsApp template ​

On Meta WhatsApp Cloud channels (connector = meta, provider = whatsapp), Meta only allows free-form text and media within 24 hours of the contact's last message. Once the 24-hour customer-service window has passed, you can reach the contact by sending an approved WhatsApp template via the template object.

Use List WhatsApp templates with ?for_text_message=1 to retrieve the id, name, and language of eligible templates on the channel.

Template requirements

The template is verified live against Meta on every send and must meet all of the following conditions, or the request is rejected with a 422:

  • Only 1 text variable: The template must contain exact one variable (type = text, positional such as {{1}} or named such as {{order_id}}). Templates with 0 variables or 2+ variables are rejected.
  • Text-only (no media header): The template header (if any) must be TEXT (header.format is TEXT or null). Templates with IMAGE, VIDEO, DOCUMENT, or LOCATION headers are rejected.
  • Approved on the channel: The template (id, name, and language) must exist on the conversation's Meta WhatsApp Cloud channel with status = APPROVED.
  • No file attachments: files cannot be sent in the same request (prohibits:template).

curl ​

bash
curl -X POST "https://api.genudo.ai/api/user/89328/messages" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "template": {
      "id": "99918273645",
      "name": "order_update",
      "language": "en",
      "variable": "#1042"
    }
  }'

PHP (Guzzle) ​

php
<?php

use GuzzleHttp\Client;

$client = new Client();
$response = $client->post('https://api.genudo.ai/api/user/89328/messages', [
    'headers' => [
        'Authorization' => 'Bearer '.$token,
        'Accept'        => 'application/json',
    ],
    'json' => [
        'template' => [
            'id'       => '99918273645',
            'name'     => 'order_update',
            'language' => 'en',
            'variable' => '#1042',
        ],
    ],
]);

Node.js ​

js
const res = await fetch('https://api.genudo.ai/api/user/89328/messages', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${token}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    template: {
      id: '99918273645',
      name: 'order_update',
      language: 'en',
      variable: '#1042',
    },
  }),
})

Response shape with a template ​

The server fills the template body with template.variable as data.message (so the inbox and conversations.last_message_content display the rendered text) and stores the resolved template metadata on the message record:

json
{
  "status": true,
  "code": 200,
  "validation": [],
  "message": "Message Sent",
  "data": {
    "_id": "68e0f4a3c2b1a9f0d3e5a7b2",
    "role": "assistant",
    "status": "sent_to_user",
    "message": "Hello, your order #1042 is ready.",
    "template_name": "order_update",
    "template_language": "en",
    "template_components": [
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "#1042"
          }
        ]
      }
    ],
    "cost_for_user": 0,
    "external_chat_id": "201066278084",
    "conversation_id": 89328,
    "opportunity_id": 98314,
    "contact_id": 44016,
    "channel_id": 512,
    "stage_id": 189,
    "pipeline_id": 17,
    "call_type": "chat",
    "sender_id": 731,
    "is_manual": true,
    "created_at": "2026-11-09T10:22:41.000000Z",
    "updated_at": "2026-11-09T10:22:43.000000Z"
  }
}

Sending attachments ​

Attachments must be uploaded as multipart/form-data — one form field per file, repeating the files[] key. message becomes a regular form field alongside them (and stays optional as long as at least one file is present).

Accepted content: any file type, unless the channel restricts it (see Channel limits). The server infers a bucket from the MIME type — image/* → image, video/* → video, audio/* → audio, application/* → document, everything else → file. Uploaded files are stored on private S3 and served through signed URLs; you never need to host them yourself.

Channel limits ​

Some channels only accept certain file types. Files are checked before anything is stored or sent, so one unsupported file rejects the whole request with a 422 and nothing reaches the contact.

Instagram

Instagram typeAccepted formatsMax size
ImagePNG, JPEG8 MB
AudioAAC, M4A, WAV, MP425 MB
VideoMP4, OGG, AVI, MOV, WebM25 MB
DocumentPDF only25 MB

Anything else (GIF, WebP, Word, Excel, ZIP, OGG/WebM voice notes, …) is rejected. The text, if any, is sent as a separate Instagram message before the attachments.

TikTok

TypeAccepted formatsMax size
ImageJPG, PNG3 MB

TikTok Business Messaging can't send video, audio or documents — any other file is rejected. Replies are only possible inside a conversation the TikTok user started; when TikTok refuses a send (for example, the reply window has closed), the request fails and the message carries TikTok's reason.

curl ​

bash
curl -X POST "https://api.genudo.ai/api/user/89328/messages" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json" \
  -F "message=Here are the specs you asked for" \
  -F "files[]=@./pricing.pdf" \
  -F "files[]=@./product-shot.png"

PHP (Guzzle) ​

php
<?php

use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('POST', 'https://api.genudo.ai/api/user/89328/messages', [
    'headers' => [
        'Authorization' => 'Bearer '.$token,
        'Accept'        => 'application/json',
    ],
    'multipart' => [
        ['name' => 'message',  'contents' => 'Here are the specs you asked for'],
        ['name' => 'files[]',  'contents' => fopen('./pricing.pdf', 'r'),      'filename' => 'pricing.pdf'],
        ['name' => 'files[]',  'contents' => fopen('./product-shot.png', 'r'), 'filename' => 'product-shot.png'],
    ],
]);

Node.js ​

js
import fs from 'node:fs'

const form = new FormData()
form.append('message', 'Here are the specs you asked for')
form.append('files[]', new Blob([fs.readFileSync('./pricing.pdf')]),      'pricing.pdf')
form.append('files[]', new Blob([fs.readFileSync('./product-shot.png')]), 'product-shot.png')

const res = await fetch('https://api.genudo.ai/api/user/89328/messages', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${token}`,
    Accept: 'application/json',
    // Do NOT set Content-Type — fetch sets the multipart boundary for you.
  },
  body: form,
})

Response shape with attachments ​

Every uploaded file becomes an entry under data.files:

json
{
  "status": true,
  "code": 200,
  "message": "Message Sent",
  "data": {
    "_id": "68e0f4a3c2b1a9f0d3e5a7b2",
    "message": "Here are the specs you asked for",
    "status": "sent_to_user",
    "files": [
      {
        "path": "media/512/68e0f4a3c2b1a9f0d3e5a7b2.pdf",
        "full_path": "https://<private-bucket>.s3.amazonaws.com/media/512/68e0f4a3c2b1a9f0d3e5a7b2.pdf?X-Amz-Expires=600&X-Amz-Signature=…",
        "mimetype": "application/pdf",
        "type": "document",
        "size": 184320,
        "name": "pricing.pdf"
      },
      {
        "path": "media/512/68e0f4a3c2b1a9f0d3e5a7b2_1.png",
        "full_path": "https://<private-bucket>.s3.amazonaws.com/media/512/68e0f4a3c2b1a9f0d3e5a7b2_1.png?X-Amz-Expires=600&X-Amz-Signature=…",
        "mimetype": "image/png",
        "type": "image",
        "size": 42117,
        "name": "product-shot.png"
      }
    ]
  }
}

Response ​

The full persisted message record (Mongo document) is returned. Notable fields:

FieldTypeDescription
_idstringMongo message id
rolestringAlways assistant for messages sent through this endpoint
statusenumsent_to_user on success, failed if delivery through the channel raised (see error field), created_manually briefly during processing
messagestring | nullThe text you sent, or the rendered body preview when a WhatsApp template was sent
template_namestring | nullPresent when sent via a WhatsApp Cloud template — the approved template name
template_languagestring | nullPresent when sent via a WhatsApp Cloud template — the template language code
template_componentsobject[] | nullPresent when sent via a WhatsApp Cloud template — the resolved Meta template components payload
filesobject[]Uploaded attachments — path (private S3 key), full_path (signed download URL, valid for 10 minutes), mimetype, type (image / video / audio / document / file), size, name
external_chat_idstringThe thread id on the origin channel (Meta thread id, WhatsApp phone, etc.)
conversation_id, opportunity_id, contact_id, channel_id, stage_id, pipeline_idintegerRelational context resolved from the conversation
sender_idintegerThe authenticated user id (or the acted-as user when using super-user impersonation)

Side effects ​

  • conversations.last_message_at and conversations.last_message_content are updated (uses the rendered template body for template sends, or falls back to [Attachment] when only files are sent).
  • A new_message event is fired on the conversation.{id} socket channel — subscribed socket clients receive the new message in real time.
  • Delivery to the underlying provider is synchronous — the request only returns after the message has been handed off to the channel provider.

Errors ​

CodeWhen
403Token missing messages:send scope, or the conversation belongs to a different workspace
404Conversation not found
422Neither message, files, nor template provided, files combined with template, message over 10k chars, a file over 25 MB, or more than 10 files
422The conversation is not linked to an active channel
422template sent on a non-Meta WhatsApp Cloud channel (WhatsApp templates can only be sent on WhatsApp Cloud channels)
422The selected template is not an APPROVED template on the channel for the given id, name, and language, or does not have exactly one text variable and no media header
422A file the channel doesn't accept — e.g. a .docx or a 10 MB image on Instagram, or any non-image file on TikTok. The error is keyed by files.{index} and names the file and the accepted formats
400The channel provider rejected the message — the persisted record's status becomes failed and its error field contains the provider error. For Instagram, the message contains Instagram's own reason (e.g. the messaging window has closed)