Telegram Chat Management API

Methods for managing chats and chat settings

OpenAPI Specification

telegram-chat-management-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Telegram Bot Bot Info Chat Management API
  description: The Telegram Bot API is an HTTP-based interface created for developers keen on building bots for Telegram. Bots can receive messages, send messages, manage chats, handle payments, work with stickers, and much more. All methods are HTTPS POST requests to https://api.telegram.org/bot<token>/METHOD_NAME.
  version: '9.5'
  contact:
    name: Telegram Support
    url: https://core.telegram.org/bots/api
  license:
    name: Terms of Service
    url: https://telegram.org/tos
  termsOfService: https://telegram.org/tos
servers:
- url: https://api.telegram.org/bot{token}
  description: Telegram Bot API Server
  variables:
    token:
      default: YOUR_BOT_TOKEN
      description: Bot authentication token obtained from @BotFather
security:
- BotToken: []
tags:
- name: Chat Management
  description: Methods for managing chats and chat settings
paths:
  /getChat:
    post:
      operationId: getChat
      summary: Get Chat
      description: Get up-to-date information about the chat.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
      responses:
        '200':
          description: Chat object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponse'
  /getChatAdministrators:
    post:
      operationId: getChatAdministrators
      summary: Get Chat Administrators
      description: Get a list of administrators in a chat.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
      responses:
        '200':
          description: Array of ChatMember objects
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatMembersResponse'
  /getChatMemberCount:
    post:
      operationId: getChatMemberCount
      summary: Get Chat Member Count
      description: Get the number of members in a chat.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
      responses:
        '200':
          description: Number of chat members
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IntegerResponse'
  /getChatMember:
    post:
      operationId: getChatMember
      summary: Get Chat Member
      description: Get information about a member of a chat.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              - user_id
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
                user_id:
                  type: integer
                  description: Unique identifier of the target user
      responses:
        '200':
          description: ChatMember object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatMemberResponse'
  /leaveChat:
    post:
      operationId: leaveChat
      summary: Leave Chat
      description: Use this method for your bot to leave a group, supergroup or channel.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
      responses:
        '200':
          description: Bot left the chat
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BooleanResponse'
  /setChatPhoto:
    post:
      operationId: setChatPhoto
      summary: Set Chat Photo
      description: Set a new profile photo for the chat.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
              - chat_id
              - photo
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
                photo:
                  type: string
                  format: binary
                  description: New chat photo as InputFile
      responses:
        '200':
          description: Chat photo set
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BooleanResponse'
  /deleteChatPhoto:
    post:
      operationId: deleteChatPhoto
      summary: Delete Chat Photo
      description: Delete a chat photo.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
      responses:
        '200':
          description: Chat photo deleted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BooleanResponse'
  /setChatTitle:
    post:
      operationId: setChatTitle
      summary: Set Chat Title
      description: Change the title of a chat.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              - title
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
                title:
                  type: string
                  description: New chat title (1-255 characters)
      responses:
        '200':
          description: Chat title updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BooleanResponse'
  /setChatDescription:
    post:
      operationId: setChatDescription
      summary: Set Chat Description
      description: Change the description of a group, a supergroup or a channel.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
                description:
                  type: string
                  description: New chat description (0-255 characters)
      responses:
        '200':
          description: Chat description updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BooleanResponse'
  /pinChatMessage:
    post:
      operationId: pinChatMessage
      summary: Pin Chat Message
      description: Add a message to the list of pinned messages in a chat.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              - message_id
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
                message_id:
                  type: integer
                  description: Identifier of a message to pin
                disable_notification:
                  type: boolean
                  description: Pass true to notify all chat members silently
      responses:
        '200':
          description: Message pinned successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BooleanResponse'
  /unpinChatMessage:
    post:
      operationId: unpinChatMessage
      summary: Unpin Chat Message
      description: Remove a message from the list of pinned messages in a chat.
      tags:
      - Chat Management
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - chat_id
              properties:
                chat_id:
                  oneOf:
                  - type: integer
                  - type: string
                  description: Unique identifier for the target chat
                message_id:
                  type: integer
                  description: Identifier of a message to unpin
      responses:
        '200':
          description: Message unpinned successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BooleanResponse'
components:
  schemas:
    ChatMember:
      type: object
      properties:
        status:
          type: string
          enum:
          - creator
          - administrator
          - member
          - restricted
          - left
          - kicked
          description: The member's status in the chat
        user:
          $ref: '#/components/schemas/User'
      required:
      - status
      - user
    User:
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for this user or bot
        is_bot:
          type: boolean
          description: True if this user is a bot
        first_name:
          type: string
          description: User's or bot's first name
        last_name:
          type: string
          description: User's or bot's last name
        username:
          type: string
          description: User's or bot's username
        language_code:
          type: string
          description: IETF language tag of the user's language
        is_premium:
          type: boolean
          description: True if this user is a Telegram Premium user
      required:
      - id
      - is_bot
      - first_name
    ChatResponse:
      type: object
      properties:
        ok:
          type: boolean
        result:
          $ref: '#/components/schemas/Chat'
    IntegerResponse:
      type: object
      properties:
        ok:
          type: boolean
        result:
          type: integer
    ChatMembersResponse:
      type: object
      properties:
        ok:
          type: boolean
        result:
          type: array
          items:
            $ref: '#/components/schemas/ChatMember'
    Chat:
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for this chat
        type:
          type: string
          enum:
          - private
          - group
          - supergroup
          - channel
          description: Type of chat
        title:
          type: string
          description: Title for supergroups, channels and group chats
        username:
          type: string
          description: Username for private chats, supergroups and channels
        first_name:
          type: string
          description: First name of the other party in a private chat
        last_name:
          type: string
          description: Last name of the other party in a private chat
        description:
          type: string
          description: Description for groups, supergroups and channel chats
        invite_link:
          type: string
          description: Primary invite link for the chat
        member_count:
          type: integer
          description: Number of members in a chat
      required:
      - id
      - type
    BooleanResponse:
      type: object
      properties:
        ok:
          type: boolean
        result:
          type: boolean
    ChatMemberResponse:
      type: object
      properties:
        ok:
          type: boolean
        result:
          $ref: '#/components/schemas/ChatMember'
  securitySchemes:
    BotToken:
      type: apiKey
      in: path
      name: token
      description: Bot authentication token obtained from @BotFather (embedded in URL path)
externalDocs:
  description: Official Telegram Bot API Documentation
  url: https://core.telegram.org/bots/api