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
forImportflags.3?trueWhether the supergroup is being created to import messages from a foreign chat service using messages.initHistoryImport
titlestringChannel title
aboutstringChannel description
geoPointflags.2?InputGeoPointGeogroup location
addressflags.2?stringGeogroup address

Result

Updates

Possible errors

CodeTypeDescription
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.
400CHAT_TITLE_EMPTYNo chat title provided.
406USER_RESTRICTEDYou're spamreported, you can't create channels or chats.

Can bots use this method?

No

Channels, supergroups, gigagroups and basic groups

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

messages.initHistoryImport

Import chat history from a foreign chat app into a specific Telegram chat, click here for more info about imported chats ยป.