Discount Code Performance
get_discount_code_performanceGet per-discount-code margin metrics: uses, revenue, discount cost, COGS, allocated ad spend, gross profit, and margin percent, ranked by any column. Pre-aggregated rolling timeframes provide the fastest results, while an explicit start_date/end_date produces a custom range computed live.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number, 1-based (default 1). | |
| sort_by | No | Sort field, default 'grossProfit'. | |
| end_date | No | Custom range end (YYYY-MM-DD, tenant timezone). Requires start_date. | |
| page_size | No | Rows per page, 1 to 100 (default 25). | |
| timeframe | No | Pre-aggregated rolling window: 'today', '7d', '30d' (default), '90d', or '1y'. Ignored when start_date and end_date are both provided. | |
| sort_order | No | Sort direction, default 'desc'. | |
| start_date | No | Custom range start (YYYY-MM-DD, tenant timezone). Requires end_date. Overrides timeframe. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| _meta | No | ||
| codes | No | ||
| period | No | ||
| source | No | Whether the figures came from the pre-computed cache or were calculated live for this request. | |
| summary | No | ||
| _message | No | ||
| _truncated | No | ||
| pagination | No | ||
| _tenant_context | No |