---
title: "Get Ad Spend"
method: POST
path: "/api/ad-spend"
tags: ["Analytics"]
---

# Get Ad Spend

`POST /api/ad-spend`

## Request

- Base URL: `https://octanist.com`
- URL: `https://octanist.com/api/ad-spend`
- Auth: API key in header `X-API-KEY`

Retrieve ad spend data grouped by various dimensions.

## Request body

- AdSpendRequest
  - `startDate` string, date, required: Start date (YYYY-MM-DD)
  - `endDate` string, date, required: End date (YYYY-MM-DD)
  - `platform` 'googleads' | 'meta' | 'microsoftads': Filter by platform
  - `groupBy` 'date' | 'campaign' | 'adgroup' | 'platform': Dimension to group results by
  - `limit` integer: Results per page (1-500)
  - `page` integer: Page number

## Response `200`

Ad spend data retrieved successfully

- object
  - `success` boolean
  - `data` AdSpendEntry[]
    - `date` string, date: Date (when groupBy is `date`)
    - `campaignId` string: Campaign ID (when groupBy is `campaign` or `adgroup`)
    - `campaignName` string: Campaign name (when groupBy is `campaign` or `adgroup`)
    - `adGroupId` string: Ad group ID (when groupBy is `adgroup`)
    - `adGroupName` string: Ad group name (when groupBy is `adgroup`)
    - `platform` 'googleads' | 'meta' | 'microsoftads': Platform (when groupBy is `campaign`, `adgroup`, or `platform`)
    - `cost` number: Total cost
    - `clicks` integer: Total clicks
    - `impressions` integer: Total impressions
    - `conversions` integer: Total conversions
  - `meta` PaginatedMeta
    - `pagination` object
      - `limit` integer
      - `page` integer
      - `totalPages` integer
      - `total` integer
      - `hasMore` boolean
    - `requestId` string
    - `timestamp` string, date-time

## Other responses

- `400`: Invalid request body, startDate > endDate, or invalid date format
- `401`: Missing or invalid API key
- `500`: Server error

---

[API](https://skmtc.dev/octanist/apis/octanist-api.md) - [All operations](https://skmtc.dev/octanist/apis/octanist-api/llms.txt) - [OpenAPI document](https://skmtc.dev/octanist/apis/octanist-api/revisions/29a41aff4975?raw)
