---
title: "Update topic query"
method: POST
path: "/topics/{topicId}/query/edit"
tags: ["Topics"]
---

# Update topic query

`POST /topics/{topicId}/query/edit`

## Request

- Base URL: `https://api.youscan.io/api/external`
- URL: `https://api.youscan.io/api/external/topics/{topicId}/query/edit`
- 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/:topicId/query/edit/post.ts> (a function with typed inputs; its response is checked against the schema)

Updates an existing topic's query parameters.

## Path parameters

- `topicId` integer, required

## 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"]`.

## Response `200`

Updated topic.

- TopicInfo
  - `id` integer: Topic ID.
  - `name` string: Topic name.
  - `topicQuery` TopicQuery: 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, nullable: Sampling rate, if sampling is enabled for the topic.

## Other responses

- `400`: The request is invalid.
- `401`: The API key is missing or invalid.
- `402`: Too many mentions matching the query for your subscription plan.
- `403`: Your permission level for this topic is too low for the action.
- `404`: Topic not found or you don't have access to it.

---

[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)
