GramJS

channels.CreateChannel

Create a supergroup/channel.

Example

const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result = await client.invoke(
    new Api.channels.CreateChannel({
      title: "My very normal title",
      about: "some string here",
      megagroup: true,
      forImport: true,
      geoPoint: new Api.InputGeoPoint({
        lat: 8.24,
        long: 8.24,
        accuracyRadius: 43,
      }),
      address: "some string here",
    })
  );
  console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result: Api.Updates = await client.invoke(
    new Api.channels.CreateChannel({
      title: "My very normal title",
      about: "some string here",
      megagroup: true,
      forImport: true,
      geoPoint: new Api.InputGeoPoint({
        lat: 8.24,
        long: 8.24,
        accuracyRadius: 43,
      }),
      address: "some string here",
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
broadcastflags.0?trueWhether to create a channel
megagroupflags.1?trueWhether to create a supergroup
titlestringChannel title
aboutstringChannel description
geoPointflags.2?InputGeoPointGeogroup location
addressflags.2?stringGeogroup address

Result

Updates

Possible errors

CodeTypeDescription
400CHANNELS_TOO_MUCHYou have joined too many channels/supergroups
400CHAT_ABOUT_TOO_LONGChat about too long
400CHAT_TITLE_EMPTYNo chat title provided
403USER_RESTRICTEDYou're spamreported, you can't create channels or chats.

Can bots use this method?

No

Channels

How to handle channels, supergroups, groups, and what's the difference between them.