> ## 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 Entities

> 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: https://api.base39.com.br
    description: Production
  - url: https://api.dev.base39.cloud
    description: Development
  - url: http://localhost:3000
    description: Local
security:
  - OAuth2: []
tags:
  - name: Search
  - name: Companies
  - name: Registration
  - name: Addresses
  - name: Relationships
  - name: Queries
  - name: Credit & Financial
  - name: Checks
  - name: Protests
  - name: Government Debt
  - name: Litigation & Bankruptcy
  - name: Compliance
  - name: Certificates
  - name: Restrictions
  - name: SCR
  - name: Reputation
  - name: Social Assistance
  - name: History
  - name: Graph
  - name: Files
  - name: Rules
  - name: Monitoring
  - name: Scorecards
  - name: Feature Store
  - name: Mentions
  - name: Views
  - name: Skills
  - name: Custom Tools
  - name: Connections
  - name: Connectors
  - name: OAuth Integrations
  - name: WhatsApp
  - name: Upstreams
  - name: Billing
  - name: Usage
  - name: Organizations
  - name: Members
  - name: Users
  - name: Authentication
  - name: API Keys
  - name: Notifications
  - name: Changelog
  - name: Webhooks
  - name: Vaults
  - name: Version
  - name: Context Schema
paths:
  /v2/search:
    get:
      tags:
        - Search
      summary: Search Entities
      description: >-
        Searches org-scoped companies first and merges Receita Federal results
        after deduplication.
      operationId: search_search
      parameters:
        - name: query
          required: true
          in: query
          description: Search query string (supports full-text search and fuzzy matching)
          schema:
            example: company financial report
            type: string
        - name: sort
          required: false
          in: query
          description: Sort order
          schema:
            type: string
            enum:
              - relevance
        - name: page_size
          required: false
          in: query
          description: Number of results per page
          schema:
            minimum: 1
            maximum: 100
            default: 20
            type: number
        - name: start_cursor
          required: false
          in: query
          description: Cursor for pagination (next_cursor from previous response)
          schema:
            example: page_abc123
            type: string
        - 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

````