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

# Connect or replace the tenant's Telegram bot

> Upserts the Telegram connection. The bot token is encrypted at rest and masked in the response. Re-calling this endpoint replaces the stored credentials and marks the connection active.



## OpenAPI

````yaml /api-reference/ai-cms/openapi-TAGTEST.json put /ai/social/telegram/connect
openapi: 3.1.0
info:
  title: Blog API
  version: 1.0.0
servers:
  - url: https://api.octaviatech.app/cms
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Tags
    description: Tag management endpoints
paths:
  /ai/social/telegram/connect:
    put:
      tags:
        - AI Automation
      summary: Connect or replace the tenant's Telegram bot
      description: >-
        Upserts the Telegram connection. The bot token is encrypted at rest and
        masked in the response. Re-calling this endpoint replaces the stored
        credentials and marks the connection active.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - botToken
                - chatId
              properties:
                botToken:
                  type: string
                  minLength: 20
                  description: Telegram bot token
                chatId:
                  type: string
                  minLength: 2
                  description: Target chat id the bot posts to
                  example: '-1001234567890'
            examples:
              Basic:
                value:
                  botToken: 123456789:AAF-abcdefghijklmnopqrstuvwxyz012345
                  chatId: '-1001234567890'
      responses:
        '200':
          description: OK (connected)
          content:
            application/json:
              example:
                success: true
                statusCode: 200
                message: Telegram connected
                data:
                  tenantId: '{{objectId}}'
                  provider: telegram
                  isActive: true
                  config:
                    botToken: 1234...6789
                    chatId: '-1001234567890'
                  updatedBy: '{{objectId}}'
                  updatedAt: '2025-10-01T12:00:00.000Z'
              schema:
                allOf:
                  - $ref: '#/components/schemas/Envelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/SocialConnection'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden (role not allowed)
        '406':
          description: Validation failed
        '500':
          description: Failed to store the connection
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Envelope:
      type: object
      properties:
        success:
          type: boolean
        statusCode:
          type: integer
        message:
          type: string
        data:
          type:
            - object
            - 'null'
      required:
        - success
        - statusCode
        - message
        - data
    SocialConnection:
      type: object
      properties:
        tenantId:
          type: string
        provider:
          type: string
          enum:
            - linkedin
            - twitter
            - telegram
        isActive:
          type: boolean
        config:
          type: object
          additionalProperties:
            type: string
        updatedBy:
          oneOf:
            - $ref: '#/components/schemas/ObjectId'
            - type: 'null'
        updatedAt:
          $ref: '#/components/schemas/DateTime'
    ObjectId:
      type: string
      pattern: ^[a-fA-F0-9]{24}$
    DateTime:
      type: string
      format: date-time
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````