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

> Link up to 100 contacts to companies in one call, naming each contact by id, email, or phone. A row that fails returns its own error and does not affect the others.

# Link many contacts to companies



## OpenAPI

````yaml post /companies/links
openapi: 3.1.0
info:
  title: OpenCX API
  description: >

    OpenCX is an AI-powered, all-in-one platform for customer support and
    outbound communications.


    Use this API to manage your OpenCX organization's AI agents, actions,
    conversations, contacts, and more.


    To get started, generate a new API key from the dashboard.


    ## Authentication

    All API endpoints require authentication using a Bearer token. You can
    generate an API key from your OpenCX dashboard.


    ## Rate Limiting

    API requests are rate limited to ensure fair usage. The current limits are:

    - 100 requests per minute for standard endpoints

    - 1000 requests per minute for streaming endpoints


    ## Error Handling

    The API uses standard HTTP status codes and returns detailed error messages
    in the response body.
  version: 1.0-beta
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: http://localhost:8080
    description: Development
  - url: https://api.open.cx
    description: Production
security:
  - bearerAuth: []
paths:
  /companies/links:
    post:
      summary: Link many contacts to companies
      description: >-
        Links up to 100 contacts in one call. Name each contact by `contact_id`,
        `contact_email`, or `contact_phone` — exactly one — so a sync can link
        straight from the identifiers it already holds. Each result carries the
        resolved `contact_id`. Failures are isolated: a contact that cannot be
        linked returns an error in its own result entry and does not affect the
        others, so the call succeeds even when some links do not. Results come
        back in request order.
      operationId: bulkLinkContactsToCompanies
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkLinkContactsDto'
      responses:
        '201':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkLinkContactsOutput'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    BulkLinkContactsDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/BulkLinkContactsDtoInput'
      type: object
      properties:
        links:
          minItems: 1
          maxItems: 100
          type: array
          items:
            type: object
            properties:
              contact_id:
                description: The OpenCX contact id, if you already hold it
                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)$
              contact_email:
                description: Look the contact up by email instead of id
                type: string
                format: email
                pattern: >-
                  ^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
              contact_phone:
                description: >-
                  Look the contact up by phone instead of id. `+15551234567` and
                  `15551234567` both match
                type: string
                minLength: 1
              external_id:
                type: string
                minLength: 1
                description: >-
                  The company to link, by the same `external_id` you upserted it
                  with
            required:
              - external_id
      required:
        - links
    BulkLinkContactsOutput:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/BulkLinkContactsOutput'
      type: object
      properties:
        results:
          type: array
          items:
            type: object
            properties:
              contact_id:
                anyOf:
                  - type: string
                  - type: 'null'
                description: >-
                  The resolved contact id. Null when the identifier did not
                  resolve.
              external_id:
                type: string
              outcome:
                anyOf:
                  - type: string
                    enum:
                      - linked
                      - unchanged
                  - type: 'null'
              error:
                anyOf:
                  - type: string
                  - type: 'null'
                description: Null when this contact linked successfully
              company:
                anyOf:
                  - $ref: '#/components/schemas/Company'
                  - type: 'null'
            required:
              - contact_id
              - external_id
              - outcome
              - error
              - company
            additionalProperties: false
          description: One entry per requested link, in request order
        summary:
          type: object
          properties:
            total:
              type: number
            linked:
              type: number
            unchanged:
              type: number
            failed:
              type: number
          required:
            - total
            - linked
            - unchanged
            - failed
          additionalProperties: false
      required:
        - results
        - summary
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    Company:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/Company'
      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)$
        external_id:
          type: string
          description: The organization's own key for this company
        name:
          type: string
        custom_data:
          anyOf:
            - type: object
              propertyNames:
                type: string
              additionalProperties:
                anyOf:
                  - type: string
                  - type: number
                  - type: boolean
            - type: 'null'
        created_at:
          type: string
          description: ISO 8601 timestamp of when the company was created
        updated_at:
          type: string
          description: ISO 8601 timestamp of when the company was last updated
      required:
        - id
        - external_id
        - name
        - custom_data
        - created_at
        - updated_at
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````