---
title: "Preview topic"
method: POST
path: "/topics/preview"
tags: ["Topics"]
---

# Preview topic

`POST /topics/preview`

## Request

- Base URL: `https://api.youscan.io/api/external`
- URL: `https://api.youscan.io/api/external/topics/preview`
- Auth: one of:
  - API key in header `X-API-KEY`
  - API key in query parameter `apiKey`
- TypeScript: <https://skmtc.dev/youscan/apis/youscan-api/docs/topics/preview/post.ts> (a function with typed inputs; its response is checked against the schema)

Estimate the number of monthly mentions for a topic query before creating a topic. This helps you check if your query is within your plan limits and if sampling is available.

## Request body

- object
  - `topicQuery` TopicQuery, required: Topic query parameters. Either `textQuery` or `viQuery` must be set.
    - `textQuery` string, nullable: Text query using YouScan query syntax.
    - `viQuery` string, nullable: VI query using YouScan query syntax (requires VI subscription). Used to match mentions by logos, text, and objects on images.
    - `filter` CustomFilter
      - `op` 'and' | 'or': How the listed filters are combined.
      - `filters` FilterItem[]
        - `fieldName` 'country' | 'countryGroup' | 'language' | 'source' | 'sourceType' | 'postType' | 'contentType' | 'authorAge' | 'authorSubscribers' | 'gender', required: The field to filter on.
        - `op` 'oneOf' | 'notOneOf' | 'greaterOrEqual' | 'lessOrEqual', required: The operation to perform.
        - `value` string, required: JSON-encoded array of values, e.g. `["ua"]`.
  - `sampling` number: Sampling rate (0 < value ≤ 1). Optional (default value is 1 — full sample).

## Response `200`

Estimation result.

- object
  - `monthlyCount` integer: Estimated number of mentions per month for the query.
  - `monthlyLimit` integer: Monthly mentions limit of your subscription plan.
  - `isWithinLimit` boolean: Whether the estimated count fits into the plan limit.
  - `samplingAllowed` boolean: Whether sampling is available in your subscription plan.
  - `sampling` number, nullable: Sampling rate echoed from the request.

## Other responses

- `400`: The request is invalid.
- `401`: The API key is missing or invalid.

---

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