> ## Documentation Index
> Fetch the complete documentation index at: https://api.onlysocial.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect a Telegram bot

> Connects a bot from its BotFather token. `201` for a new channel, `200` for the same bot again. A `422` on `takeover` means the bot's webhook points elsewhere: resend with `takeover: true` only if your customer confirms.



## OpenAPI

````yaml /api-reference/partner.openapi.json post /partner/workspaces/{workspace}/channels/telegram
openapi: 3.1.0
info:
  title: Partner API
  version: 1.0.0
  description: >-
    Provision your customers, sign them in with single sign-on, issue their
    workspace API keys and connect their messaging channels. Authenticated by
    your partner key as `X-API-KEY`, from your backend only.
servers:
  - url: https://app.onlysocial.io/api
    description: OnlySocial
security:
  - partnerKey: []
tags:
  - name: Customers
    description: Create or refresh a customer's account and workspace.
  - name: Single sign-on
    description: Swap a token signed with your SSO secret for a one-time sign-in link.
  - name: Workspace API keys
    description: Issue, list and revoke the `osk_` keys of a workspace you provisioned.
  - name: Channel Connect
    description: Hosted links that connect a customer's own messaging channels.
paths:
  /partner/workspaces/{workspace}/channels/telegram:
    parameters:
      - $ref: '#/components/parameters/Workspace'
    post:
      tags:
        - Channel Connect
      summary: Connect a Telegram bot
      description: >-
        Connects a bot from its BotFather token. `201` for a new channel, `200`
        for the same bot again. A `422` on `takeover` means the bot's webhook
        points elsewhere: resend with `takeover: true` only if your customer
        confirms.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - bot_token
              properties:
                bot_token:
                  type: string
                  minLength: 20
                  maxLength: 120
                  example: 123456:ABC…
                name:
                  type: string
                  maxLength: 120
                  example: Acme Motors
                takeover:
                  type: boolean
                  description: >-
                    Move the bot's webhook here even though it points somewhere
                    else.
      responses:
        '200':
          description: Already connected; refreshed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelegramEnvelope'
        '201':
          description: Connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelegramEnvelope'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationFailed'
components:
  parameters:
    Workspace:
      name: workspace
      in: path
      required: true
      description: >-
        A workspace uuid from provisioning. It must be administered by a
        customer you provisioned.
      schema:
        type: string
        format: uuid
  schemas:
    TelegramEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/Channel'
        meta:
          type: object
          properties:
            webhook_registered:
              type: boolean
            webhook_taken_over:
              type: boolean
    Channel:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          example: Acme Motors
        platform:
          type: string
          example: telegram
        handle:
          type:
            - string
            - 'null'
          example: acmemotors_bot
        status:
          type: string
          example: connected
        connected:
          type: boolean
          example: true
        created_at:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
        error_code:
          type: string
  responses:
    Unauthenticated:
      description: Missing or invalid partner key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            message: Invalid or inactive API key.
    NotFound:
      description: >-
        Not found, or not yours. Another partner's workspace and a uuid that
        does not exist look the same.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ValidationFailed:
      description: A field failed validation.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
                example: Validation failed.
              errors:
                type: object
                additionalProperties:
                  type: array
                  items:
                    type: string
  securitySchemes:
    partnerKey:
      type: apiKey
      in: header
      name: X-API-KEY
      description: Your partner API key, `pk_…`. Backend only.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.