Skip to main content

messages.createChat

Creates a new chat.

func (c *Client) MessagesCreateChat(ctx context.Context, request *MessagesCreateChatRequest) (*MessagesInvitedUsers, error)

Calling this method

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.MessagesCreateChat(ctx, &tg.MessagesCreateChatRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // *MessagesInvitedUsers
return nil
})

Parameters

NameTypeRequiredDescription
Users[]InputUserClassyesList of user IDs to be invited
TitlestringyesChat name
TTLPeriodintTime-to-live of all messages that will be sent in the chat: once message.date+message ttl_period === time(), the message will be deleted on the server, and must be deleted locally as well. You can use messages.setDefaultHistoryTTL to edit this value later.

Returns

*MessagesInvitedUsers

Possible errors

CodeTypeDescription
500CHAT_ID_GENERATE_FAILEDFailure while generating the chat ID.
400CHAT_INVALIDInvalid chat.
400CHAT_MEMBER_ADD_FAILEDCould not add participants.
400CHAT_TITLE_EMPTYNo chat title provided.
400INPUT_USER_DEACTIVATEDThe specified user was deleted.
400TTL_PERIOD_INVALIDThe specified TTL period is invalid.
400USERS_TOO_FEWNot enough users (to create a chat, for example).
406USER_RESTRICTEDYou're spamreported, you can't create channels or chats.

References