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

# Search Company

> This endpoint provides a powerful tool for searching our internal database of Companies. As our database primarily consists of employees, this functionality enables users to discover company information efficiently. By utilizing the Search Company endpoint, you can query our database to find relevant Companies and obtain their respective IDs for further exploration or integration with other functionalities.

<Warning>
  **Deprecated — July 15, EOD UTC.** Migrate to [Search Companies (v3)](/docs/endpoints/v3/search-companies).

  **During the transition window, v2 search is wired to the new OpenSearch instance.** Some IDs returned here may 404 in the v2 Fetch Company endpoint. See the [Migrating to v3](/docs/getting-started/migrating-to-v3) guide.
</Warning>

See [OpenSearch Mapping](/docs/enrichment-data/company/mappings-v2) for the Company endpoint.

Replace `"query"` with your OpenSearch DSL query defining the search criteria and set the proper `x-api-key`. The response will contain a list of company IDs matching the search criteria, that can be later used in the Company Fetch endpoint.

Search returns up to 1000 results per page. The pagination works exactly as in the Profile Search endpoint.

Response example:

```json theme={null}
{
  "ids": [
    "09d9c510-c9f6-4c6e-9e62-fe5fedbeda87",
  ],
  "totalCount": 1,
  "paginationToken": "eyJzZWFyY2hfYWZ0ZXIiOlt7ImZpZWxkIjoiX3Njb3JlIiwidmFsdWUiOjF9LHsiZmllbGQiOiJwcm9maWxlX2luZm8uaWQiLCJ2YWx1ZSI6IjAwMDE2MTU4LWYyY2EtNDYzZC05YWEzLTIyOWZkMzk0ZWQ0MSJ9XX0="
}
```


## OpenAPI

````yaml openapi.json POST /companies/search
openapi: 3.1.0
info:
  title: Swarm API
  version: 1.0.0
  contact:
    name: The Swarm
    url: https://theswarm.com
    email: hello@theswarm.com
servers:
  - url: https://bee.theswarm.com
security:
  - ApiKeyAuth: []
tags:
  - name: profiles
    description: Operations related to profiles
  - name: companies
    description: Operations related to companies
  - name: teams
    description: Operations for managing teams and connectors
  - name: social
    description: Operations related to social media posts and interactions
  - name: mcp
    description: Model Context Protocol endpoint for AI assistant integrations
  - name: credits
    description: Operations related to credit usage
  - name: network-mapper
    description: Operations for mapping connections and relationships across your network
paths:
  /companies/search:
    post:
      tags:
        - companies
      summary: Search for companies ids
      description: >-
        Search for companies ids using the [ElasticSearch Query
        DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html)
        format
      operationId: searchCompanies
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: object
                  description: >-
                    Search query in the [ElasticSearch Query
                    DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html)
                    format. [Find mapping
                    here](https://docs.theswarm.com/docs/mappings/company-v2)
                  example:
                    match:
                      company_info.industry:
                        query: Financial Services
                limit:
                  type: integer
                  description: >-
                    Limit the number of results. If you want to use
                    stable_pagination this parameter must be set to 1000
                  default: 100
                  maximum: 1000
                paginationToken:
                  type: string
                  description: Pagination token received in the previous response
                stable_pagination:
                  type: boolean
                  description: >-
                    When set to true, ensures that pagination results remain
                    consistent, even if the underlying data changes during
                    retrieval. This is useful for retrieving large result sets
                    reliably across multiple requests
                  default: false
              required:
                - query
      responses:
        '200':
          description: A list of profile ids matching provided query
          content:
            application/json:
              schema:
                type: object
                properties:
                  ids:
                    description: List of company ids
                    type: array
                    items:
                      type: string
                      format: uuid
                  totalCount:
                    description: Total number of profiles matching the query
                    type: integer
                  paginationToken:
                    description: Pagination token for the next request
                    type: string
                required:
                  - ids
                  - totalCount
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        5XX:
          $ref: '#/components/responses/5XX'
      security:
        - ApiKeyAuth: []
components:
  responses:
    '400':
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    '401':
      description: Unauthorized
    '403':
      description: Forbidden
    5XX:
      description: Unexpected error
  schemas:
    ErrorResponse:
      type: object
      properties:
        code:
          description: Error status code
          type: integer
        errors:
          type: array
          items:
            type:
              - string
              - object
      required:
        - code
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````