Skip to content
Download Beeper

Send a message

$client->messages->send(string chatID, ?Attachment attachment, ?string replyToMessageID, ?string text): MessageSendResponse
POST/v1/chats/{chatID}/messages

Send a text message to a specific chat. Supports replying to existing messages. Returns a pending message ID.

ParametersExpand Collapse
chatID: string

Chat ID. Input routes also accept the local chat ID from this installation when available.

attachment?:optional Attachment

Single attachment to send with the message

replyToMessageID?:optional string

Provide a message ID to send this as a reply to an existing message

text?:optional string

Draft text. Plain text and Markdown are converted to Beeper rich text with the same rules used by send and edit.

ReturnsExpand Collapse
string chatID

Chat ID. Input routes also accept the local chat ID from this installation when available.

string pendingMessageID

Pending ID assigned to the message before the network confirms the send. Pass it to GET /v1/chats/{chatID}/messages/{messageID} to resolve, or wait for the matching message.upserted over the WebSocket.

Send a message

<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(accessToken: 'My Access Token');

$response = $client->messages->send(
  '!NCdzlIaMjZUmvmvyHU:beeper.com',
  attachment: [
    'uploadID' => 'uploadID',
    'duration' => 0,
    'fileName' => 'fileName',
    'mimeType' => 'mimeType',
    'size' => ['height' => 0, 'width' => 0],
    'type' => 'image',
  ],
  replyToMessageID: 'replyToMessageID',
  text: 'text',
);

var_dump($response);
{
  "chatID": "!whatsapp_15550101002:ba_EvYDBBsZbRQAy3UOSWqG0LuTVkc.local-whatsapp.localhost",
  "pendingMessageID": "m1694783291234567"
}
Returns Examples
{
  "chatID": "!whatsapp_15550101002:ba_EvYDBBsZbRQAy3UOSWqG0LuTVkc.local-whatsapp.localhost",
  "pendingMessageID": "m1694783291234567"
}