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

# Search companies

> Searches org-scoped companies first and merges Receita Federal results after deduplication.



## OpenAPI

````yaml /api-reference/openapi.json get /v2/search
openapi: 3.1.0
info:
  title: Base39 API
  description: Base39 API
  version: 1.0.0
  contact:
    name: Base39 Team
    url: https://base39.com.br
    email: suporte@base39.com.br
  termsOfService: https://base39.com.br/termos
  license:
    name: Proprietary
    url: https://base39.com.br/termos
servers:
  - url: http://localhost:3000
    description: Local
  - url: https://api.dev.base39.cloud
    description: Development
  - url: https://api.base39.com.br
    description: Production
security:
  - OAuth2: []
tags:
  - name: pages
    description: Profiles and reports pages
  - name: pipelines
    description: Pipeline boards (kanban) of pages
  - name: blocks
    description: Blocks operations
  - name: search
    description: Search across content
  - name: targets
    description: Lookup targets via datasets
  - name: CognitoTriggers
    description: Cognito triggers
paths:
  /v2/search:
    get:
      tags:
        - search
      summary: Search companies
      description: >-
        Searches org-scoped companies first and merges Receita Federal results
        after deduplication.
      operationId: search_search
      parameters:
        - name: types
          required: false
          in: query
          description: >-
            Comma-separated result object types to include. Allowed values:
            company, target, person.
          schema:
            type: string
      responses:
        '200':
          description: Search results with relevance scores
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchOutput'
        '400':
          description: Invalid search request
        '401':
          description: Unauthorized
components:
  schemas:
    SearchOutput:
      type: object
      properties:
        object:
          type: string
          enum:
            - list
          example: list
        results:
          type: array
          items:
            $ref: '#/components/schemas/SearchResultItemOutput'
        next_cursor:
          type: string
          nullable: true
        has_more:
          type: boolean
          description: Whether there are more results
        type:
          type: string
          enum:
            - search_result
      required:
        - object
        - results
        - next_cursor
        - has_more
    SearchResultItemOutput:
      type: object
      properties:
        object:
          type: string
          enum:
            - company
            - target
            - person
          example: target
        id:
          type: string
          description: Entity ID (CNPJ for target, CPF for person)
        score:
          type: number
          description: Relevance score (0-1)
          minimum: 0
          maximum: 1
        highlights:
          description: Highlighted text snippets with <mark> tags
          type: array
          items:
            type: string
        data:
          description: >-
            Result payload — TargetSearchDataOutput when object=company or
            object=target, PersonSearchDataOutput when object=person
          oneOf:
            - $ref: '#/components/schemas/TargetSearchDataOutput'
            - $ref: '#/components/schemas/PersonSearchDataOutput'
      required:
        - object
        - id
        - score
        - highlights
        - data
    TargetSearchDataOutput:
      type: object
      properties:
        object:
          type: string
          enum:
            - target
          example: target
        cnpj:
          type: string
          description: CNPJ (14 chars)
        icon:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/IconOutput'
        legalName:
          type: string
          nullable: true
        tradeName:
          type: string
          nullable: true
        city:
          type: string
          nullable: true
        state:
          type: string
          nullable: true
        isHeadQuarter:
          type: boolean
          description: Is headquarters (matriz)
        registrationStatus:
          type: string
          nullable: true
          description: Situação cadastral (Receita Federal)
        registrationStatusDate:
          type: string
          nullable: true
          description: Data da situação cadastral
        activityStartDate:
          type: string
          nullable: true
          description: Data de início de atividade
      required:
        - object
        - cnpj
        - icon
        - legalName
        - tradeName
        - city
        - state
        - isHeadQuarter
        - registrationStatus
        - registrationStatusDate
        - activityStartDate
    PersonSearchDataOutput:
      type: object
      properties:
        object:
          type: string
          enum:
            - person
          example: person
        cpf:
          type: string
          description: CPF (11 digits)
        name:
          type: string
          nullable: true
        oab:
          type: string
          nullable: true
        oabState:
          type: string
          nullable: true
      required:
        - object
        - cpf
        - name
        - oab
        - oabState
    IconOutput:
      type: object
      properties:
        type:
          type: string
          enum:
            - emoji
            - external
            - file_upload
            - domain
            - file
            - lucide
            - dicebear
            - brand
        emoji:
          type: string
          example: page_icon
        external:
          $ref: '#/components/schemas/ExternalFileOutput'
        file_upload:
          $ref: '#/components/schemas/FileUploadOutput'
        domain:
          type: string
          example: acme.com
        file:
          $ref: '#/components/schemas/InternalFileOutput'
        lucide:
          type: string
          example: file-text
        brand:
          type: string
          example: github
          description: Simple Icons brand slug (logo and color resolved automatically)
        dicebear:
          $ref: '#/components/schemas/DicebearIconPayloadOutput'
        background:
          type: string
          enum:
            - blue
            - red
            - pattern-red
            - pattern-blue
            - pattern-red-1
            - pattern-red-2
            - pattern-red-3
            - pattern-blue-1
            - pattern-blue-2
            - pattern-blue-3
        empty:
          type: boolean
          example: true
        updatedBy:
          type: string
          example: dataset:empresas
    ExternalFileOutput:
      type: object
      properties:
        url:
          type: string
          example: https://example.com/image.jpg
      required:
        - url
    FileUploadOutput:
      type: object
      properties:
        id:
          type: string
          example: fu_abc123
      required:
        - id
    InternalFileOutput:
      type: object
      properties:
        url:
          type: string
          example: https://s3.amazonaws.com/...
        expiryTime:
          type: string
          example: '2024-01-15T10:30:00.000Z'
      required:
        - url
        - expiryTime
    DicebearIconPayloadOutput:
      type: object
      properties:
        style:
          type: string
          enum:
            - notionists-neutral
        seed:
          type: string
          example: 0256de50-f90c-49a8-81f0-3988b2b89d8d
        backgroundColor:
          type: string
          example: b6e3f4,b6e3f4
          description: Hex color(s), comma-separated for gradients
        options:
          $ref: '#/components/schemas/DicebearIconOptionsOutput'
      required:
        - style
        - seed
        - backgroundColor
    DicebearIconOptionsOutput:
      type: object
      properties:
        brows:
          type: string
        eyes:
          type: string
        glasses:
          type: string
        lips:
          type: string
        nose:
          type: string
        flip:
          type: boolean
        rotate:
          type: number
        scale:
          type: number
        radius:
          type: number
        size:
          type: number
        backgroundType:
          type: string
          enum:
            - solid
            - gradientLinear
        backgroundRotation:
          type: array
          items:
            type: number
        translateX:
          type: number
        translateY:
          type: number
        clip:
          type: boolean
        randomizeIds:
          type: boolean
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://id.local.base39.cloud/oauth2/authorize
          tokenUrl: https://id.local.base39.cloud/oauth2/token
          scopes:
            profile: Read user profile
            email: Read user email
            openid: OpenID authentication
      description: OAuth2 Authorization Code flow

````