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

# Link a contact to a company

> Links the contact to an existing company. A contact can be linked to several companies; the first one linked becomes its primary company.

Idempotent: linking a company the contact already has answers `200` with the same body instead of `201`, and changes nothing — safe to retry.

To find the `company_id`, use [list companies](/api-reference/cloudchat/endpoints/list-companies), for example filtered by an attribute such as the CNPJ. An assistant cannot link companies.



## OpenAPI

````yaml api-reference/specs/cloudchat/v1.json POST /v1/accounts/{accountId}/contacts/{contactId}/companies
openapi: 3.0.1
info:
  title: Cloud Chat API
  version: v1
  description: >-
    The curated public surface of Cloud Chat. Every call needs two things: the
    Bearer token from `POST /auth/v1/signin`, and the `cloudchat-instance`
    header that says which Cloud Chat instance your company lives on.


    If you don't know your instance value, the [Find your
    credentials](/api-reference/cloudchat/credentials) page reads it out of your
    own token in the browser.
servers:
  - url: https://api.cloudhumans.com/cloudchat
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Canned Responses
    description: >-
      Canned responses — the shortcuts agents expand while replying. Each one
      belongs to a single account and is identified by its short code.
  - name: Conversations
    description: >-
      The conversations of an account: read them, change their priority and
      status, assign them, leave internal notes, and block or unblock the
      contact of a conversation. Answering the customer, opening a conversation
      and deleting one are not part of this surface. What you can see and change
      follows the same rule as the dashboard: an administrator token reaches
      every inbox, an agent token only the inboxes it is a member of.
  - name: Contacts
    description: >-
      Customer contacts of the account, with their personal data. Administrators
      only.
  - name: Help Center
    description: >-
      Portals, categories and articles of the help center — the public FAQ your
      customers read.
  - name: Uploads
    description: Store the images help center articles embed.
  - name: Labels
    description: >-
      The label definitions of an account: the tags conversations and contacts
      carry. Listing and reading are open to any member; creating and updating a
      label need an administrator or CX engineer token. Renaming a label retags
      the records that carry it. There is no delete: removing a label and
      creating another with the same title would bring the old tags back. The
      same group applies labels to a conversation or a contact and takes them
      off again.
  - name: Inboxes
    description: >-
      The inboxes a token can see — every inbox of the account for an
      administrator, only its memberships for an agent. Administrators can also
      change an inbox's name, greeting, working hours and CSAT toggle. Never
      includes the channel's credentials, and the channel itself is not editable
      here.
  - name: Agents
    description: >-
      Read-only access to the human and AI agents of an account. A hidden admin
      (the platform's own support user) never appears, on the list or by id.
  - name: Teams
    description: >-
      Teams group agents for assignment. Listing and reading are open to any
      member; creating and updating a team, and managing its membership, require
      an administrator token. A system-managed team (provisioned by the
      platform) can be read like any other but never updated.
  - name: Macros
    description: >-
      Macros bundle a sequence of actions an agent runs against a conversation
      from the dashboard. This surface lets you list, read and write macro
      definitions — running one is not part of the v1 contract. A macro is
      either `global` (visible to the whole account) or `personal` (visible only
      to its author); an agent token can only create personal macros.
  - name: Automation Rules
    description: >-
      The account's automation rules — administrator only. An agent token gets a
      403 on every operation in this group.


      Reading is direct. Writing goes through a propose → confirm pair: the
      propose call validates the change, writes nothing, and returns a
      single-use `proposal_token` with a preview and a list of `warnings`; the
      confirm call sends the token back and applies exactly what was previewed.
      Rules created through the API start off, and turning a rule on or off
      stays with a person in the Cloud Chat automations screen.
  - name: Availability Reasons
    description: >-
      The reasons an agent can go `busy` for, configured per account. Listing is
      open to any member; creating, updating and deleting require an
      administrator token. Deleting is a soft delete — the reason disappears
      from listings but agents' past availability history keeps referencing it.
  - name: Native Attribute Requirements
    description: >-
      Which native conversation attributes (priority, assignee, tag, team) the
      account requires agents to fill before resolving a conversation. Listing
      is open to any member; requiring and un-requiring need an administrator
      token. Deleting a requirement is reversible — require the same key again
      to restore it.
  - name: Custom Attributes
    description: >-
      The custom fields an account added to conversations, contacts and
      companies, and their definitions: key, type, model and options. Listing
      and reading are open to any member; creating and editing need an
      administrator token. Deleting a definition, conditional sub-lists and the
      AI fill settings stay in the Cloud Chat screen.
  - name: Campaigns
    description: Check who a campaign would reach, send it, and read the result back.
  - name: Reports
    description: The numbers of the Cloud Chat reporting dashboards, read through the API.
  - name: Companies
    description: >-
      Companies (the businesses your contacts work for) and the links between
      contacts and companies. Companies must be enabled for the account; when
      they are not, every operation in this group answers `403`. Any member of
      the account can read. Updating a company and linking or unlinking contacts
      is open to agents, supervisors, CX engineers and administrators; an
      assistant is read-only.
paths:
  /v1/accounts/{accountId}/contacts/{contactId}/companies:
    parameters:
      - $ref: '#/components/parameters/CloudChatInstance'
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ContactId'
    post:
      tags:
        - Companies
      summary: Link a contact to a company
      description: >-
        Links the contact to an existing company. A contact can be linked to
        several companies; the first one linked becomes its primary company.


        Idempotent: linking a company the contact already has answers `200` with
        the same body instead of `201`, and changes nothing — safe to retry.


        To find the `company_id`, use [list
        companies](/api-reference/cloudchat/endpoints/list-companies), for
        example filtered by an attribute such as the CNPJ. An assistant cannot
        link companies.
      operationId: linkContactCompany
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContactCompanyLinkRequest'
            example:
              company_id: 314
      responses:
        '200':
          description: The contact was already linked to this company. Nothing changed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkedCompany'
              example:
                id: 314
                name: Transportadora Rápida
                domain: rapida.com.br
                description: Transportadora parceira para entregas no Sudeste.
                contacts_count: 3
                labels:
                  - transportadora
                custom_attributes:
                  cnpj: '12345678000190'
                  rm_responsavel: Ana Lima
                  operacoes:
                    - Last mile
                    - Reversa
                created_at: '2026-08-14T12:30:05.412Z'
                updated_at: '2026-10-28T17:02:41.903Z'
                primary: true
        '201':
          description: Linked. The body is the company as seen from the contact.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkedCompany'
              example:
                id: 314
                name: Transportadora Rápida
                domain: rapida.com.br
                description: Transportadora parceira para entregas no Sudeste.
                contacts_count: 3
                labels:
                  - transportadora
                custom_attributes:
                  cnpj: '12345678000190'
                  rm_responsavel: Ana Lima
                  operacoes:
                    - Last mile
                    - Reversa
                created_at: '2026-08-14T12:30:05.412Z'
                updated_at: '2026-10-28T17:02:41.903Z'
                primary: true
        '400':
          description: >-
            Malformed request, or a `company_id` that is missing or not a
            positive integer. `error.details` then names `company_id`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: bad_request
                  message: The request is malformed.
                  details:
                    - field: company_id
                      code: invalid
                      message: >-
                        Provide company_id as a positive integer. Use
                        listCompanies to find it.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/CompaniesForbidden'
        '404':
          description: >-
            The account is not reachable for you (see the shared 404 on any
            other endpoint), or the contact or the company does not exist in
            this account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: not_found
                  message: Resource could not be found.
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    CloudChatInstance:
      name: cloudchat-instance
      in: header
      required: true
      description: >-
        Your Cloud Chat instance ID — an integer, fixed for your company, told
        at onboarding. [The API
        overview](/api-reference/cloudchat/overview#two-headers-every-call)
        explains how instances work, how to find yours, and the errors a wrong
        or missing value produces.
      schema:
        type: integer
        example: 1
    AccountId:
      name: accountId
      in: path
      required: true
      description: >-
        Your Cloud Chat account. It has to be an account your token grants
        membership on, and it has to live on the instance in the
        `cloudchat-instance` header — the two travel together. Account numbers
        are only unique **within** an instance, so the same number is a
        different company on another instance. Usually a mismatched pair fails
        closed with a 401, because your user does not exist on the other
        instance — but if your identity happens to exist on both, the call
        succeeds against the other company's data, silently. Read it and you are
        looking at the wrong help center; write it and you have stored into the
        wrong account. Send the two values that were given to you together, and
        never try a number to see what answers.
      schema:
        type: integer
        example: 1
    ContactId:
      name: contactId
      in: path
      required: true
      description: >-
        The contact id — the `contact.id` returned by the conversation
        endpoints.
      schema:
        type: integer
        example: 815
  schemas:
    ContactCompanyLinkRequest:
      type: object
      required:
        - company_id
      properties:
        company_id:
          type: integer
          description: >-
            The `id` of the company to link, as returned by [list
            companies](/api-reference/cloudchat/endpoints/list-companies).
          example: 314
    LinkedCompany:
      description: >-
        A company as seen from one contact: the company, plus whether it is that
        contact's primary company.
      allOf:
        - $ref: '#/components/schemas/Company'
        - type: object
          required:
            - primary
          properties:
            primary:
              type: boolean
              description: >-
                Whether this is the contact's primary company. A contact can be
                linked to several companies; the first one linked becomes the
                primary.
              example: true
    Error:
      type: object
      description: The error envelope every Cloud Chat API response uses.
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: >-
                The stable, machine-readable reason. Branch on this, never on
                `message`.
              enum:
                - unauthorized
                - forbidden
                - not_found
                - validation_failed
                - conflict
                - bad_request
                - internal_error
                - rate_limited
                - service_unavailable
              example: not_found
            message:
              type: string
              description: >-
                The reason in words, localized to your account's language
                (English, Spanish or Brazilian Portuguese; English when the
                account is set to anything else). Wording changes with the
                account and between releases, so never match on it.


                Two cases stay in English whatever the account is set to:
                `unauthorized`, decided before any account is known, and the
                account-level `not_found`, which must not reveal the account's
                language.
              example: Resource could not be found.
            details:
              type: array
              description: >-
                Present on some rejections — a 400 for a refused query parameter
                or upload mode, for example. One entry per offending field,
                localized to the account's language like `message` — match on
                `code` and `field`, never on the text.
              items:
                type: object
                required:
                  - field
                  - code
                  - message
                properties:
                  field:
                    type: string
                    description: Which request field the rule was about.
                  code:
                    type: string
                    description: Stable, machine-readable reason.
                  message:
                    type: string
                    description: The rule in words.
    Company:
      type: object
      description: A company of the account.
      required:
        - id
        - name
        - domain
        - description
        - contacts_count
        - labels
        - custom_attributes
        - created_at
        - updated_at
      properties:
        id:
          type: integer
          description: >-
            The company id. Send it as `companyId` or `company_id` to the other
            company operations.
          example: 314
        name:
          type: string
          description: The company name.
          example: Transportadora Rápida
        domain:
          type: string
          nullable: true
          description: >-
            The company's web domain, `null` when it has none. Read-only through
            this API.
          example: rapida.com.br
        description:
          type: string
          nullable: true
          description: Free text about the company, `null` when it has none.
          example: Transportadora parceira para entregas no Sudeste.
        contacts_count:
          type: integer
          description: How many contacts are linked to the company.
          example: 3
        labels:
          type: array
          description: The labels on the company, by name. An empty array when it has none.
          items:
            type: string
          example:
            - transportadora
        custom_attributes:
          type: object
          description: >-
            The company's custom attributes, keyed by attribute key. A value is
            a string, a number, a boolean or an array of strings (for a
            multi-select list). An attribute your role cannot see is left out
            entirely, not returned as `null`, so a missing key can mean either
            "not set" or "not visible to you". An empty object when none are
            set.
          additionalProperties:
            oneOf:
              - type: string
              - type: number
              - type: boolean
              - type: array
                items:
                  type: string
          example:
            cnpj: '12345678000190'
            rm_responsavel: Ana Lima
            operacoes:
              - Last mile
              - Reversa
        created_at:
          type: string
          format: date-time
          description: When the company was created. ISO 8601 in UTC, with milliseconds.
          example: '2026-08-14T12:30:05.412Z'
        updated_at:
          type: string
          format: date-time
          description: When the company was last changed, in the same format.
          example: '2026-10-28T17:02:41.903Z'
    GatewayError:
      type: object
      description: >-
        Rejected by the gateway before Cloud Chat saw it, so it does not use the
        `error` envelope.
      required:
        - message
      properties:
        message:
          type: string
          example: API rate limit exceeded
        request_id:
          type: string
          description: Gateway request id. Quote it when reporting a problem.
          example: f3f7567638d4b65a8003057d0c77d275
  responses:
    Unauthorized:
      description: >-
        No Bearer token, or one that is expired, malformed, or not a Cognito
        token. Sign in again for a fresh `id_token`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: >-
                Authentication is required. Send a valid Bearer token in the
                Authorization header.
    CompaniesForbidden:
      description: >-
        Refused for who you are or for the account's setup, not for what you
        sent. Three causes:


        - **Companies are not enabled for the account.** Every operation in this
        group answers this way until they are, with the message in the example
        below. Talk to your Cloud Humans contact.

        - **Your role does not permit it.** Reading is open to every member of
        the account. Writing (updating a company, linking or unlinking a
        contact) is refused for an assistant.

        - **The account is suspended.** Then nothing on it can be read or
        written until it is reactivated.


        Not being a member of the account is a **404**, not a 403.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: forbidden
              message: Companies are not enabled for this account.
    TooManyRequests:
      description: >-
        Rate limited per credential. Note the envelope: this one is `{
        "message": ... }`, because the request never reached the API.


        Don't hardcode the limit — read it from the response. `Retry-After` says
        how many seconds to wait, and every response (not just this one) carries
        `ratelimit-limit`, `ratelimit-remaining` and `ratelimit-reset`, the last
        in seconds.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GatewayError'
          example:
            message: API rate limit exceeded
    InternalError:
      description: >-
        Something failed on our side. The response never carries the underlying
        error, but it is reported to our monitoring automatically — no need to
        file anything for a one-off.


        Retrying is reasonable, with one caveat on `POST`: a 500 does not prove
        the write did not happen, so a retry can come back `422` with
        `short_code` already taken. That 422 means the first attempt succeeded —
        list the account and confirm before treating it as a failure.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: internal_error
              message: An unexpected error occurred. Please try again later.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        The `id_token` from `POST /auth/v1/signin`, sent as `Authorization:
        Bearer <id_token>`. Not the `access_token` — that one does not carry the
        identity Cloud Chat authorizes on.

````

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