---
title: "Secondary Sales API — SpireStock REST API"
description: "List the sales distributors made to their retailers, filtered by distributor and sale day, and read the per-distributor totals under the same filters."
source: https://developers.spirestock.com/api-reference/secondary-sales
---

# Secondary Sales API

List the sales distributors made to their retailers, filtered by distributor and sale day, and read the per-distributor totals under the same filters.

Base URL: `https://api.spirestock.com/api/v1`. Every request needs an API key (`X-API-Key`) or a session token (`Authorization: Bearer`); see https://developers.spirestock.com/api-reference/auth.

## Endpoints

- [GET /secondary-sales](https://developers.spirestock.com/api-reference/secondary-sales#get-secondary-sales)
- [GET /secondary-sales/summary](https://developers.spirestock.com/api-reference/secondary-sales#get-secondary-sales-summary)

## GET /secondary-sales

Sales a distributor made to its retailers, newest sale day first with id as the tie-break.

Access: API key `read` scope; staff need Orders (8) — list.

Paged (page and limit): see https://developers.spirestock.com/api-reference#pagination.

**Parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `distributor_id` | number | no | One distributor; a value that is not a positive integer is 400 |
| `date_from` | string | no | First sale day, YYYY-MM-DD only |
| `date_to` | string | no | Last sale day (inclusive), YYYY-MM-DD only; a start after the end is 400 |
| `page` | number | no | Page number; junk or a value below 1 reads as 1 (default 1) |
| `limit` | number | no | Page size, default 20, max 100 (larger values are clamped) (default 20) |

**Example request**

```bash
curl "https://api.spirestock.com/api/v1/secondary-sales?distributor_id=1201&date_from=2024-06-01&date_to=2024-06-30" \
  -H "X-API-Key: YOUR_API_KEY"
```

**Example response**

```json
{
  "response_code": 200,
  "data": [
    {
      "id": 9,
      "organization_id": 6,
      "distributor_id": 1201,
      "distributor_name": "Demo Distributor A",
      "retailer_id": null,
      "retailer_name": "Retailer One",
      "retailer_store": "Store One",
      "product_variant_id": null,
      "product_variant_name": "Toned Milk 500 ml",
      "quantity": 10,
      "rate": 22,
      "amount": 220,
      "sale_date": "2024-06-10",
      "recorded_by": 1001,
      "createdAt": "2024-06-10T05:30:00.000Z",
      "updatedAt": "2024-06-10T05:30:00.000Z"
    }
  ],
  "pagination": {
    "total": 1,
    "page": 1,
    "limit": 20,
    "total_pages": 1
  }
}
```

## GET /secondary-sales/summary

Totals per distributor under the same filters as the list: sale_count, total_quantity and total_amount, highest amount first. Not paged. Field staff without the grant see only distributors allocated to their towns, or sales their reporting tree recorded. Cached 30 seconds.

Access: API key `read` scope; staff need Orders (8) — list (without it, only their own records).

**Parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `distributor_id` | number | no | One distributor; a value that is not a positive integer is 400 |
| `date_from` | string | no | First sale day, YYYY-MM-DD only |
| `date_to` | string | no | Last sale day (inclusive), YYYY-MM-DD only; a start after the end is 400 |

**Example request**

```bash
curl "https://api.spirestock.com/api/v1/secondary-sales/summary?date_from=2024-06-01&date_to=2024-06-30" \
  -H "X-API-Key: YOUR_API_KEY"
```

**Example response**

```json
{
  "response_code": 200,
  "data": [
    {
      "distributor_id": 1201,
      "distributor_name": "Demo Distributor A",
      "sale_count": 2,
      "total_quantity": 14,
      "total_amount": 360
    },
    {
      "distributor_id": 1202,
      "distributor_name": "Demo Distributor B",
      "sale_count": 1,
      "total_quantity": 6,
      "total_amount": 132
    }
  ]
}
```
