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

# Run a Report

> Run a report query: chart and summary figures plus a page of records.

Runs a report query and returns the summary behind the chart (a cell per view × segment, view and segment totals, the grand total) and a page of records. Rows are limited to the token's organization.

* Periods such as `last_week` are resolved in the `timezone` you send; weeks start on Monday.
* User filters accept `"me"` for the caller.
* An invalid query returns `422` naming the bad part (`detail.path`); a report that runs longer than 10 seconds returns `504`.

Requires a CRM read [scope](https://docs.anycrm.anyreach.ai/authentication.md#scopes).


## OpenAPI

````yaml POST /reports/run
openapi: 3.1.0
info:
  title: anycrm-api
  version: 0.0.1
servers: []
security: []
tags:
  - name: Customer Intelligence
    description: >-
      Company research and ICP-fit scoring — create a research run, track its
      progress, and read back scored companies as leads.
  - name: Outreach
    description: >-
      The cold-email sending infrastructure — domains and mailboxes, over
      Primeforge and Warmforge.
  - name: AnyCard
    description: >-
      Authenticated CRUD for AnyCard, the org's digital business-card /
      lead-capture product.
  - name: AnyCard Events
    description: >-
      Event-attribution analytics for AnyCard — which captured leads converted,
      broken down by source, owner, and deal.
  - name: AnyCard Share Links
    description: >-
      Unauthenticated endpoints reached by anyone who scans a QR code or opens a
      shared AnyCard link.
  - name: AI
    description: >-
      A streaming (SSE) AI chat endpoint with account-commit actions it can take
      on the caller's behalf, and the job that fills every deal and account tab
      of an org.
  - name: Analytics Assistant
    description: >-
      The natural-language analytics assistant — a guarded text-to-SQL loop
      (SSE) that answers ad-hoc questions over the org's CRM data as a
      least-privilege, read-only database role.
  - name: Account Readiness
    description: >-
      Account Readiness Profiles — AI-scored signals on whether an account is
      ready for outreach or expansion, computed via a Temporal workflow.
  - name: Integrations
    description: >-
      Pipedream Connect — issuing connect tokens and managing the org's
      connected third-party accounts.
  - name: Feedback
    description: >-
      User-submitted platform feedback (bug reports, feature requests) — global,
      not scoped to one organization.
  - name: Public Media
    description: >-
      Unauthenticated image reads for publicly-embeddable assets (card photos,
      inline email images) — allowlisted by key shape; everything else in the
      storage bucket stays private.
  - name: Service Health
    description: Service liveness.
paths:
  /reports/run:
    post:
      tags:
        - Reports
      summary: Run Report Query
      description: 'Run a report query: chart and summary figures plus a page of records.'
      operationId: run_report_query_reports_run_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunReportBody'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunReportOut'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    RunReportBody:
      properties:
        query:
          $ref: '#/components/schemas/ReportQuery'
        timezone:
          type: string
          title: Timezone
          description: Viewer's IANA timezone, e.g. Africa/Accra.
          default: UTC
        page:
          type: integer
          maximum: 99
          minimum: 0
          title: Page
          default: 0
        page_size:
          type: integer
          maximum: 200
          minimum: 1
          title: Page Size
          default: 50
        include_summary:
          type: boolean
          title: Include Summary
          description: >-
            False skips the chart figures (summary comes back empty), for
            paging, sorting or changing columns.
          default: true
      type: object
      required:
        - query
      title: RunReportBody
    RunReportOut:
      properties:
        period:
          anyOf:
            - $ref: '#/components/schemas/ResolvedPeriod'
            - type: 'null'
        summary:
          $ref: '#/components/schemas/ReportSummary'
        records:
          $ref: '#/components/schemas/ReportRecords'
        comparison:
          anyOf:
            - $ref: '#/components/schemas/ReportComparison'
            - type: 'null'
          description: The compared period's figures, when asked for.
      type: object
      required:
        - period
        - summary
        - records
      title: RunReportOut
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ReportQuery:
      properties:
        entity:
          type: string
          enum:
            - activities
            - deals
            - stage_changes
            - contacts
            - outreach
          title: Entity
        filters:
          items:
            $ref: '#/components/schemas/ReportFilter'
          type: array
          maxItems: 50
          title: Filters
          description: All must match.
        filter_groups:
          items:
            items:
              $ref: '#/components/schemas/ReportFilter'
            type: array
          type: array
          maxItems: 10
          title: Filter Groups
          description: >-
            More filter groups: a record matches `filters` OR any one group (a
            group's filters all match).
        any_filters:
          items:
            $ref: '#/components/schemas/ReportFilter'
          type: array
          maxItems: 50
          title: Any Filters
          description: At least one must match (when any are given).
        period:
          anyOf:
            - $ref: '#/components/schemas/ReportPeriod'
            - type: 'null'
        measure:
          $ref: '#/components/schemas/ReportMeasure'
        view_by:
          anyOf:
            - type: string
            - type: 'null'
          title: View By
        interval:
          anyOf:
            - type: string
              enum:
                - day
                - week
                - month
                - quarter
                - year
            - type: 'null'
          title: Interval
          description: Bucket for a date view_by (default month).
        segment_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Segment By
        chart:
          type: string
          enum:
            - column
            - bar
            - pie
            - number
            - funnel
          title: Chart
          default: column
        chart_sort:
          anyOf:
            - type: string
              enum:
                - value_desc
                - value_asc
                - label_asc
                - label_desc
            - type: 'null'
          title: Chart Sort
          description: Chart order; default is the field's own order.
        compare:
          anyOf:
            - type: string
              enum:
                - previous_period
                - previous_year
            - type: 'null'
          title: Compare
          description: Also run the period before, or a year earlier.
        columns:
          items:
            type: string
          type: array
          maxItems: 40
          title: Columns
        sort:
          items:
            $ref: '#/components/schemas/ReportSort'
          type: array
          maxItems: 5
          title: Sort
      type: object
      required:
        - entity
      title: ReportQuery
    ResolvedPeriod:
      properties:
        field:
          type: string
          title: Field
        start:
          type: string
          format: date
          title: Start
        end:
          type: string
          format: date
          title: End
          description: Inclusive.
      type: object
      required:
        - field
        - start
        - end
      title: ResolvedPeriod
    ReportSummary:
      properties:
        cells:
          items:
            $ref: '#/components/schemas/SummaryCell'
          type: array
          title: Cells
          description: One per view × segment combination.
        view_totals:
          items:
            $ref: '#/components/schemas/SummaryCell'
          type: array
          title: View Totals
        segment_totals:
          items:
            $ref: '#/components/schemas/SummaryCell'
          type: array
          title: Segment Totals
        total:
          type: number
          title: Total
        truncated:
          type: boolean
          title: Truncated
          description: 'Too many groups: the smallest cells are left out.'
          default: false
      type: object
      required:
        - cells
        - view_totals
        - segment_totals
        - total
      title: ReportSummary
    ReportRecords:
      properties:
        columns:
          items:
            type: string
          type: array
          title: Columns
        rows:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Rows
          description: Choice/user/ref cells are {value, label}; others plain.
        total:
          type: integer
          title: Total
      type: object
      required:
        - columns
        - rows
        - total
      title: ReportRecords
    ReportComparison:
      properties:
        period:
          $ref: '#/components/schemas/ResolvedPeriod'
        summary:
          $ref: '#/components/schemas/ReportSummary'
      type: object
      required:
        - period
        - summary
      title: ReportComparison
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ReportFilter:
      properties:
        field:
          type: string
          title: Field
          description: Field key from GET /reports/fields.
        op:
          type: string
          title: Op
          description: One of the field's operators.
        value:
          title: Value
          description: >-
            Scalar, list (in / not_in / between), or for "period" a {"range"} or
            {"start", "end"} object. User fields accept "me".
      type: object
      required:
        - field
        - op
      title: ReportFilter
    ReportPeriod:
      properties:
        range:
          anyOf:
            - type: string
            - type: 'null'
          title: Range
          description: Preset such as "last_week" or "this_quarter".
        start:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Start
          description: Custom start date.
        end:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: End
          description: Custom end date (inclusive).
        field:
          type: string
          title: Field
          description: The date field the period applies to.
      type: object
      required:
        - field
      title: ReportPeriod
    ReportMeasure:
      properties:
        agg:
          type: string
          enum:
            - count
            - sum
            - avg
            - count_distinct
          title: Agg
          default: count
        field:
          anyOf:
            - type: string
            - type: 'null'
          title: Field
          description: Field for sum / avg (numbers) or count_distinct (e.g. deal).
      type: object
      title: ReportMeasure
    ReportSort:
      properties:
        field:
          type: string
          title: Field
        dir:
          type: string
          enum:
            - asc
            - desc
          title: Dir
          default: desc
      type: object
      required:
        - field
      title: ReportSort
    SummaryCell:
      properties:
        view:
          anyOf:
            - $ref: '#/components/schemas/ReportGroup'
            - type: 'null'
        segment:
          anyOf:
            - $ref: '#/components/schemas/ReportGroup'
            - type: 'null'
        value:
          type: number
          title: Value
      type: object
      required:
        - value
      title: SummaryCell
    ReportGroup:
      properties:
        value:
          title: Value
        label:
          type: string
          title: Label
      type: object
      required:
        - value
        - label
      title: ReportGroup
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.