# Create or Update a company

`POST /companies`

> This is a subset of the full specification, limited to the `POST /companies` operation.
>
> You can find the full specification here: /_bundle/docs/references/@2.18/rest-api/api.intercom.io.yaml

```yaml
openapi: 3.0.1
info:
  title: Intercom API
  version: '2.18'
  description: This is a subset of the full specification, limited to the `POST /companies` operation.
  contact:
    name: Intercom Developer Hub
    url: https://developers.intercom.com
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
servers:
  - url: https://api.intercom.io
    description: The production API server
  - url: https://api.eu.intercom.io
    description: The european API server
  - url: https://api.au.intercom.io
    description: The australian API server
security:
  - bearerAuth: []
tags:
  - name: Companies
    description: Everything about your Companies
paths:
  /companies:
    post:
      summary: Create or Update a company
      parameters:
        - name: Intercom-Version
          in: header
          schema:
            $ref: '#/components/schemas/intercom_version'
      tags:
        - Companies
      operationId: createOrUpdateCompany
      description: |-
        You can create or update a company.

        Companies will be only visible in Intercom when there is at least one associated user.

        Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated.

        You must send either `company_id` or `id`. A request with neither returns a `400` error.

        Every custom attribute you send must already exist in your workspace. Sending one that doesn't returns a `400` error.

        **Using `company_id`**

        You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company.

        Requires the `write_users_companies` OAuth scope.
      responses:
        '200':
          description: Successful
          content:
            application/json:
              examples:
                Successful:
                  value:
                    type: company
                    company_id: company_remote_id
                    id: 6762f0761bb69f9f2193bae2
                    app_id: this_is_an_id147_that_should_be_at_least_
                    name: my company
                    remote_created_at: 1374138000
                    created_at: 1734537334
                    updated_at: 1734537334
                    monthly_spend: 0
                    session_count: 0
                    user_count: 0
                    tags:
                      type: tag.list
                      tags: []
                    segments:
                      type: segment.list
                      segments: []
                    plan: {}
                    custom_attributes:
                      industry: manufacturing
                    notes:
                      type: note.list
                      data: []
                      url: /companies/6762f0761bb69f9f2193bae2/notes
                      total_count: 0
                      has_more: false
              schema:
                $ref: '#/components/schemas/company'
        '400':
          description: Bad Request
          content:
            application/json:
              examples:
                Bad Request:
                  value:
                    type: error.list
                    request_id: null
                    errors:
                      - code: bad_request
                        message: bad 'test' parameter
                Missing company_id:
                  value:
                    type: error.list
                    request_id: 0c6a6de1-7f2b-4a5e-9a3c-1b2d8e4f5a60
                    errors:
                      - code: bad_request
                        message: missing 'company_id' parameter
                Custom attribute does not exist:
                  value:
                    type: error.list
                    request_id: 1d7b7ef2-8a3c-4b6f-8b4d-2c3e9f506b71
                    errors:
                      - code: parameter_invalid
                        message: Custom attribute 'plan_tier' does not exist
                Custom attribute value is an object:
                  value:
                    type: error.list
                    request_id: 2e8c8f03-9b4d-4c70-9c5e-3d4f0a617c82
                    errors:
                      - code: nested_custom_attributes
                        message: Cannot submit an object as a custom attribute value
                Company is not an object:
                  value:
                    type: error.list
                    request_id: null
                    errors:
                      - code: '422'
                        message: invalid company data structure
              schema:
                $ref: '#/components/schemas/error'
        '401':
          description: Unauthorized
          content:
            application/json:
              examples:
                Unauthorized:
                  value:
                    type: error.list
                    request_id: 8a9f415f-e9df-41e9-ba1f-739914f66551
                    errors:
                      - code: unauthorized
                        message: Access Token Invalid
                Token lacks required scope:
                  value:
                    type: error.list
                    request_id: 3f9d9014-ac5e-4d81-ad6f-4e501b728d93
                    errors:
                      - code: token_unauthorized
                        message: Not authorized to access resource
              schema:
                $ref: '#/components/schemas/error'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              examples:
                Monthly spend out of range:
                  value:
                    type: error.list
                    request_id: 3dfc2c5e-fe80-460e-9b42-765c2835beeb
                    errors:
                      - code: unprocessable_entity
                        message: monthly_spend has to be in range [-2147483648, 2147483647]
              schema:
                $ref: '#/components/schemas/error'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_or_update_company_request'
            examples:
              successful:
                summary: Successful
                value:
                  company_id: company_remote_id
                  name: my company
                  remote_created_at: 1374138000
              bad_request:
                summary: Bad Request
                value:
                  test: invalid
components:
  schemas:
    company:
      title: Company
      type: object
      x-tags:
        - Companies
      description: Companies allow you to represent organizations using your product. Each company will have its own description and be associated with contacts. You can fetch, create, update and list companies.
      properties:
        type:
          type: string
          description: Value is `company`
          enum:
            - company
          example: company
        id:
          type: string
          description: The Intercom defined id representing the company.
          example: 531ee472cce572a6ec000006
        name:
          type: string
          description: The name of the company. Returned HTML-escaped, for example `&` as `&amp;`.
          example: Blue Sun
        app_id:
          type: string
          description: The Intercom defined code of the workspace the company is associated to.
          example: ecahpwf5
        plan:
          type: object
          properties:
            type:
              type: string
              description: Value is always "plan"
              example: plan
            id:
              type: string
              description: The id of the plan
              example: '269315'
            name:
              type: string
              description: The name of the plan
              example: Pro
        company_id:
          type: string
          description: The company id you have defined for the company. Returned HTML-escaped, for example `&` as `&amp;`.
          example: '6'
        remote_created_at:
          type: integer
          description: The time the company was created by you.
          example: 1663597223
        created_at:
          type: integer
          description: The time the company was added in Intercom.
          example: 1663597223
        updated_at:
          type: integer
          description: The last time the company was updated.
          example: 1663597223
        last_request_at:
          type: integer
          description: The time the company last recorded making a request.
          example: 1663597223
        size:
          type: integer
          description: The number of employees in the company.
          example: 100
        website:
          type: string
          description: The URL for the company website.
          example: https://www.intercom.com
        industry:
          type: string
          description: The industry that the company operates in.
          example: Software
        monthly_spend:
          type: integer
          description: How much revenue the company generates for your business.
          example: 100
        session_count:
          type: integer
          description: How many sessions the company has recorded.
          example: 100
        user_count:
          type: integer
          description: The number of users in the company.
          example: 100
        custom_attributes:
          type: object
          description: The custom attributes you have set on the company.
          additionalProperties:
            anyOf:
              - type: string
                nullable: true
              - type: integer
              - type: number
              - type: boolean
          example:
            paid_subscriber: true
            monthly_spend: 155.5
            team_mates: 9
        tags:
          type: object
          description: The list of tags associated with the company
          properties:
            type:
              type: string
              description: The type of the object
              enum:
                - tag.list
            tags:
              type: array
              items:
                $ref: '#/components/schemas/tag_basic'
        segments:
          type: object
          description: Always returned empty. Fetch a company's segments with the list attached segments endpoint.
          properties:
            type:
              type: string
              description: The type of the object
              enum:
                - segment.list
            segments:
              type: array
              items:
                $ref: '#/components/schemas/segment'
        notes:
          type: object
          description: The list of notes associated with the company
          properties:
            type:
              type: string
              description: The type of the object
              enum:
                - note.list
            data:
              type: array
              description: The notes on the company, newest first.
              items:
                $ref: '#/components/schemas/company_note'
            url:
              type: string
              description: The relative URL of the company's notes.
              example: /companies/531ee472cce572a6ec000006/notes
            total_count:
              type: integer
              description: The number of notes in `data`.
              example: 1
            has_more:
              type: boolean
              description: Always `false`. Every note on the company is returned in `data`.
              example: false
    company_note:
      title: Company Note
      type: object
      x-tags:
        - Notes
      description: A note as it appears inside a company's `notes` list. Fetch the full note with the retrieve note endpoint.
      properties:
        type:
          type: string
          description: String representing the object's type. Always has the value `note`.
          example: note
        id:
          type: string
          description: The id of the note.
          example: '17495962'
        url:
          type: string
          description: The relative URL of the note.
          example: /notes/17495962
        body:
          type: string
          description: The body text of the note.
          example: <p>Text for the note.</p>
    create_or_update_company_request:
      type: object
      title: Create Or Update Company Request Payload
      description: You can create or update a Company. Send either `company_id` or `id`; a request with neither returns a `400` error.
      nullable: true
      properties:
        name:
          type: string
          description: The name of the Company. Leading and trailing whitespace is removed.
          example: Intercom
        company_id:
          type: string
          description: The company id you have defined for the company. Can't be updated
          example: 625e90fc55ab113b6d92175f
        id:
          type: string
          description: An alternative name for `company_id`. Supply this or `company_id`.
          example: 625e90fc55ab113b6d92175f
        plan:
          type: string
          description: The name of the plan you have associated with the company.
          example: Enterprise
        size:
          type: integer
          description: The number of employees in this company.
          example: 100
        website:
          type: string
          description: The URL for this company's website. Please note that the value specified here is not validated. Accepts any string.
          example: https://www.example.com
        industry:
          type: string
          description: The industry that this company operates in.
          example: Manufacturing
        custom_attributes:
          type: object
          description: Values for custom attributes that already exist in your workspace. Each value can be a string, integer, number, boolean or null. Arrays and objects aren't accepted.
          additionalProperties:
            anyOf:
              - type: string
                nullable: true
              - type: integer
              - type: number
              - type: boolean
          example:
            paid_subscriber: true
            monthly_spend: 155.5
            team_mates: 9
        remote_created_at:
          type: integer
          description: The time the company was created by you.
          example: 1394531169
        update_last_request_at:
          type: boolean
          description: Set to true to update the company's last seen time to now.
          example: true
        monthly_spend:
          type: integer
          description: How much revenue the company generates for your business. Floats are truncated to whole integers, so 155.98 is stored as 155. A value above 2147483647 (2**31-1) is stored as 0. 2147483647 itself, or a value of -2147483648 or below, returns a `422` error.
          example: 1000
    error:
      type: object
      title: Error
      description: The API will return an Error List for a failed request, which will contain one or more Error objects.
      properties:
        type:
          type: string
          description: The type is error.list
          example: error.list
        request_id:
          type: string
          nullable: true
          format: uuid
          description: ''
          example: f93ecfa8-d08a-4325-8694-89aeb89c8f85
        errors:
          type: array
          description: An array of one or more error objects
          items:
            properties:
              code:
                type: string
                description: A string indicating the kind of error, used to further qualify the HTTP response code.
                example: unauthorized
              message:
                type: string
                nullable: true
                description: Optional. Human readable description of the error.
                example: Access Token Invalid
              data:
                type: object
                nullable: true
                additionalProperties: true
                description: Optional. Extra detail about the error, for example `required_permissions` on a 403 `action_forbidden` error.
                example:
                  required_permissions:
                    - read_conversations
            required:
              - code
      required:
        - type
        - errors
    intercom_version:
      description: Intercom API version.</br>If you omit the header, the API uses the version set in your app package, and 1.0 if none is set.
      type: string
      example: '2.18'
      enum:
        - '1.0'
        - '1.1'
        - '1.2'
        - '1.3'
        - '1.4'
        - '2.0'
        - '2.1'
        - '2.2'
        - '2.3'
        - '2.4'
        - '2.5'
        - '2.6'
        - '2.7'
        - '2.8'
        - '2.9'
        - '2.10'
        - '2.11'
        - '2.12'
        - '2.13'
        - '2.14'
        - '2.15'
        - '2.16'
        - '2.17'
        - '2.18'
    segment:
      title: Segment
      type: object
      x-tags:
        - Segments
      description: A segment is a group of your contacts defined by the rules that you set.
      properties:
        type:
          type: string
          description: The type of object.
          enum:
            - segment
          example: segment
        id:
          type: string
          description: The unique identifier representing the segment.
          example: 56203d253cba154d39010062
        name:
          type: string
          description: The name of the segment.
          example: Active
        created_at:
          type: integer
          description: The time the segment was created.
          example: 1394621988
        updated_at:
          type: integer
          description: The time the segment was updated.
          example: 1394622004
        person_type:
          type: string
          description: 'Type of the contact: contact (lead) or user.'
          enum:
            - contact
            - user
          example: contact
        count:
          type: integer
          description: The number of items in the user segment. It's returned when the request has `include_count` with a value. A company segment only gets a count when a contact segment has the same name, and it shows that segment's count.
          example: 3
          nullable: true
    tag_basic:
      title: Tag
      type: object
      x-tags:
        - Tags
      description: A tag allows you to label your contacts, companies, and conversations and list them using that tag.
      properties:
        type:
          type: string
          description: value is "tag"
          example: tag
        id:
          type: string
          description: The id of the tag
          example: '123456'
        name:
          type: string
          description: The name of the tag
          example: Test tag
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
```
