> ## 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.

# Connect TikTok ad accounts

> Subscribes Flextell to each ad account's Instant Form leads and reads its forms (each gets an
integration connection with the default mapping). Reconnecting an ad account renews its token and
switches back on the forms the disconnect switched off.



## OpenAPI

````yaml /api-referansi/openapi.json post /v1/tiktok-lead-ads/advertisers
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/tiktok-lead-ads/advertisers:
    post:
      tags:
        - TikTokLeadAds
      summary: Connect TikTok ad accounts
      description: >-
        Subscribes Flextell to each ad account's Instant Form leads and reads
        its forms (each gets an

        integration connection with the default mapping). Reconnecting an ad
        account renews its token and

        switches back on the forms the disconnect switched off.
      operationId: tiktok-lead-ads.advertisers.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/TikTokLeadAdvertiserStoreRequest'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/TikTokLeadAdvertiserResource'
                required:
                  - success
                  - data
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '422':
          $ref: '#/components/responses/ValidationException'
        '428':
          description: >-
            Mandatory setup is incomplete. Finish the setup wizard first;
            `data.next_step` names the step to continue with.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    examples:
                      - false
                  error_code:
                    type: string
                    enum:
                      - SETUP_REQUIRED
                    examples:
                      - SETUP_REQUIRED
                  message:
                    type: string
                    examples:
                      - Complete the required setup steps to continue.
                  data:
                    type: object
                    properties:
                      next_step:
                        type:
                          - string
                          - 'null'
                        examples:
                          - clinic_info
                    required:
                      - next_step
                required:
                  - success
                  - error_code
                  - message
                  - data
components:
  schemas:
    TikTokLeadAdvertiserStoreRequest:
      type: object
      properties:
        session_id:
          type: string
          format: uuid
          description: >-
            The `session_id` the session endpoint returned; it expires 15
            minutes after the authorization.
        advertiser_ids:
          type: array
          description: >-
            The ad accounts to connect, by TikTok advertiser id, picked from the
            session's `advertisers`.
          items:
            type: string
            description: A TikTok advertiser id.
            pattern: ^\d{1,32}$
          minItems: 1
          maxItems: 50
      required:
        - session_id
        - advertiser_ids
      title: TikTokLeadAdvertiserStoreRequest
    TikTokLeadAdvertiserResource:
      type: object
      properties:
        id:
          type: integer
        advertiser_id:
          type: string
          description: The TikTok ad account (advertiser) id.
        name:
          type: string
        status:
          type: string
          description: >-
            `connected`, or `needs_reconnect` when TikTok stopped accepting the
            ad account's token or delivering its leads.
        error_message:
          type:
            - string
            - 'null'
          description: >-
            Why the ad account needs reconnecting, localized; `null` while
            connected.
        auto_enable_new_forms:
          type: boolean
          description: >-
            Whether forms Flextell sees for the first time are switched on right
            away.
        settings:
          type: object
          description: >-
            The lead settings new forms start with, keyed as listed by the
            integration-entities endpoint.
          additionalProperties: {}
        connected_by:
          type:
            - object
            - 'null'
          properties:
            id:
              type: integer
            name:
              type: string
          required:
            - id
            - name
        forms_count:
          type: integer
        enabled_forms_count:
          type: integer
          description: Forms whose leads are being written to Flextell.
        subscribed_at:
          type:
            - string
            - 'null'
          format: date-time
        connected_at:
          type:
            - string
            - 'null'
          format: date-time
        last_lead_at:
          type:
            - string
            - 'null'
          format: date-time
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - advertiser_id
        - name
        - status
        - error_message
        - auto_enable_new_forms
        - settings
        - connected_by
        - forms_count
        - enabled_forms_count
        - subscribed_at
        - connected_at
        - last_lead_at
        - created_at
        - updated_at
      title: TikTokLeadAdvertiserResource
  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
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://app.flextell.ai/oauth/authorize
          tokenUrl: https://app.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.