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
| Name | Type | Required | Description |
|---|---|---|---|
Broadcast | bool | — | Whether to create a channel |
Megagroup | bool | — | Whether to create a supergroup |
ForImport | bool | — | Whether the supergroup is being created to import messages from a foreign chat service using messages.initHistoryImport |
Forum | bool | — | Whether to create a forum |
Title | string | yes | Channel title |
About | string | yes | Channel description |
GeoPoint | InputGeoPointClass | — | Geogroup location, see here » for more info on geogroups. |
Address | string | — | Geogroup address, see here » for more info on geogroups. |
TTLPeriod | int | — | Time-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
Possible errors
| Code | Type | Description |
|---|---|---|
| 400 | ADDRESS_INVALID | The specified geopoint address is invalid. |
| 400 | CHANNELS_ADMIN_LOCATED_TOO_MUCH | The user has reached the limit of public geogroups. |
| 400 | CHANNELS_TOO_MUCH | You have joined too many channels/supergroups. |
| 400 | CHAT_ABOUT_TOO_LONG | Chat about too long. |
| 500 | CHAT_INVALID | Invalid chat. |
| 400 | CHAT_TITLE_EMPTY | No chat title provided. |
| 400 | TTL_PERIOD_INVALID | The specified TTL period is invalid. |
| 406 | USER_RESTRICTED | You're spamreported, you can't create channels or chats. |
References
- Official documentation
- Generated Go reference
- TL definition:
channels.createChannel#91006707