---
title: "get sales analytics"
method: GET
path: "/api/v1/sales/analytics"
tags: ["sales"]
---

# get sales analytics

`GET /api/v1/sales/analytics`

## Request

- Base URL: `https://api.app.tightly.io`
- URL: `https://api.app.tightly.io/api/v1/sales/analytics`
- Auth: HTTP bearer

Revenue trend and period-over-period comparison, grouped: each group carries `revenue_total` and `revenue_monthly` keyed by month, with `Overall` beside the groups.

`start_date` and `end_date` are required unless `in_fiscal_year` is sent, which takes `this` or `last` as a shorthand for the organisation's own fiscal year. `categories` narrows the groups and `fields` narrows the measures returned.

A key issued to one account is refused with `account_mismatch`: this read covers every account on the book. That account's own sales are at `GET /sales/table`.

Scope: `sales:read`.

## Query parameters

- `in_fiscal_year` string
- `start_date` string, date, required
- `end_date` string, date, required
- `categories` string
- `fields` string
- `is_sample` boolean

## Headers

- `Tightly-Version` string

## Response `200`

The sales analytics metrics

- object
  - `data` object
  - `message` object: severity, service and desc.

## Other responses

- `400`: Bad Request - Invalid request parameters or validation errors
- `401`: No usable key: malformed, unknown, revoked, expired or stopped. One refusal covers all five, telling a caller which is which maps the surface for them. A request with no Authorization header at all is refused 400 before any key is looked for.
- `403`: The key may not reach this operation. `scope_missing` when the key does not hold Sales; `organization_mismatch` when the path names an organisation that is not the key's; `ip_not_allowed` when the caller's address is outside the key's allowlist; `account_mismatch` when the key is issued to one account, because this operation covers every account.
- `429`: The key has spent its allowance for this minute. 600 reads and 120 writes a minute, counted per key, refused calls included. `Retry-After` says how long to wait.
- `500`: Internal Server Error - Database connection or processing errors
- `503`: The database is briefly out of reach, which is what a failover or a full connection pool looks like from outside. Wait the seconds `Retry-After` names and send the request again. A read is safe to repeat. A write is not, because the connection was lost in the middle of it, so read the object back before sending it a second time. Branch on the status rather than on `code`, which is `POSTGRES_UNAVAILABLE` from one of the two seams that raise this and `SERVICE_UNAVAILABLE` from the other.

---

[API](https://skmtc.dev/tightly/apis/tightly-api.md) · [All operations](https://skmtc.dev/tightly/apis/tightly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tightly/apis/tightly-api/revisions/199f7eb35afb?raw)
