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

# Top Affiliates Involved

> Retrieve a list of top affiliates involved in incidents within a specified date range.

# Top Affiliates Involved

Retrieve aggregated data showing which affiliates were involved in incidents during the selected date range.

## Endpoint

`GET /hubspot/stats/top-affiliates-involved/:startDate/:endDate`

### URL Parameters

| Parameter   | Type   | Required | Description                          |
| ----------- | ------ | -------- | ------------------------------------ |
| `startDate` | string | ✅        | Start date of the range (YYYY-MM-DD) |
| `endDate`   | string | ✅        | End date of the range (YYYY-MM-DD)   |

### Request Headers

| Header          | Value            | Description               |
| --------------- | ---------------- | ------------------------- |
| `Authorization` | `Bearer <token>` | User authentication token |

> **Note:** No request body is required.

## Response

### Success Response (HTTP 200)

```json theme={null}
{
  "message": "",
  "data": {
    "affiliates": []
  }
}
```

* `affiliates`: An array of affiliates involved in incidents during the date range.

### Error Response (HTTP 400–500)

```json theme={null}
{
  "message": "Invalid params",
  "data": {}
}
```

> Any non-200 status code represents an error.

## Authentication

This endpoint requires a valid authentication token via the `Authorization` header.

## Example Request (cURL)

```bash theme={null}
curl -X GET "https://yourdomain.com/hubspot/stats/top-affiliates-involved/2025-11-01/2025-11-15" \
-H "Authorization: Bearer YOUR_TOKEN"
```

## Example Request (JavaScript - fetch)

```javascript theme={null}
const response = await fetch(
  "/hubspot/stats/top-affiliates-involved/2025-11-01/2025-11-15",
  {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_TOKEN"
    }
  }
);

const data = await response.json();
console.log(data);
```

## Notes

* The endpoint returns an empty array when no affiliates are found.
* Date format must be `YYYY-MM-DD`.
* Success is based solely on HTTP status code.
