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

# documents.count

> Count documents and aggregate data. Use for spending totals and financial analysis. Supports grouping by merchant, category, date, etc. Gets ALL matching documents.



## OpenAPI

````yaml https://developer.api.receiptor.ai/openapi.json post /capabilities/documents.count
openapi: 3.0.0
info:
  title: Receiptor AI API
  description: >-
    API for Receiptor AI — automates financial document extraction,
    categorization, and integration with accounting systems. All capabilities
    are available via `POST /v1/capabilities/{slug}` with a JSON request body.
  version: 1.0.0
  contact:
    name: Receiptor AI
    url: https://receiptor.ai
    email: info@receiptor.ai
servers:
  - url: https://developer.api.receiptor.ai/v1
    description: Production
security: []
tags:
  - name: Capabilities
    description: Execute product capabilities
  - name: Discovery
    description: Discover available capabilities
  - name: OAuth2
    description: OAuth 2.0 authorization flow
paths:
  /capabilities/documents.count:
    post:
      tags:
        - Capabilities
      summary: documents.count
      description: >-
        Count documents and aggregate data. Use for spending totals and
        financial analysis. Supports grouping by merchant, category, date, etc.
        Gets ALL matching documents.
      operationId: documents.count
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                where:
                  type: object
                  properties:
                    logic:
                      type: string
                      enum:
                        - and
                        - or
                      default: and
                    conditions:
                      type: array
                      items:
                        type: object
                        properties:
                          field:
                            type: string
                            enum:
                              - amount
                              - docDate
                              - merchant
                              - category
                              - docType
                              - invoiceId
                              - receiptId
                              - preferredCurrency
                              - currency
                              - paymentMethod
                              - paymentMethodEnding
                              - fromEmail
                              - toEmail
                              - summary
                              - taxAmount
                              - subtotal
                              - isRecurring
                              - recurringType
                          op:
                            type: string
                            enum:
                              - eq
                              - ne
                              - gt
                              - gte
                              - lt
                              - lte
                              - in
                              - nin
                              - regex
                              - exists
                          value: {}
                        required:
                          - field
                          - op
                        additionalProperties: false
                      minItems: 1
                  required:
                    - conditions
                  additionalProperties: false
                  description: >-
                    Typed filter clause. Allowed fields: amount, docDate,
                    merchant, category, docType, invoiceId, receiptId,
                    preferredCurrency, currency, paymentMethod,
                    paymentMethodEnding, fromEmail, toEmail, summary, taxAmount,
                    subtotal, isRecurring, recurringType. Allowed ops: eq, ne,
                    gt, gte, lt, lte, in, nin, regex, exists.
                archived:
                  type: string
                  enum:
                    - exclude
                    - only
                    - include
                  default: exclude
                  description: >-
                    Archive filter: exclude (default, active docs), only
                    (archived docs), include (both).
                groupBy:
                  type: string
                  description: Aggregation key (e.g., merchant, category, date)
              additionalProperties: false
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  code:
                    type: integer
                    example: 200
                  data:
                    type: object
                    properties:
                      result:
                        type: object
                        description: Capability-specific result
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
      security:
        - apiKey: []
components:
  responses:
    BadRequest:
      description: Invalid input
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              code:
                type: integer
                example: 400
              error:
                type: object
                properties:
                  errorCode:
                    type: integer
                    example: 400
                  errorMessage:
                    type: string
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              code:
                type: integer
                example: 401
              error:
                type: object
                properties:
                  errorCode:
                    type: integer
                    example: 401
                  errorMessage:
                    type: string
                    example: API key authentication required
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              code:
                type: integer
                example: 404
              error:
                type: object
                properties:
                  errorCode:
                    type: integer
                    example: 404
                  errorMessage:
                    type: string
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: API key prefixed with `sk_`. Obtain from the Receiptor AI dashboard.

````