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

# Create a channel

> A Telegram channel sent with `bot_token` is connected before it is saved: Telegram must accept
the token (`CHANNEL_TELEGRAM_TOKEN_INVALID`) and the webhook (`CHANNEL_TELEGRAM_WEBHOOK_REJECTED`),
otherwise nothing is created.



## OpenAPI

````yaml /api-referansi/openapi.json post /v1/channels
openapi: 3.1.0
info:
  title: Flextell API
  version: 0.0.1
  description: >-
    Flextell REST API referansı. Kimlik doğrulama, scope ve istek kuralları için
    API sekmesindeki rehberlere bakın.
servers:
  - url: https://app.flextell.ai/api
    description: Üretim
security:
  - oauth2: []
  - bearer: []
paths:
  /v1/channels:
    post:
      tags:
        - Channel
      summary: Create a channel
      description: >-
        A Telegram channel sent with `bot_token` is connected before it is
        saved: Telegram must accept

        the token (`CHANNEL_TELEGRAM_TOKEN_INVALID`) and the webhook
        (`CHANNEL_TELEGRAM_WEBHOOK_REJECTED`),

        otherwise nothing is created.
      operationId: channel.store
      parameters:
        - name: X-Tenant
          in: header
          required: true
          description: >-
            Tenant identifier. Send the Tenant ID in the `X-Tenant` header to
            scope API requests to a specific tenant.
          schema:
            type: number
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChannelStoreRequest'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                  data:
                    $ref: '#/components/schemas/ChannelResource'
                required:
                  - success
                  - data
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '422':
          $ref: '#/components/responses/ValidationException'
        '502':
          $ref: '#/components/responses/ChannelProviderUnavailableException'
components:
  schemas:
    ChannelStoreRequest:
      type: object
      properties:
        name:
          type: string
          description: The name of the channel.
          maxLength: 255
        type:
          $ref: '#/components/schemas/ChannelType'
          description: The channel type (whatsapp, instagram, website, telegram).
        provider:
          type:
            - string
            - 'null'
          description: >-
            The messaging provider backing the channel, when the type supports
            more than one.
          maxLength: 255
        address:
          type:
            - string
            - 'null'
          description: >-
            The channel address — a phone number, handle or bot identifier.
            Required for every type except website, and for a Telegram channel
            created without a bot token; a connected Telegram channel defaults
            to `@<bot username>`.
          maxLength: 255
        website_domain:
          type:
            - string
            - 'null'
          description: >-
            The site the widget is embedded on, without a scheme. Required for
            website channels.
          pattern: >-
            ^(?:localhost|(?:\d{1,3}\.){3}\d{1,3}|(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+))(?:\:\d{1,5})?$
          maxLength: 255
        integration_id:
          type:
            - integer
            - 'null'
          description: The integration this channel belongs to.
        is_active:
          type:
            - boolean
            - 'null'
          description: Whether the channel is active.
        ai_reply_mode:
          anyOf:
            - $ref: '#/components/schemas/AiReplyMode'
              description: >-
                Pins the channel to a fixed AI reply mode (auto, semi_auto,
                closed). Omit to follow the clinic schedule.
            - type: 'null'
        bot_token:
          type:
            - string
            - 'null'
          description: >-
            Telegram only. The BotFather token of the bot to connect. When
            given, the bot is verified and its webhook registered before the
            channel is saved, and the channel starts `open`; when omitted, only
            the channel record is created. Write-only: it is stored encrypted
            and never returned.
          pattern: ^\d+:[A-Za-z0-9_-]+$
          maxLength: 255
        webhook_enabled:
          type:
            - boolean
            - 'null'
          description: >-
            Telegram only. Whether Telegram delivers incoming messages to the
            channel's webhook. Defaults to true.
        webhook_base_url:
          type:
            - string
            - 'null'
          format: uri
          description: >-
            Telegram only, non-production only. The public HTTPS base URL (for
            example a tunnel) the webhook is registered under. Ignored in
            production, which always uses the application URL.
          maxLength: 255
      required:
        - name
        - type
      title: ChannelStoreRequest
    ChannelResource:
      type: object
      properties:
        id:
          type: integer
        tenant_id:
          type: integer
        name:
          type: string
        type:
          $ref: '#/components/schemas/ChannelType'
        provider:
          type:
            - string
            - 'null'
        address:
          type: string
        website_domain:
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/ChannelStatus'
        is_active:
          type: boolean
        ai_reply_mode:
          anyOf:
            - $ref: '#/components/schemas/AiReplyMode'
            - type: 'null'
        connection_error:
          type:
            - object
            - 'null'
          properties:
            code:
              type: string
            expected_address:
              type: string
            connected_address:
              type: string
            message:
              type: string
            detected_at:
              type: string
              format: date-time
          required:
            - code
            - expected_address
            - connected_address
            - message
            - detected_at
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - tenant_id
        - name
        - type
        - provider
        - address
        - website_domain
        - status
        - is_active
        - ai_reply_mode
        - connection_error
        - created_at
        - updated_at
      title: ChannelResource
    ChannelType:
      type: string
      enum:
        - whatsapp
        - instagram
        - website
        - telegram
      title: ChannelType
    AiReplyMode:
      type: string
      enum:
        - auto
        - semi_auto
        - closed
      title: AiReplyMode
    ChannelStatus:
      type: string
      enum:
        - closed
        - waiting
        - open
      title: ChannelStatus
  responses:
    AuthenticationException:
      description: Unauthenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    AuthorizationException:
      description: Authorization error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
    ChannelProviderUnavailableException:
      description: >-
        The messaging provider behind the channel could not be reached; the
        request may be retried
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                description: Always false for an error.
                examples:
                  - false
              error_code:
                type: string
                description: Machine-readable error code.
                examples:
                  - CHANNEL_PROVIDER_UNAVAILABLE
              message:
                type: string
                description: Localized error message.
            required:
              - success
              - error_code
              - message
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://dev.flextell.ai/oauth/authorize
          tokenUrl: https://dev.flextell.ai/oauth/token
          scopes:
            '*': all
    bearer:
      type: http
      scheme: bearer

````

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