---
title: "Start Trends Analysis"
method: POST
path: "/ad_analytics/cpg_suite/trends-analysis/"
---

# Start Trends Analysis

`POST /ad_analytics/cpg_suite/trends-analysis/`

Start CPG trends analysis comparing two selections over time.

## Request body

- TrendsAnalysisRequest — Request for trends analysis comparing two selections over time.
  - `selection_1` SelectionPayload, required
    - `selections` array[], required
      - Selection[]
        - `field` string, required
        - `values` string[], nullable, required
  - `selection_2` SelectionPayload, required
    - `selections` array[], required
      - Selection[]
        - `field` string, required
        - `values` string[], nullable, required
  - `metric` 'total_sales' | 'transaction_count' | 'customer_count' | 'percent_of_total_sales', required — Primary metrics for trends analysis.
  - `filters` CPGSuiteFilter, required — Filter for CPG Suite.
    - `selections` SelectionPayload, required
      - `selections` array[], required
        - Selection[]
          - `field` string, required
          - `values` string[], nullable, required
    - `search_string` string, nullable — Search string for fuzzy match
    - `timeframe` SrcApiAdAnalyticsModelTimeframe
      - `start_date` string, date-time, required
      - `end_date` string, date-time, nullable, required
    - `audience_filter` CPGAudienceFilter — Audience filter for CPG Suite with category selection support.
      - `audience_id` string, nullable — Base audience ID to filter by
      - `category_selections` SelectionPayload
        - `selections` array[], required
          - Selection[]
            - `field` string, required
            - `values` string[], nullable, required
  - `aggregate_by_day_of_week` boolean — Aggregate by day of week instead of time periods

## Response `200`

Successful Response

- AsyncJobRecord — Do NOT access this table directly.
  - `id` integer, nullable — ID of this object.
  - `created_at` string, date-time, nullable — datetime object representing when this object was created.
  - `updated_at` string, date-time, nullable — datetime object representing when this object was updated.
  - `deleted_at` string, date-time, nullable — datetime object representing when this object was deleted.
  - `status` 'RUNNING' | 'COMPLETED' | 'FAILED'
  - `endpoint` string — Endpoint spawning async job
  - `request` union — request sent to endpoint
    - object
    - unknown[]
      - unknown
  - `sync_response` union — sync response
    - object
    - unknown[]
      - unknown
  - `error` string, nullable — error message
  - `response` unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/akkio/apis/fastapi.md) · [All operations](https://skmtc.net/akkio/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/akkio/fastapi/versions/6662a407c637/schema)
