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

# Add a user-owned X app connection

> Requires an interactive owner session. Stores the X OAuth client secret in Factorize-managed encrypted storage and never returns it. Selected scopes are validated before saving.

Requires the integrations:write scope.

An interactive owner session is required; bearer tokens cannot call this operation.



## OpenAPI

````yaml /openapi.yaml post /api/v1/x/connections
openapi: 3.1.0
info:
  title: Factorize API
  version: 1.0.0
  description: >-
    Versioned Factorize REST API. See the hosted docs for examples and OAuth
    discovery.
  x-dashboard-auth: >-
    Access-token and authorized-client management and trace replay operations
    require an interactive owner session; all other operations accept a suitably
    scoped bearer token or owner session.
servers:
  - url: https://app.factorize.sh
security:
  - bearerAuth: []
paths:
  /api/v1/x/connections:
    post:
      tags:
        - x
      summary: Add a user-owned X app connection
      description: >-
        Requires an interactive owner session. Stores the X OAuth client secret
        in Factorize-managed encrypted storage and never returns it. Selected
        scopes are validated before saving.


        Requires the integrations:write scope.


        An interactive owner session is required; bearer tokens cannot call this
        operation.
      operationId: post_api_v1_x_connections
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                name:
                  type: string
                  minLength: 1
                  maxLength: 120
                clientId:
                  type: string
                  minLength: 1
                  maxLength: 256
                clientSecret:
                  type: string
                  minLength: 1
                  maxLength: 4096
                  pattern: ^[^\r\n]+$
                  writeOnly: true
                scopes:
                  minItems: 1
                  maxItems: 24
                  type: array
                  items:
                    type: string
                    enum:
                      - tweet.read
                      - tweet.write
                      - tweet.moderate.write
                      - users.email
                      - users.read
                      - follows.read
                      - follows.write
                      - offline.access
                      - space.read
                      - mute.read
                      - mute.write
                      - like.read
                      - like.write
                      - list.read
                      - list.write
                      - block.read
                      - block.write
                      - bookmark.read
                      - bookmark.write
                      - dm.read
                      - dm.write
                      - media.write
                      - broadcast.read
                      - broadcast.write
              required:
                - id
                - name
                - clientId
                - clientSecret
                - scopes
              additionalProperties: false
      responses:
        '201':
          description: X connection created
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  name:
                    type: string
                  clientId:
                    type: string
                  scopes:
                    type: array
                    items:
                      type: string
                  accountId:
                    type:
                      - string
                      - 'null'
                  accountHandle:
                    type:
                      - string
                      - 'null'
                  grantedScopes:
                    type: array
                    items:
                      type: string
                  status:
                    type: string
                    enum:
                      - pending
                      - connected
                      - reconnect_required
                      - revoked
                  createdAt:
                    type: string
                  updatedAt:
                    type: string
                required:
                  - id
                  - name
                  - clientId
                  - scopes
                  - accountId
                  - accountHandle
                  - grantedScopes
                  - status
                  - createdAt
                  - updatedAt
                additionalProperties: false
        '400':
          $ref: '#/components/responses/Error400'
        '401':
          $ref: '#/components/responses/Error401'
        '403':
          $ref: '#/components/responses/Error403'
        '404':
          $ref: '#/components/responses/Error404'
        '409':
          $ref: '#/components/responses/Error409'
        '415':
          $ref: '#/components/responses/Error415'
        '429':
          $ref: '#/components/responses/Error429'
        '500':
          $ref: '#/components/responses/Error500'
        '503':
          $ref: '#/components/responses/Error503'
      security:
        - cookieAuth: []
components:
  responses:
    Error400:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error401:
      description: Invalid or revoked credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error403:
      description: Missing scope or required owner session
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error404:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error409:
      description: Operation conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error415:
      description: Unsupported media type; use application/json
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error429:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error500:
      description: Internal error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error503:
      description: Service unavailable
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: OAuth2
    cookieAuth:
      type: apiKey
      in: cookie
      name: factorize_session

````

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