Skip to content
Download Beeper

Create or start a chat

$client->chats->create(string accountID, ?bool allowInvite, ?string messageText, ?Mode mode, ?list<string> participantIDs, ?string title, ?Type type, ?User user): ChatNewResponse
POST/v1/chats

Create a single/group chat (mode='create') or start a direct chat from merged user data (mode='start').

ParametersExpand Collapse
accountID: string

Account to create or start the chat on.

allowInvite?:optional bool

Whether invite-based DM creation is allowed when required by the platform. Used for mode='start'.

messageText?:optional string

Optional first message content if the platform requires it to create the chat.

mode?:optional Mode

Operation mode. Defaults to 'create' when omitted.

participantIDs?:optional list<string>

Required when mode='create'. User IDs to include in the new chat.

title?:optional string

Optional title for group chats when mode='create'; ignored for single chats on most platforms.

type?:optional Type

Required when mode='create'. 'single' requires exactly one participantID; 'group' supports multiple participants and optional title.

user?:optional User

Required when mode='start'. Merged user-like contact payload used to resolve the best identifier.

ReturnsExpand Collapse
string chatID

Newly created chat ID.

?Status status

Only returned in start mode. 'existing' means an existing chat was reused; 'created' means a new chat was created.

Create or start a chat

<?php

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

$client = new Client();

$chat = $client->chats->create(
  accountID: 'accountID',
  allowInvite: true,
  messageText: 'messageText',
  mode: 'create',
  participantIDs: ['string'],
  title: 'title',
  type: 'single',
  user: [
    'id' => 'id',
    'email' => 'email',
    'fullName' => 'fullName',
    'phoneNumber' => 'phoneNumber',
    'username' => 'username',
  ],
);

var_dump($chat);
{
  "chatID": "!NCdzlIaMjZUmvmvyHU:beeper.com",
  "status": "existing"
}
Returns Examples
{
  "chatID": "!NCdzlIaMjZUmvmvyHU:beeper.com",
  "status": "existing"
}