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

# Run Report

> Run a leads, traffic, ads or calls report with POST /api/reports/{source}: metrics, breakdowns, filters, date ranges and period comparison, computed like the Octanist dashboards.

Run a report for BI tools, spreadsheets or your own dashboards. The numbers are computed like the dashboards in the app, and the query body is the same as the `run_*_report` tools of the [MCP server](https://octanist.com/docs/api-reference/mcp.md).

| Path | Report |
| - | - |
| `POST /api/reports/leads` | Leads, qualified and won leads, value, ad spend, cost per lead and ROAS, like the Performance dashboard. Leads are credited to channels with the organization's [attribution model](https://octanist.com/docs/settings/attribution.md). |
| `POST /api/reports/traffic` | Website visits, visitors, page views and conversion rate, like the Acquisition tab |
| `POST /api/reports/ads` | Spend, clicks, impressions, CTR and CPC as the ad platforms report them |
| `POST /api/reports/calls` | Calls, missed calls and call leads. Needs [call tracking](https://octanist.com/docs/incoming-integrations/call-tracking.md). |

Reports need an active Octanist plan. Read-only API keys can run reports.

Call [`GET /api/reports`](https://octanist.com/docs/api-reference/endpoint/report-options) first for the metric ids, channel ids and date range presets.

## Path Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `source` | string | Yes | `leads`, `traffic`, `ads` or `calls` |

## Request Body

Fields for every report:

| Field | Type | Required | Description |
| - | - | - | - |
| `metrics` | string\[] | Yes | 1 to 4 metric ids of this report, most important first |
| `breakdown` | string | Yes | `none` for totals, `date` for a time series, or a dimension. See [Breakdowns](#breakdowns). |
| `dateRange` | object | Yes | `{ "preset": "last30days" }`, or `{ "startDate": "2026-01-01", "endDate": "2026-01-31" }` with dates in `YYYY-MM-DD`. Presets are resolved in the organization's timezone each time the report runs. |
| `interval` | string | No | Bucket size for the `date` breakdown: `auto` (default), `day`, `week`, `month`, `quarter` or `year` |
| `compareTo` | string | No | `none` (default), `previous_period`, `previous_month` (same days last month) or `previous_year` (same period last year) |
| `limit` | integer | No | Maximum rows for a dimension breakdown, 1 to 25 (default 10) |
| `splitBy` | string | No | Leads, ads and calls only. With `breakdown: "date"`: one series per value of this dimension (the top values, the rest as "Other"). Uses the first metric only and does not compare periods. |
| `filters` | object | No | Per report, see [Filters](#filters) |

Lead reports also take `breakdownKey`: the custom field key for the `custom_field` breakdown or split.

### Breakdowns

| Report | Breakdowns |
| - | - |
| `leads` | `none`, `date`, `channel`, `source`, `medium`, `campaign`, `source_medium`, `source_medium_campaign`, `ad_campaign`, `status`, `label`, `form`, `created_via`, `visit_country`, `device`, `browser`, `os`, `landing_domain`, `landing_path`, `referrer_host`, `utm_source`, `utm_medium`, `utm_campaign`, `phone_country`, `lost_reason`, `custom_field`, `weekday`, `hour`, `weekday_hour` |
| `traffic` | `none`, `date`, `channel`, `referrer`, `landing_page`, `page`, `utm_source`, `utm_medium`, `utm_campaign`, `domain`, `device`, `country`, `browser` |
| `ads` | `none`, `date`, `platform`, `account`, `campaign`, `ad_group` |
| `calls` | `none`, `date`, `call_status`, `channel`, `utm_source`, `utm_campaign`, `landing_page`, `weekday`, `hour`, `weekday_hour` |

`channel`, `source`, `medium`, `campaign`, `source_medium` and `source_medium_campaign` on lead reports credit leads with the attribution model. `ad_campaign` shows ad platform campaigns with their spend, for cost per lead per campaign.

`splitBy` takes the dimensions of the same report, without `date`, `weekday`, `hour` and `weekday_hour`. Traffic reports cannot be split.

### Filters

**Leads**

| Field | Type | Description |
| - | - | - |
| `channels` | string\[] | Channel ids. Leads credited to one of them. |
| `leadStatuses` | string\[] | `open`, `qualified`, `won`, `lost` |
| `labelIds` | string\[] | Label IDs from [`GET /api/workspace`](https://octanist.com/docs/api-reference/endpoint/workspace) |
| `formIdentifiers` | string\[] | Form identifiers from `GET /api/workspace`. Leads submitted through one of these forms. |
| `conditions` | array | Up to 10 conditions on the lead and the visit it converted on. All must hold. They narrow the leads only; ad spend is never filtered by them. |
| `customFields` | array | Up to 10 conditions on custom fields: `{ "key": "budget", "op": "eq", "value": "high" }` with `op` `eq`, `neq`, `contains` or `exists` |

A condition is `{ "field": "visit_country", "op": "is", "values": ["NL", "BE"] }`. `op` is `is_set` or `is_not_set` (no values), `is` or `is_not` (matches any of the values, case-insensitive), or `contains` (one value). The fields are listed in [`GET /api/reports`](https://octanist.com/docs/api-reference/endpoint/report-options).

**Traffic**

| Field | Type | Description |
| - | - | - |
| `channels` | string\[] | Channel ids |
| `domain` | string | Only visits to this website domain |

**Ads**

| Field | Type | Description |
| - | - | - |
| `platforms` | string\[] | `googleads`, `meta`, `microsoftads`, `linkedin`, `tiktok`, `snapchat`, `x`, `reddit`, `pinterest` |
| `campaignContains` | string | Only campaigns whose name contains this text |

Calls reports have no filters.

## Example Request

Won leads and cost per lead per channel for last month, compared with the month before:

```bash theme={null}
curl -X POST \
  -H "X-API-KEY: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "metrics": ["total_leads", "won_leads", "cpl"],
    "breakdown": "channel",
    "dateRange": { "preset": "lastMonth" },
    "compareTo": "previous_period",
    "filters": {
      "conditions": [
        { "field": "visit_country", "op": "is", "values": ["NL"] }
      ]
    }
  }' \
  "https://octanist.com/api/reports/leads"
```

## Example Response

```json theme={null}
{
  "success": true,
  "data": {
    "query": {
      "source": "leads",
      "metrics": ["total_leads", "won_leads", "cpl"],
      "breakdown": "channel",
      "dateRange": { "preset": "lastMonth" },
      "compareTo": "previous_period",
      "filters": {
        "conditions": [
          { "field": "visit_country", "op": "is", "values": ["NL"] }
        ]
      }
    },
    "startDate": "2026-02-01",
    "endDate": "2026-02-28",
    "interval": "week",
    "currency": "EUR",
    "hasExtraCosts": false,
    "totals": { "total_leads": 184, "won_leads": 31, "cpl": 42.5 },
    "rows": [
      {
        "key": "google",
        "label": "Google Ads",
        "values": { "total_leads": 102, "won_leads": 19, "cpl": 38.2 },
        "previous": { "total_leads": 95, "won_leads": 15, "cpl": 41.0 }
      },
      {
        "key": "organic",
        "label": "Organic / Direct",
        "values": { "total_leads": 82, "won_leads": 12, "cpl": null },
        "previous": { "total_leads": 77, "won_leads": 10, "cpl": null }
      }
    ],
    "omittedRows": 0,
    "previous": {
      "startDate": "2026-01-04",
      "endDate": "2026-01-31",
      "totals": { "total_leads": 172, "won_leads": 25, "cpl": 44.9 }
    }
  },
  "meta": {
    "requestId": "req_a1b2c3d4e5f6",
    "timestamp": "2026-03-10T12:00:00.000Z"
  }
}
```

## Response Fields

| Field | Type | Description |
| - | - | - |
| `query` | object | The query as it was run, including `source` |
| `startDate`, `endDate` | string | The resolved date range (`YYYY-MM-DD`) |
| `interval` | string | Bucket size used for dates |
| `currency` | string | Currency of money metrics |
| `hasExtraCosts` | boolean | Whether extra costs are included in cost metrics |
| `totals` | object | Each metric over the whole range. `null` when a metric cannot be computed, for example cost per lead without spend. |
| `rows` | array | One row per date bucket or dimension value, with `key`, `label` and `values`. With `compareTo`, also `previous`. With `splitBy`, also `split`. |
| `omittedRows` | integer | Dimension rows left out because of `limit` |
| `previous` | object | With `compareTo`: the comparison range and its `totals` |
| `trend` | array | With `breakdown: "none"`: values per interval, for sparklines. Left out when there would be fewer than two points. |
| `series` | array | With `splitBy`: the series with `key`, `label` and `total`, biggest first, "Other" last |
| `notes` | string\[] | Caveats about the numbers, for example that ad spend cannot be split by the chosen breakdown. Left out when there are none. Show them to the reader when they matter. |

Rates such as `qualify_rate` and `win_rate` are percentages (0 to 100). Money metrics are in `currency`.

## Error Responses

| Status | Code | Description |
| - | - | - |
| 400 | `VALIDATION_ERROR` | Invalid JSON, or an invalid query: an unknown metric or breakdown for this report, a bad date range, or the `custom_field` breakdown without `breakdownKey`. `details.errors` lists the problems. |
| 401 | `UNAUTHORIZED` | Missing or invalid API key |
| 403 | `FORBIDDEN` | The organization has no active plan, or call tracking is off (calls report) |
| 404 | `NOT_FOUND` | `source` is not `leads`, `traffic`, `ads` or `calls` |
| 500 | `INTERNAL_ERROR` | Server error |


## OpenAPI

````yaml POST /api/reports/{source}
openapi: 3.0.1
info:
  title: Octanist API
  description: >-
    The Octanist API allows you to create, update and read leads, run reports,
    read workspace settings, retrieve statistics, and access ad spend data.
  version: 2.5.0
  contact:
    name: Octanist Support
    url: https://octanist.com/docs
servers:
  - url: https://octanist.com
    description: Production server
security:
  - apiKeyAuth: []
paths:
  /api/reports/{source}:
    post:
      tags:
        - Reports
      summary: Run Report
      description: >-
        Run a leads, traffic, ads or calls report, computed like the dashboards.
        The body is the query for that report. Needs an active plan; the calls
        report needs call tracking.
      parameters:
        - name: source
          in: path
          required: true
          description: Which report to run
          schema:
            type: string
            enum:
              - leads
              - traffic
              - ads
              - calls
            example: leads
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/LeadReportQuery'
                - $ref: '#/components/schemas/TrafficReportQuery'
                - $ref: '#/components/schemas/AdsReportQuery'
                - $ref: '#/components/schemas/CallReportQuery'
            example:
              metrics:
                - total_leads
                - won_leads
                - cpl
              breakdown: channel
              dateRange:
                preset: lastMonth
              compareTo: previous_period
      responses:
        '200':
          description: Report result
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/ReportResult'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: >-
            Invalid JSON or an invalid report query; details.errors lists the
            problems
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            The organization has no active plan, or call tracking is off (calls
            report)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Unknown report source
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    LeadReportQuery:
      type: object
      title: leads
      required:
        - metrics
        - breakdown
        - dateRange
      properties:
        metrics:
          type: array
          items:
            type: string
            enum:
              - total_leads
              - open_leads
              - qualified_leads
              - won_leads
              - lost_leads
              - value_won
              - value_lost
              - avg_lead_value
              - total_spend
              - extra_costs
              - total_cost
              - cpl
              - cpql
              - cpwl
              - cpc
              - qualify_rate
              - win_rate
              - close_rate
              - ctr
              - clicks
              - impressions
              - roas
              - win_lose_ratio
          minItems: 1
          maxItems: 4
          description: Metric ids, most important first
          example:
            - total_leads
            - won_leads
            - cpl
        breakdown:
          type: string
          enum:
            - none
            - date
            - channel
            - source
            - medium
            - campaign
            - source_medium
            - source_medium_campaign
            - ad_campaign
            - status
            - label
            - form
            - created_via
            - visit_country
            - device
            - browser
            - os
            - landing_domain
            - landing_path
            - referrer_host
            - utm_source
            - utm_medium
            - utm_campaign
            - phone_country
            - lost_reason
            - custom_field
            - weekday
            - hour
            - weekday_hour
          example: channel
        breakdownKey:
          type: string
          maxLength: 200
          description: Custom field key, for the `custom_field` breakdown or split
        splitBy:
          type: string
          enum:
            - none
            - channel
            - source
            - medium
            - campaign
            - source_medium
            - source_medium_campaign
            - ad_campaign
            - status
            - label
            - form
            - created_via
            - visit_country
            - device
            - browser
            - os
            - landing_domain
            - landing_path
            - referrer_host
            - utm_source
            - utm_medium
            - utm_campaign
            - phone_country
            - lost_reason
            - custom_field
          description: >-
            Only with breakdown `date`: one series per value of this dimension
            (top values, the rest as "Other"). Uses the first metric only and
            does not compare periods.
        filters:
          type: object
          properties:
            channels:
              type: array
              items:
                type: string
              maxItems: 20
              description: Channel ids from GET /api/reports
            leadStatuses:
              type: array
              items:
                type: string
                enum:
                  - open
                  - qualified
                  - won
                  - lost
              maxItems: 4
            labelIds:
              type: array
              items:
                type: string
              maxItems: 20
            formIdentifiers:
              type: array
              items:
                type: string
              maxItems: 20
            conditions:
              type: array
              maxItems: 10
              description: >-
                Conditions on the lead and its converting visit; all must hold.
                They do not filter ad spend.
              items:
                type: object
                required:
                  - field
                  - op
                properties:
                  field:
                    type: string
                    enum:
                      - email
                      - phone
                      - phone_country
                      - name
                      - note
                      - created_via
                      - visit_country
                      - device
                      - browser
                      - os
                      - landing_domain
                      - landing_path
                      - referrer_host
                      - utm_source
                      - utm_medium
                      - utm_campaign
                  op:
                    type: string
                    enum:
                      - is_set
                      - is_not_set
                      - is
                      - is_not
                      - contains
                    description: >-
                      is_set / is_not_set need no values; is / is_not match any
                      of the values (case-insensitive); contains takes one value
                  values:
                    type: array
                    items:
                      type: string
                    maxItems: 20
            customFields:
              type: array
              maxItems: 10
              items:
                type: object
                required:
                  - key
                  - op
                  - value
                properties:
                  key:
                    type: string
                  op:
                    type: string
                    enum:
                      - eq
                      - neq
                      - contains
                      - exists
                  value:
                    type: string
        dateRange:
          $ref: '#/components/schemas/ReportDateRange'
        interval:
          type: string
          enum:
            - auto
            - day
            - week
            - month
            - quarter
            - year
          description: Bucket size for the `date` breakdown. Default `auto`.
        compareTo:
          type: string
          enum:
            - none
            - previous_period
            - previous_month
            - previous_year
          description: Earlier period to compute the same numbers for. Default `none`.
        limit:
          type: integer
          minimum: 1
          maximum: 25
          description: Maximum rows for a dimension breakdown (default 10)
    TrafficReportQuery:
      type: object
      title: traffic
      required:
        - metrics
        - breakdown
        - dateRange
      properties:
        metrics:
          type: array
          items:
            type: string
            enum:
              - sessions
              - visitors
              - pageviews
              - session_leads
              - session_qualified
              - session_won
              - session_revenue
              - session_conversion_rate
              - revenue_per_session
          minItems: 1
          maxItems: 4
          description: Metric ids, most important first
          example:
            - sessions
            - session_leads
        breakdown:
          type: string
          enum:
            - none
            - date
            - channel
            - referrer
            - landing_page
            - page
            - utm_source
            - utm_medium
            - utm_campaign
            - domain
            - device
            - country
            - browser
          example: channel
        filters:
          type: object
          properties:
            channels:
              type: array
              items:
                type: string
              maxItems: 20
            domain:
              type: string
              maxLength: 253
              description: Only visits to this website domain
        dateRange:
          $ref: '#/components/schemas/ReportDateRange'
        interval:
          type: string
          enum:
            - auto
            - day
            - week
            - month
            - quarter
            - year
          description: Bucket size for the `date` breakdown. Default `auto`.
        compareTo:
          type: string
          enum:
            - none
            - previous_period
            - previous_month
            - previous_year
          description: Earlier period to compute the same numbers for. Default `none`.
        limit:
          type: integer
          minimum: 1
          maximum: 25
          description: Maximum rows for a dimension breakdown (default 10)
    AdsReportQuery:
      type: object
      title: ads
      required:
        - metrics
        - breakdown
        - dateRange
      properties:
        metrics:
          type: array
          items:
            type: string
            enum:
              - ad_spend
              - ad_clicks
              - ad_impressions
              - ad_ctr
              - ad_cpc
              - platform_conversions
              - cost_per_platform_conversion
          minItems: 1
          maxItems: 4
          description: Metric ids, most important first
          example:
            - ad_spend
            - ad_clicks
        breakdown:
          type: string
          enum:
            - none
            - date
            - platform
            - account
            - campaign
            - ad_group
          example: campaign
        splitBy:
          type: string
          enum:
            - none
            - platform
            - account
            - campaign
            - ad_group
          description: >-
            Only with breakdown `date`: one series per value of this dimension
            (top values, the rest as "Other"). Uses the first metric only and
            does not compare periods.
        filters:
          type: object
          properties:
            platforms:
              type: array
              items:
                type: string
                enum:
                  - googleads
                  - meta
                  - microsoftads
                  - linkedin
                  - tiktok
                  - snapchat
                  - x
                  - reddit
                  - pinterest
            campaignContains:
              type: string
              maxLength: 200
              description: Only campaigns whose name contains this text
        dateRange:
          $ref: '#/components/schemas/ReportDateRange'
        interval:
          type: string
          enum:
            - auto
            - day
            - week
            - month
            - quarter
            - year
          description: Bucket size for the `date` breakdown. Default `auto`.
        compareTo:
          type: string
          enum:
            - none
            - previous_period
            - previous_month
            - previous_year
          description: Earlier period to compute the same numbers for. Default `none`.
        limit:
          type: integer
          minimum: 1
          maximum: 25
          description: Maximum rows for a dimension breakdown (default 10)
    CallReportQuery:
      type: object
      title: calls
      required:
        - metrics
        - breakdown
        - dateRange
      properties:
        metrics:
          type: array
          items:
            type: string
            enum:
              - calls
              - answered_calls
              - missed_calls
              - missed_call_rate
              - avg_call_duration
              - call_leads
              - call_to_lead_rate
          minItems: 1
          maxItems: 4
          description: Metric ids, most important first
          example:
            - calls
            - missed_calls
        breakdown:
          type: string
          enum:
            - none
            - date
            - call_status
            - channel
            - utm_source
            - utm_campaign
            - landing_page
            - weekday
            - hour
            - weekday_hour
          example: date
        splitBy:
          type: string
          enum:
            - none
            - call_status
            - channel
            - utm_source
            - utm_campaign
            - landing_page
          description: >-
            Only with breakdown `date`: one series per value of this dimension
            (top values, the rest as "Other"). Uses the first metric only and
            does not compare periods.
        dateRange:
          $ref: '#/components/schemas/ReportDateRange'
        interval:
          type: string
          enum:
            - auto
            - day
            - week
            - month
            - quarter
            - year
          description: Bucket size for the `date` breakdown. Default `auto`.
        compareTo:
          type: string
          enum:
            - none
            - previous_period
            - previous_month
            - previous_year
          description: Earlier period to compute the same numbers for. Default `none`.
        limit:
          type: integer
          minimum: 1
          maximum: 25
          description: Maximum rows for a dimension breakdown (default 10)
    ReportResult:
      type: object
      properties:
        query:
          type: object
          description: The query as it was run, including `source`
        startDate:
          type: string
          format: date
        endDate:
          type: string
          format: date
        interval:
          type: string
          enum:
            - day
            - week
            - month
            - quarter
            - year
        currency:
          type: string
          example: EUR
        hasExtraCosts:
          type: boolean
        totals:
          type: object
          additionalProperties:
            type: number
            nullable: true
          description: >-
            Metric id to value; null when it cannot be computed. Rates are
            percentages (0 to 100).
        rows:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              label:
                type: string
              values:
                type: object
                additionalProperties:
                  type: number
                  nullable: true
                description: >-
                  Metric id to value; null when it cannot be computed. Rates are
                  percentages (0 to 100).
              previous:
                type: object
                additionalProperties:
                  type: number
                  nullable: true
                description: 'With compareTo: the same row in the comparison period'
              split:
                type: object
                additionalProperties:
                  type: number
                  nullable: true
                description: 'With splitBy: the first metric per series key'
        omittedRows:
          type: integer
          description: Dimension rows left out because of the limit
        previous:
          type: object
          description: With compareTo
          properties:
            startDate:
              type: string
              format: date
            endDate:
              type: string
              format: date
            totals:
              type: object
              additionalProperties:
                type: number
                nullable: true
              description: >-
                Metric id to value; null when it cannot be computed. Rates are
                percentages (0 to 100).
        trend:
          type: array
          description: >-
            With breakdown `none`: values per interval, when there are at least
            two points
          items:
            type: object
            properties:
              key:
                type: string
                format: date
              values:
                type: object
                additionalProperties:
                  type: number
                  nullable: true
                description: >-
                  Metric id to value; null when it cannot be computed. Rates are
                  percentages (0 to 100).
        series:
          type: array
          description: 'With splitBy: the series, biggest first, "Other" last'
          items:
            type: object
            properties:
              key:
                type: string
              label:
                type: string
              total:
                type: number
                nullable: true
        notes:
          type: array
          items:
            type: string
          description: Caveats about the numbers
    Meta:
      type: object
      properties:
        requestId:
          type: string
          example: req_a1b2c3d4e5f6
        timestamp:
          type: string
          format: date-time
          example: '2026-03-10T12:00:00.000Z'
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code
              example: VALIDATION_ERROR
            message:
              type: string
              description: Human readable error message
              example: Human readable error message
            details:
              type: object
              description: Optional additional error details
        meta:
          $ref: '#/components/schemas/Meta'
    ReportDateRange:
      description: >-
        A preset, resolved in the organization timezone each time the report
        runs, or fixed dates (YYYY-MM-DD).
      oneOf:
        - type: object
          title: Preset
          required:
            - preset
          properties:
            preset:
              type: string
              enum:
                - today
                - yesterday
                - last7days
                - last14days
                - thisWeek
                - lastWeek
                - last30days
                - thisMonth
                - lastMonth
                - last90days
                - thisQuarter
                - lastQuarter
                - last180days
                - last365days
                - thisYear
                - lastYear
              example: last30days
        - type: object
          title: Fixed dates
          required:
            - startDate
            - endDate
          properties:
            startDate:
              type: string
              format: date
              example: '2026-01-01'
            endDate:
              type: string
              format: date
              example: '2026-01-31'
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: API key for authentication

````

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