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

# Agregar

> Contagens e taxas sobre todos os clientes, com pseudônimo por padrão.



## OpenAPI

````yaml openapi/pt/cell.json POST /v1/insights/aggregate
openapi: 3.1.0
info:
  title: API de dados da Niadra
  version: '1'
  description: >-
    Escrita, contexto, histórico, objetos, identidade, privacidade e governança
    de um espaço. Cada espaço tem um endereço estável, com o espaço e a região
    no nome.
servers:
  - url: https://{space}.{region}.api.niadra.com
    variables:
      space:
        default: acme-prod
        description: O espaço, que vem na chave de fonte.
      region:
        default: us-east-1
        description: A região do espaço, que também vem na chave.
security: []
paths:
  /v1/insights/aggregate:
    post:
      summary: Agregar
      description: >-
        Contagens e taxas sobre todos os clientes do espaço: escolha uma
        entidade, um período, filtros, dimensões e métricas (`count`,
        `profiles`, `avg_sentiment`). Grupos menores que o tamanho mínimo são
        suprimidos, nunca mostrados, e cada consulta deixa um comprovante
        analítico.


        **Autenticação.** Chave de fonte com o escopo `analytics`, ou token de
        pessoa do Console com o papel analysis (ou admin). Pessoas do papel
        vendor não acessam.
      operationId: aggregate_v1_insights_aggregate_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AggregateRequest'
            example:
              entity: episodes
              since: '2026-06-24T00:00:00Z'
              until: '2026-09-22T23:59:59Z'
              filters:
                intent:
                  - complaint
              group_by:
                - normalized_category
                - channel
              metrics:
                - count
                - profiles
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregateResponse'
              example:
                min_group_size: 10
                suppressed_groups: 3
                rows:
                  - group:
                      normalized_category: technician_visit
                      channel: voice
                    count: 1204
                    profiles: 1030
                    avg_sentiment: null
                  - group:
                      normalized_category: technician_visit
                      channel: whatsapp
                    count: 636
                    profiles: 588
                    avg_sentiment: null
          description: Uma linha por grupo, com os grupos suprimidos contados à parte.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: O pedido não bate com o contrato.
      security:
        - sourceKey: []
components:
  schemas:
    AggregateRequest:
      additionalProperties: false
      properties:
        entity:
          description: >-
            `episodes`, `open_items`, `traits`, `actions`, `objects` ou
            `profiles`.
          title: Entity
          type: string
        filters:
          additionalProperties:
            items:
              maxLength: 200
              type: string
            type: array
          title: Filters
          type: object
        group_by:
          items:
            type: string
          maxItems: 3
          title: Group By
          type: array
        metrics:
          items:
            type: string
          maxItems: 3
          title: Metrics
          type: array
        since:
          format: date-time
          title: Since
          type: string
        until:
          format: date-time
          title: Until
          type: string
      required:
        - since
        - until
        - entity
      title: AggregateRequest
      type: object
    AggregateResponse:
      additionalProperties: false
      properties:
        min_group_size:
          title: Min Group Size
          type: integer
        rows:
          items:
            $ref: '#/components/schemas/AggregateRowOut'
          title: Rows
          type: array
        suppressed_groups:
          description: Grupos abaixo do tamanho mínimo, retidos.
          title: Suppressed Groups
          type: integer
      required:
        - rows
        - suppressed_groups
        - min_group_size
      title: AggregateResponse
      type: object
    Problem:
      additionalProperties: false
      description: >-
        Detalhes do problema no formato da RFC 9457; `code` vem do catálogo de
        erros versionado.
      properties:
        code:
          title: Code
          type: string
        detail:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Detail
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Request Id
        status:
          title: Status
          type: integer
        title:
          title: Title
          type: string
        type:
          default: about:blank
          title: Type
          type: string
      required:
        - title
        - status
        - code
      title: Problem
      type: object
    AggregateRowOut:
      additionalProperties: false
      properties:
        avg_sentiment:
          anyOf:
            - type: number
            - type: 'null'
          title: Avg Sentiment
        count:
          title: Count
          type: integer
        group:
          additionalProperties:
            anyOf:
              - type: string
              - type: 'null'
          title: Group
          type: object
        profiles:
          anyOf:
            - type: integer
            - type: 'null'
          title: Profiles
      required:
        - group
        - count
      title: AggregateRowOut
      type: object
  securitySchemes:
    sourceKey:
      type: http
      scheme: bearer
      description: nia_sk_...

````