---
title: "Get the Sales By Company report"
method: GET
path: "/public/v1/reports/sales-by-company"
tags: ["SalesByCompany"]
---

# Get the Sales By Company report

`GET /public/v1/reports/sales-by-company`

## Request

- Base URL: `https://app.distru.com`
- URL: `https://app.distru.com/public/v1/reports/sales-by-company`
- Auth: HTTP bearer

Returns one row per customer with its last order date, order count, total received (payments applied to the customer's orders) and total sales (order totals net of returns) over the reported date range. A customer only appears when it has at least one order matching every active filter inside the range — customers with no qualifying order in the window are omitted entirely, so an empty `data` array is a valid result.

This is a read-only report and has no side effects. It does not touch inventory, compliance (Metrc/BioTrack), or any other entity — it only aggregates existing orders, payments and returns.

Date handling:
• When no `order_datetime` filter is provided, the range defaults to the last 30 days (from the start of the day 30 days ago through the end of today).
• The range and all dates are resolved in the API user's own timezone, so day boundaries follow that timezone rather than UTC.

Status handling:
• When `status` is omitted, every status except `CANCELED` is counted.
• Canceled orders are only counted when the `status` filter explicitly includes `CANCELED`.

Row ordering:
• The report does not accept a sort parameter. By default rows are returned by `total_sales` descending (highest-selling customer first).
• When `search` is supplied, rows are instead ordered by how closely the customer's name matches the search term.

Every value is returned as it appears in the report's CSV export, with numeric cells returned as strings (currency and percent formatting stripped), matching the rest of the API. Any custom fields configured on the customer relationship are appended as extra columns keyed by their slugified label; those keys are per-company and are also listed in `meta.columns`. Report-level information (the resolved date range and column definitions) is returned under `meta`.

Each row also carries the IDs of the records it names — `customer_id` and `customer_owner_id`, each right after its name column — so a row can be followed to the company or user endpoints without a name lookup. The CSV export leaves these ID columns out.

Requires the "view the sales by company report" permission on the API key.

## Query parameters

- `status` string[]
- `order_datetime` string
- `search` string
- `company_relationship_group_ids` string[]
- `owner_ids` string[]

## Response `200`

The Sales By Company report

- SalesByCompanyReport: The Sales By Company report
  - `data` SalesByCompanyReportRow[], required: The report rows
    - `category` string: The customer's category, or null when unset.
    - `customer_id` string, required: The customer's company ID — the `id` [GET /public/v1/companies](#get-companies) returns.
    - `customer_owner_id` string: The ID of the sales rep assigned to this customer — the `id` [GET /public/v1/users](#get-users) returns — or null when no owner is assigned.
    - `last_order_date` string, required: The date of the customer's most recent order, formatted `MM/DD/YYYY` in the API user's timezone. This is the latest order of any status and may fall outside the reported date range.
    - `name` string, required: The customer's company name
    - `order_count` string, required: The number of the customer's orders counted under the active filters (status and date range). Always at least 1, since only customers with a qualifying order appear.
    - `owner` string: The full name of the sales rep assigned to this customer, or null when no owner is assigned.
    - `relationship_type` string: The name of the customer's relationship type, or null when none is assigned.
    - `total_received` string, required: The sum of payments applied to the customer's counted orders, as a currency amount.
    - `total_sales` string, required: The sum of the counted orders' totals minus any returns against them. Can be negative when returns exceed order totals.
  - `meta` SalesByCompanyReportMeta, required: Report-level metadata
    - `columns` SalesByCompanyReportColumn[], required: The report's column definitions in order, including any custom-field columns appended for this company. The `key` of each entry matches the property name used in every `data` row.
      - `key` string, required: The key used for this column in each data row
      - `label` string, required: The human-readable label of the column
    - `date_range` string, required: The human-readable resolved date range the report covers (in the API user's timezone), reflecting the default 30-day window when no `order_datetime` filter was supplied.
    - `report` string, required: The report identifier, always `sales_by_company`

## Other responses

- `400`: Invalid parameters
- `401`: Missing or invalid API token
- `403`: The API token lacks the required permission, or team restrictions hide the record

## Changes

- **2026-10-07** `e8639f7dafed`: 2 info
  - added the optional property `data/items/customer_owner_id` to the response with the `200` status
  - added the required property `data/items/customer_id` to the response with the `200` status

[Operation history](https://skmtc.dev/distru/apis/distru-api/changes/public/v1/reports/sales-by-company/get.md)

---

[API](https://skmtc.dev/distru/apis/distru-api.md) - [All operations](https://skmtc.dev/distru/apis/distru-api/llms.txt) - [OpenAPI document](https://skmtc.dev/distru/apis/distru-api/revisions/9d851a88e82f?raw)
