# Total Revenue, Grouped

`POST https://api.suger.cloud/ai/org/{orgId}/revenue/record-aggregate`

Totals this organization's revenue in the database and returns the grouped amounts, answering "how much" in one call and without summing rows page by page. Narrow with any of partner, productId, entitlementId, buyerId and currency, and bound it with startDate and endDate (YYYY-MM-DD, at most 7305 days apart). Without a startDate it covers only the 30 days before endDate, which defaults to today, so pass both dates for any longer total. Reads only: it is a POST because the filters travel as a body, not because it changes anything.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgId` | path | string | yes | Organization ID |

## Request Body

Required.

Content-Type: `application/json` · Schema: `object`

**`Request body`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `partner` | string | no |  |
| `productId` | string | no |  |
| `entitlementId` | string | no |  |
| `buyerId` | string | no |  |
| `currency` | string | no |  |
| `startDate` | string | no |  |
| `endDate` | string | no |  |

## Responses

### 200 — Legacy Revenue aggregate

Content-Type: `application/json`

### 400 — Invalid legacy Revenue request

Content-Type: `application/json`

**`Response`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | string | yes |  |
| `detail` | string | no |  |

### 403 — Missing Revenue permission

Content-Type: `application/json`

**`Response`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | string | yes |  |
| `detail` | string | no |  |

### 413 — Request body too large

Content-Type: `application/json` · Schema: `RevenuePayloadTooLargeResponse`

**`RevenuePayloadTooLargeResponse`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | object | yes |  |

### 500 — Failed to query Revenue records

Content-Type: `application/json`

**`Response`** fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | string | yes |  |
| `detail` | string | no |  |

## Example

_The request bodies are this operation's documented examples; the response and error bodies are generated from its schema. Substitute your own ids, and set `SUGER_TOKEN` to a bearer token from the [OAuth client-credentials exchange](https://doc.fours.com/settings/oauth-app/)._

### Request

```bash
curl -X POST 'https://api.suger.cloud/ai/org/{orgId}/revenue/record-aggregate' \
  -H "Authorization: Bearer $SUGER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "partner": "AWS",
  "startDate": "2026-01-01",
  "endDate": "2026-06-30"
}'
```

### Response — 200

```json
{}
```

### Error — 400

```json
{
  "error": "string",
  "detail": "string"
}
```

---

API reference: https://doc.fours.com/api/
