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

> ## Agent Instructions
> Base URL: https://api.social-api.ai/v1. Send your API key in the Authorization header: Authorization: Bearer <your API key>.
> Every error response from /v1 is JSON: { "error": { "code", "message", "meta" (optional) }, "request_id" }. Branch on error.code; use error.message only for logs.
> A 429 response carries a Retry-After header, in seconds, when the limit has a known wait. Authenticated responses can carry X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset for the per-minute request budget your SocialAPI account shares across every API key (see /guides/rate-limits).
> Paginated list endpoints return next_cursor, at the top level or inside pagination (see /guides/pagination). Pass it as the cursor query parameter to get the next page. An absent or empty next_cursor means you have the last page.
> Treat every ID as an opaque string: do not parse it or assume a format.
> Support differs by platform and by operation. Check /platforms/overview before assuming an operation works on a platform. An unsupported operation returns 501 with error.code resource.not_supported.

# Exchange OAuth code

> Exchanges an OAuth authorization code for a connected social account. Use this when
you handle the OAuth callback on your own server (proxy flow). For a single account
the response is a flat ConnectAccountResponse (HTTP 201). When a single OAuth flow
connects multiple accounts (e.g. Facebook Pages) the response is OAuthCallbackResponse.



## OpenAPI

````yaml /api-reference/openapi.json post /oauth/exchange
openapi: 3.0.0
info:
  description: >-
    Unified social media inbox API. Read and respond to comments, DMs, reviews,
    and mentions across Instagram, Facebook, Threads, Google Business Profile,
    TikTok, LinkedIn, and YouTube through a single REST API. X/Twitter and
    Trustpilot coming soon.
  title: SocialAPI.AI
  contact:
    name: SocialAPI.AI Support
    email: support@social-api.ai
  license:
    name: MIT
  version: '1.0'
servers:
  - url: https://api.social-api.ai/v1
security: []
paths:
  /oauth/exchange:
    post:
      tags:
        - Accounts
      summary: Exchange OAuth code
      description: >-
        Exchanges an OAuth authorization code for a connected social account.
        Use this when

        you handle the OAuth callback on your own server (proxy flow). For a
        single account

        the response is a flat ConnectAccountResponse (HTTP 201). When a single
        OAuth flow

        connects multiple accounts (e.g. Facebook Pages) the response is
        OAuthCallbackResponse.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/api_endpoints.ExchangeRequest'
        description: Platform, code, and metadata (redirect_uri + state required)
        required: true
      responses:
        '200':
          description: Google login manages multiple Business Profiles; select one
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_endpoints.PendingConnectionResponse'
        '201':
          description: Single account connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_endpoints.ConnectAccountResponse'
        '400':
          description: Missing or invalid fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_endpoints.ErrorResponse'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_endpoints.ErrorResponse'
        '403':
          description: >-
            Plan limit reached (billing.platform_not_available or
            billing.brands_limit)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_endpoints.ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    api_endpoints.ExchangeRequest:
      type: object
      properties:
        code:
          description: Code is the authorization code received from the platform callback.
          type: string
          example: AQDtbPB9X...
        metadata:
          description: Metadata must include redirect_uri and state for CSRF validation.
          type: object
          additionalProperties: {}
        platform:
          description: >-
            Platform identifies the social platform (must match the connect
            call).
          type: string
          example: instagram
    api_endpoints.PendingConnectionResponse:
      type: object
      properties:
        connection_id:
          type: string
          example: pc_4a8f2c1e9b3d7f06a5c2e8b4d1f3a7e2
        login_id:
          description: >-
            login_id identifies the login and is set for both Facebook and
            Google.

            pages and lost_access are Facebook page-selection only.
          type: string
        lost_access:
          type: array
          items:
            $ref: '#/components/schemas/api_endpoints.LostPageAccess'
        pages:
          type: array
          items:
            $ref: '#/components/schemas/api_endpoints.PendingPage'
        platform:
          type: string
          example: google
        profiles:
          type: array
          items:
            $ref: '#/components/schemas/api_endpoints.PendingProfile'
        status:
          type: string
          example: selection_required
    api_endpoints.ConnectAccountResponse:
      type: object
      properties:
        account_id:
          type: string
          example: acc_01HZ9X3Q4R5M6N7P8V2K0W1J
        brand_id:
          description: >-
            BrandID is the brand the account was connected to. When the connect
            request named no brand, this is the brand created for it.
          type: string
          example: b7e3c1a2-4f5d-4e8a-9b1c-2d3e4f5a6b7c
        display_name:
          type: string
          example: Acme Corp
        platform:
          type: string
          example: instagram
        username:
          type: string
          example: acmecorp
    api_endpoints.ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/api_endpoints.ErrorBody'
        request_id:
          description: >-
            RequestID matches the X-Request-ID response header. Include it when
            contacting support.
          type: string
          example: 01HZ9X3Q4R5M6N7P8V2K0W1J
    api_endpoints.LostPageAccess:
      type: object
      properties:
        brand_id:
          type: string
        brand_name:
          type: string
        name:
          type: string
        platform_page_id:
          type: string
    api_endpoints.PendingPage:
      type: object
      properties:
        assignable:
          type: boolean
        assigned_account_id:
          type: string
        assigned_brand_id:
          type: string
        assigned_brand_name:
          type: string
        category:
          type: string
        name:
          type: string
          example: Acme Bakery
        picture_url:
          type: string
        platform_page_id:
          type: string
          example: '17841400000000000'
    api_endpoints.PendingProfile:
      type: object
      properties:
        bio:
          type: string
          example: Wood-fired pizza since 1998
        display_name:
          type: string
          example: Joe's Pizza (Downtown)
        platform_account_id:
          type: string
          example: accounts/123/locations/456
        profile_picture_url:
          type: string
          example: ''
        username:
          type: string
          example: ''
    api_endpoints.ErrorBody:
      type: object
      properties:
        code:
          type: string
          example: resource.not_found
        message:
          type: string
          example: Account not found
        meta:
          type: object
          additionalProperties: {}
  securitySchemes:
    BearerAuth:
      description: >-
        Prefix your API key with "Bearer ". Example: `Authorization: Bearer
        sapi_key_...`
      type: apiKey
      name: Authorization
      in: header

````

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