Skip to content
Download Beeper

Create or start a chat

client.Chats.New(ctx, body) (*ChatNewResponse, error)
POST/v1/chats

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

ParametersExpand Collapse
body ChatNewParams
AccountID param.Field[string]

Account to create or start the chat on.

AllowInvite param.Field[bool]optional

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

MessageText param.Field[string]optional

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

Mode param.Field[ChatNewParamsMode]optional

Operation mode. Defaults to 'create' when omitted.

const ChatNewParamsModeCreate ChatNewParamsMode = "create"
const ChatNewParamsModeStart ChatNewParamsMode = "start"
ParticipantIDs param.Field[[]string]optional

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

Title param.Field[string]optional

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

Type param.Field[ChatNewParamsType]optional

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

const ChatNewParamsTypeSingle ChatNewParamsType = "single"
const ChatNewParamsTypeGroup ChatNewParamsType = "group"
User param.Field[ChatNewParamsUser]optional

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

ID stringoptional

Known user ID when available.

Email stringoptional

Email candidate.

FullName stringoptional

Display name hint used for ranking only.

PhoneNumber stringoptional

Phone number candidate (E.164 preferred).

Username stringoptional

Username/handle candidate.

ReturnsExpand Collapse
type ChatNewResponse struct{…}
ChatID string

Newly created chat ID.

Status ChatNewResponseStatusoptional

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

Accepts one of the following:
const ChatNewResponseStatusExisting ChatNewResponseStatus = "existing"
const ChatNewResponseStatusCreated ChatNewResponseStatus = "created"

Create or start a chat

package main

import (
  "context"
  "fmt"

  "github.com/beeper/desktop-api-go"
)

func main() {
  client := beeperdesktopapi.NewClient(

  )
  chat, err := client.Chats.New(context.TODO(), beeperdesktopapi.ChatNewParams{
    AccountID: "accountID",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chat.ChatID)
}
{
  "chatID": "!NCdzlIaMjZUmvmvyHU:beeper.com",
  "status": "existing"
}
Returns Examples
{
  "chatID": "!NCdzlIaMjZUmvmvyHU:beeper.com",
  "status": "existing"
}