> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upriver.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Media Categories Search

> Find the most relevant categories from the taxonomy for a given freeform text. Useful for discovering the best category for brand industries, target audiences, etc. Returns ordered matches with confidence scores.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/categories/search
openapi: 3.1.0
info:
  title: Upriver API
  description: >-
    A social insights API for ad generation platforms. It provides structured
    signals, like psychographics, behavioral insights, trends, and audience
    language, to help AI models generate relevant, higher-converting ads.
  version: 1.0.0
servers:
  - url: https://api.upriver.ai
    description: Production API server
security: []
tags:
  - name: Brands
  - name: Products
  - name: Creators
  - name: Audience
  - name: Sponsorships
  - name: Trends
  - name: Breakout Topics
  - name: Taxonomy
paths:
  /v1/categories/search:
    post:
      tags:
        - Taxonomy
      summary: Media Categories Search
      description: >-
        Find the most relevant categories from the taxonomy for a given freeform
        text. Useful for discovering the best category for brand industries,
        target audiences, etc. Returns ordered matches with confidence scores.
      operationId: search_categories
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CategorySearchInput'
              description: Search parameters
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CategorySearchResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    CategorySearchInput:
      properties:
        text:
          type: string
          title: Text
          description: Freeform text to match against category taxonomy
          examples:
            - telehealth and men's health
        top_k:
          type: integer
          maximum: 20
          minimum: 1
          title: Top K
          description: Number of categories to return, ordered by relevance
          default: 5
      type: object
      required:
        - text
      title: CategorySearchInput
      description: Input for category search endpoint.
    CategorySearchResponse:
      properties:
        matches:
          items:
            $ref: '#/components/schemas/CategoryMatch'
          type: array
          title: Matches
          description: Ordered list of matched categories (highest confidence first)
        query_text:
          type: string
          title: Query Text
          description: The input text that was matched
      type: object
      required:
        - matches
        - query_text
      title: CategorySearchResponse
      description: Response from category search endpoint.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    CategoryMatch:
      properties:
        category_id:
          type: string
          title: Category Id
          description: Category ID from taxonomy
        display_name:
          type: string
          title: Display Name
          description: >-
            Human-readable category name. Use this for embedding-based
            resolution in downstream endpoints.
        level:
          type: integer
          title: Level
          description: Taxonomy level (1 or 2)
        parent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Id
          description: Parent category ID for L2 categories
        confidence:
          type: number
          maximum: 1
          minimum: 0
          title: Confidence
          description: Confidence score for this match
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
          description: Explanation for why this category was chosen
      type: object
      required:
        - category_id
        - display_name
        - level
        - confidence
      title: CategoryMatch
      description: |-
        A matched category with confidence score.

        Note: When passing the matched category to other endpoints that use
        embedding-based resolution (like /sponsors), use the display_name field
        rather than category_id for better embedding matches.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````