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

# Get Lawsuit Statistics



## OpenAPI

````yaml /api-reference/openapi.json get /v2/lawsuits/stats
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/lawsuits/stats:
    get:
      tags:
        - Litigation & Bankruptcy
      summary: Get Lawsuit Statistics
      operationId: lawsuits_get_stats
      parameters:
        - name: expand
          required: false
          in: query
          description: >-
            Comma-separated fields to expand. Supports selection with brackets
            (e.g., "createdBy,updatedBy" or "targets.company[icon,tradeName]").
          schema:
            example: createdBy
            type: string
        - name: page_size
          required: false
          in: query
          description: Number of items to return per page
          schema:
            minimum: 1
            maximum: 100
            default: 20
            example: 100
            type: number
        - name: start_cursor
          required: false
          in: query
          description: >-
            Opaque cursor for pagination. Use the next_cursor from previous
            response.
          schema:
            example: >-
              eyJjcmVhdGVkX3RpbWUiOiIyMDI0LTExLTE1VDEwOjAwOjAwLjAwMFoiLCJpZCI6InBhZ2VfYWJjMTIzIn0=
            type: string
        - name: filter
          required: true
          in: query
          description: 'Required exact filter. Supported field: `parties.document`.'
          schema:
            example: parties.document:"61969404000182"
            type: string
      responses:
        '200':
          description: Aggregated stats payload
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/LawsuitsStatsOutput'
        '400':
          description: Invalid filter or document
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetailsDto'
        '401':
          description: Unauthorized
components:
  schemas:
    LawsuitsStatsOutput:
      type: object
      properties:
        entityType:
          type: string
          enum:
            - company
            - person
        document:
          type: string
        total:
          type: number
          description: Total lawsuits matching the requested document.
        totalValue:
          type: number
          nullable: true
          description: Sum of every materialized cause value across all matching lawsuits.
        statusDistribution:
          $ref: '#/components/schemas/LawsuitsStatusDistributionOutput'
        topSubjects:
          type: array
          items:
            $ref: '#/components/schemas/LawsuitsSubjectStatOutput'
        states:
          type: array
          items:
            $ref: '#/components/schemas/LawsuitsStateStatOutput'
        relatedParties:
          type: array
          items:
            $ref: '#/components/schemas/LawsuitsRelatedPartyStatOutput'
        byYear:
          type: array
          items:
            $ref: '#/components/schemas/LawsuitsYearStatOutput'
      required:
        - entityType
        - document
        - total
        - statusDistribution
        - topSubjects
        - states
        - relatedParties
        - byYear
    ProblemDetailsDto:
      type: object
      properties:
        type:
          type: string
          example: about:blank
        title:
          type: string
          example: Not Found
        status:
          type: number
          example: 404
        detail:
          type: string
          example: Protests not found for document
        instance:
          type: string
          example: /v2/entities/61969404000182/protests
        request_id:
          type: string
          example: req_123
      required:
        - type
        - title
        - status
        - detail
        - instance
        - request_id
    LawsuitsStatusDistributionOutput:
      type: object
      properties:
        active:
          type: number
          description: Lawsuits classified as in progress.
        inactive:
          type: number
          description: Lawsuits classified as concluded/closed.
        other:
          type: number
          description: Lawsuits that could not be classified (suspended, unknown, missing).
      required:
        - active
        - inactive
        - other
    LawsuitsSubjectStatOutput:
      type: object
      properties:
        subject:
          type: string
        count:
          type: number
        totalValue:
          type: number
          nullable: true
      required:
        - subject
        - count
    LawsuitsStateStatOutput:
      type: object
      properties:
        state:
          type: string
          description: UF code, e.g. "MT".
        stateName:
          type: string
          description: Full state name, e.g. "Mato Grosso".
        count:
          type: number
      required:
        - state
        - stateName
        - count
    LawsuitsRelatedPartyStatOutput:
      type: object
      properties:
        name:
          type: string
        count:
          type: number
      required:
        - name
        - count
    LawsuitsYearStatOutput:
      type: object
      properties:
        year:
          type: number
        count:
          type: number
      required:
        - year
        - count
  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

````