Skip to content
  • Auto
  • Light
  • Dark
Download Beeper

Create

Create a chat
client.Chats.New(ctx, body) (*ChatNewResponse, error)
post/v1/chats

Create a single or group chat on a specific account using participant IDs and optional title.

ParametersExpand Collapse
body ChatNewParams
AccountID param.Field[string]

Account to create the chat on.

ParticipantIDs param.Field[[]string]

User IDs to include in the new chat.

Type param.Field[ChatNewParamsType]

Chat type to create: 'single' requires exactly one participantID; 'group' supports multiple participants and optional title.

const ChatNewParamsTypeSingle ChatNewParamsType = "single"
const ChatNewParamsTypeGroup ChatNewParamsType = "group"
MessageText param.Field[string]optional

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

Title param.Field[string]optional

Optional title for group chats; ignored for single chats on most platforms.

ReturnsExpand Collapse
type ChatNewResponse struct{…}
ChatID stringoptional

Newly created chat if available.

Create a chat
package main

import (
  "context"
  "fmt"

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

func main() {
  client := beeperdesktopapi.NewClient(
    option.WithAccessToken("My Access Token"),
  )
  chat, err := client.Chats.New(context.TODO(), beeperdesktopapi.ChatNewParams{
    AccountID: "local-whatsapp_ba_EvYDBBsZbRQAy3UOSWqG0LuTVkc",
    ParticipantIDs: []string{"string"},
    Type: beeperdesktopapi.ChatNewParamsTypeSingle,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chat)
}
{
  "success": true,
  "error": "error",
  "chatID": "!NCdzlIaMjZUmvmvyHU:beeper.com"
}
Returns Examples
{
  "success": true,
  "error": "error",
  "chatID": "!NCdzlIaMjZUmvmvyHU:beeper.com"
}