Skip to main content

channels.createChannel

Create a supergroup/channel.

func (c *Client) ChannelsCreateChannel(ctx context.Context, request *ChannelsCreateChannelRequest) (UpdatesClass, error)

Calling this method

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

res, err := api.ChannelsCreateChannel(ctx, &tg.ChannelsCreateChannelRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // UpdatesClass
return nil
})

Parameters

NameTypeRequiredDescription
BroadcastboolWhether to create a channel
MegagroupboolWhether to create a supergroup
ForImportboolWhether the supergroup is being created to import messages from a foreign chat service using messages.initHistoryImport
ForumboolWhether to create a forum
TitlestringyesChannel title
AboutstringyesChannel description
GeoPointInputGeoPointClassGeogroup location, see here » for more info on geogroups.
AddressstringGeogroup address, see here » for more info on geogroups.
TTLPeriodintTime-to-live of all messages that will be sent in the supergroup: 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

UpdatesClass

Possible errors

CodeTypeDescription
400ADDRESS_INVALIDThe specified geopoint address is invalid.
400CHANNELS_ADMIN_LOCATED_TOO_MUCHThe user has reached the limit of public geogroups.
400CHANNELS_TOO_MUCHYou have joined too many channels/supergroups.
400CHAT_ABOUT_TOO_LONGChat about too long.
500CHAT_INVALIDInvalid chat.
400CHAT_TITLE_EMPTYNo chat title provided.
400TTL_PERIOD_INVALIDThe specified TTL period is invalid.
406USER_RESTRICTEDYou're spamreported, you can't create channels or chats.

References