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

# Create a connection

> Starts a 30-minute session and returns `connect_url`. Open it as a top-level navigation in your customer's browser, never in an iframe or a fetch. `account_id` or `channel_id` makes it a reconnect. For `telegram` send `bot_token` instead of `return_url`: the bot is connected in this call and the connection comes back `connected`, with `meta.webhook_registered` and `meta.webhook_taken_over` (`201` for a new bot, `200` for the same bot again). See [Client Connect API](/partner/client-connect).



## OpenAPI

````yaml /api-reference/partner.openapi.json post /partner/workspaces/{workspace}/connections
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 social accounts and 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: Client Connect API
    description: >-
      Hosted links that connect, or reconnect, a customer's social accounts and
      messaging channels, WhatsApp and Telegram included. One endpoint for every
      provider.
paths:
  /partner/workspaces/{workspace}/connections:
    parameters:
      - $ref: '#/components/parameters/Workspace'
    post:
      tags:
        - Client Connect API
      summary: Create a connection
      description: >-
        Starts a 30-minute session and returns `connect_url`. Open it as a
        top-level navigation in your customer's browser, never in an iframe or a
        fetch. `account_id` or `channel_id` makes it a reconnect. For `telegram`
        send `bot_token` instead of `return_url`: the bot is connected in this
        call and the connection comes back `connected`, with
        `meta.webhook_registered` and `meta.webhook_taken_over` (`201` for a new
        bot, `200` for the same bot again). See [Client Connect
        API](/partner/client-connect).
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            1–200 characters. The same key and request returns the same
            connection with `200`; a different request on that key is a `409`.
            Not used for Telegram.
          schema:
            type: string
            maxLength: 200
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - provider
              properties:
                provider:
                  type: string
                  enum:
                    - facebook_page
                    - instagram
                    - instagram_direct
                    - linkedin
                    - linkedin_page
                    - youtube
                    - google_m_b
                    - threads
                    - tiktok
                    - pinterest
                    - reddit
                    - tumblr
                    - twitter
                    - v_kontakte
                    - blue_sky
                    - mastodon
                    - whatsapp
                    - telegram
                  description: >-
                    Aliases accepted: `facebook` and `messenger`
                    (facebook_page), `instagram_login`, `gbp`, `x`, `vk`,
                    `bluesky`.
                  example: google_m_b
                return_url:
                  type: string
                  format: uri
                  description: >-
                    One of your registered return URLs, exactly. Required for
                    every provider but `telegram`.
                  example: https://app.acmedealers.test/integrations/callback
                state:
                  type: string
                  maxLength: 500
                  description: >-
                    Comes back on the return URL and in the completion events.
                    No secrets or personal data.
                  example: dealer-4821
                account_id:
                  type: string
                  format: uuid
                  description: >-
                    Reconnect this publishing account (of that workspace and
                    provider).
                channel_id:
                  type: string
                  format: uuid
                  description: >-
                    Reconnect this messaging channel: a WhatsApp channel, or a
                    channel that belongs to an account of `provider`.
                coexistence:
                  type: boolean
                  description: >-
                    `whatsapp` only: keep the number on the WhatsApp Business
                    app.
                max_accounts:
                  type: integer
                  minimum: 1
                  maximum: 100
                  description: >-
                    Providers with a picker: the most accounts your customer may
                    tick.
                allow_unverified:
                  type: boolean
                  description: >-
                    Reconnects: let your customer confirm a profile that cannot
                    be proven to be the same one.
                server:
                  type: string
                  maxLength: 253
                  description: >-
                    `mastodon`: the server. Asked on the hosted page when
                    absent.
                handle:
                  type: string
                  maxLength: 253
                  description: '`blue_sky`: the handle Bluesky''s sign-in opens on.'
                bot_token:
                  type: string
                  minLength: 20
                  maxLength: 120
                  description: >-
                    `telegram` only: the BotFather token. Never stored on the
                    connection or echoed back.
                  example: 123456:ABC…
                name:
                  type: string
                  maxLength: 120
                  description: '`telegram` only: the channel name.'
                  example: Acme Motors
                takeover:
                  type: boolean
                  description: >-
                    `telegram` only: move the bot's webhook here even though it
                    points somewhere else.
      responses:
        '200':
          description: >-
            The connection this Idempotency-Key already made, or the same
            Telegram bot again
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionEnvelope'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionEnvelope'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '403':
          description: The Client Connect API is not on for you.
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: The Idempotency-Key was used for a different request.
        '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:
    ConnectionEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/Connection'
        meta:
          type: object
          description: Telegram only.
          properties:
            webhook_registered:
              type: boolean
            webhook_taken_over:
              type: boolean
    Connection:
      type: object
      properties:
        id:
          type: string
          format: uuid
        workspace_id:
          type: string
          format: uuid
        provider:
          type: string
          enum:
            - facebook_page
            - instagram
            - instagram_direct
            - linkedin
            - linkedin_page
            - youtube
            - google_m_b
            - threads
            - tiktok
            - pinterest
            - reddit
            - tumblr
            - twitter
            - v_kontakte
            - blue_sky
            - mastodon
            - whatsapp
            - telegram
        mode:
          type:
            - string
            - 'null'
          enum:
            - relay
            - direct
            - broker
            - token
            - null
        reconnect:
          type: boolean
        status:
          type: string
          enum:
            - pending
            - authorizing
            - selecting
            - confirming
            - connected
            - failed
            - cancelled
            - expired
        account_id:
          type:
            - string
            - 'null'
          format: uuid
          description: The first account connected.
        account:
          oneOf:
            - type: object
              properties:
                id:
                  type: integer
                  description: >-
                    The integer the Publishing API's post endpoints take in
                    `accounts`.
                uuid:
                  type: string
                  format: uuid
                  description: The `{account}` in the Publishing API.
                provider:
                  type: string
                name:
                  type: string
                username:
                  type:
                    - string
                    - 'null'
            - type: 'null'
        accounts:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                description: >-
                  The integer the Publishing API's post endpoints take in
                  `accounts`.
              uuid:
                type: string
                format: uuid
                description: The `{account}` in the Publishing API.
              provider:
                type: string
              name:
                type: string
              username:
                type:
                  - string
                  - 'null'
          description: Every account connected, a WhatsApp number included.
        skipped:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              reason:
                type: string
        max_accounts:
          type:
            - integer
            - 'null'
        allow_unverified:
          type: boolean
        coexistence:
          type: boolean
        channel_id:
          type:
            - string
            - 'null'
          format: uuid
          description: The messaging channel, when there is one.
        error_code:
          type:
            - string
            - 'null'
          description: >-
            Why it `failed`. See [Error
            codes](/partner/client-connect#error-codes).
        state:
          type:
            - string
            - 'null'
        expires_at:
          type: string
          format: date-time
        connect_url:
          type: string
          format: uri
          description: >-
            Only on a pending, unexpired session. A one-session capability: hand
            it straight to the customer's browser and never log it.
    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.