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

# Get Referenced Items for Affiliates

> Retrieves a list of recommended items based on a user query, designed for affiliate use cases. Allows filtering by media type, publisher, and snippet counts.

<Card title="Error Reference: Search & Recommendations" icon="triangle-exclamation" href="/api-reference/general/errors#search-%26-recommendations">
  Common errors: invalid collection, missing or invalid tenant, certainty threshold issues, empty query string.
</Card>


## OpenAPI

````yaml post /ai/v1/data/affiliates/referenced-items
openapi: 3.1.0
info:
  title: AI API
  description: |-
    Optimized for high-speed inference and scalability by Gloo AI

    [Swagger UI](./docs) | [ReDoc UI](./redoc)
  version: 1.0.0
servers:
  - url: https://platform.ai.gloo.com
security:
  - bearerAuth: []
tags:
  - name: Content Controls
  - name: Data Engine
  - name: Ingestion & Enrichment
  - name: answers
  - name: chat
  - name: completions
  - name: content
  - name: core
  - name: data
  - name: get-models
  - name: ingestion
  - name: sotc
paths:
  /ai/v1/data/affiliates/referenced-items:
    post:
      tags:
        - data
      summary: Get Referenced Items for Affiliates
      description: >-
        Retrieves a list of recommended items based on a user query, designed
        for affiliate use cases. Allows filtering by media type, publisher, and
        snippet counts.
      operationId: get-affiliate-referenced-items
      requestBody:
        description: Parameters for retrieving affiliate recommendations.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AffiliatesRequestBody'
            example:
              max_snippet_count_overall: 100
              media_types:
                - article
                - book
              min_snippet_count_per_item: 2
              publishers: []
              query: How do I have a good marriage?
              certainty_threshold: 0.3
              item_count: 3
      responses:
        '200':
          description: Successful response returning a list of referenced items.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AffiliatesItem'
              example:
                - item_id: 236ca8b8-0ef3-4c5b-b1a4-1091aa43abdd
                  author:
                    - Dr. Michael Youssef
                  filename: 3-ways-to-strengthen-your-marriage.txt
                  tradition: ''
                  duration: ''
                  item_title: 3 Ways to Strengthen Your Marriage
                  item_subtitle: ''
                  item_image: >-
                    https://ltw.org/wp-content/uploads/2024/12/3WaysStrengthenMarriageFeb2024MYJ_2000x833.png
                  item_url: >-
                    https://ltw.org/read/article/3-ways-to-strengthen-your-marriage/
                  item_tags: ''
                  h2_id: 6891cf39-c61a-4e9d-a548-77e57a5f47cc
                  h2_title: MY Journal
                  h2_subtitle: ''
                  h2_image: >-
                    https://ltw.org/wp-content/uploads/2024/12/3WaysStrengthenMarriageFeb2024MYJ_2000x833.png
                  h2_url: >-
                    https://ltw.org/read/article/3-ways-to-strengthen-your-marriage/
                  h2_tags: null
                  h3_id: c0122b21-26a2-4663-b23e-780f131cf1f9
                  h3_title: Marriage
                  h3_subtitle: ''
                  h3_image: >-
                    https://ltw.org/wp-content/uploads/2024/12/3WaysStrengthenMarriageFeb2024MYJ_2000x833.png
                  h3_url: >-
                    https://ltw.org/read/article/3-ways-to-strengthen-your-marriage/
                  h3_tags: null
                  h2_summary: ''
                  publication_date: February 1, 2024
                  publisher: Leading the Way
                  publisher_id: a6e849de-4972-4fc5-b5f6-6a239ed577c5
                  publisher_url: https://ltw.org
                  publisher_logo: >-
                    https://dapologeticsimages.s3.us-east-1.amazonaws.com/logos/logo_1743136797058.svg
                  item_summary: ''
                  type: Article
                  hosted_url: >-
                    https://ltw.org/read/article/3-ways-to-strengthen-your-marriage/
                  snippet_count: 2
                  cumulative_certainty: 1.44311040639877
        '401':
          description: Unauthorized - The JWT token is missing or invalid.
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
        '422':
          description: >-
            Validation Error - The request body is invalid, missing required
            fields, or contains invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
              examples:
                InvalidRequestBody:
                  summary: 'Error: Invalid Request Body'
                  value:
                    detail:
                      - loc:
                          - body
                        msg: Input should be a valid JSON object
                        type: json_invalid
                MissingRequiredFields:
                  summary: 'Error: Missing Required Fields'
                  value:
                    detail:
                      - loc:
                          - body
                          - query
                        msg: Field required
                        type: missing
                      - loc:
                          - body
                          - collection
                        msg: Field required
                        type: missing
                InvalidFieldValues:
                  summary: 'Error: Invalid Field Values'
                  value:
                    detail:
                      - loc:
                          - body
                          - min_snippet_count_per_item
                        msg: Input should be greater than or equal to 1
                        type: greater_than_equal
                        ctx:
                          ge: 1
        '500':
          description: >-
            Internal Server Error - An error occurred while searching for
            sources.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Error searching sources. Our team has been notified.
      security:
        - bearerAuth: []
components:
  schemas:
    AffiliatesRequestBody:
      type: object
      title: AffiliatesRequestBody
      properties:
        query:
          type: string
          description: The prompt that the user enters into the application.
        certainty_threshold:
          type: number
          maximum: 1
          minimum: 0
          title: Certainty Threshold
          description: The minimum certainty threshold for snippets.
          default: 0.75
        max_snippet_count_overall:
          type: integer
          description: The maximum number of snippets to search through overall.
          default: 300
        media_types:
          type: array
          items:
            type: string
            enum:
              - audio
              - video
              - book
              - article
          description: The type(s) of media for the items returned.
          default: []
        min_snippet_count_per_item:
          type: integer
          description: >-
            The minimum number of snippets that must be associated with an item
            for it to be returned.
          minimum: 1
          default: 1
        publishers:
          type: array
          items:
            type: string
          description: The publisher(s) whose items should be recommended.
          default: []
        item_count:
          type: integer
          description: >-
            The maximum number of items to return. Items are ranked by
            cumulative certainty. If the available snippets span fewer items
            than this count, only those items are returned.
          minimum: 1
      required:
        - query
    AffiliatesItem:
      type: object
      title: AffiliatesItem
      properties:
        item_id:
          type: string
          format: uuid
        author:
          type: array
          items:
            type: string
        filename:
          type: string
        tradition:
          type: string
        duration:
          type: string
        item_title:
          type: string
        item_subtitle:
          type: string
        item_image:
          type: string
          format: uri
        item_url:
          type: string
          format: uri
        item_tags:
          anyOf:
            - type: string
            - type: array
              items:
                type: string
        h2_id:
          type: string
        h2_title:
          type: string
        h2_subtitle:
          type: string
        h2_image:
          type: string
          format: uri
        h2_url:
          type: string
          format: uri
        h2_tags:
          anyOf:
            - type: string
            - type: 'null'
        h3_id:
          type: string
        h3_title:
          type: string
        h3_subtitle:
          type: string
        h3_image:
          type: string
          format: uri
        h3_url:
          type: string
          format: uri
        h3_tags:
          anyOf:
            - type: string
            - type: 'null'
        h2_summary:
          type: string
        publication_date:
          type: string
        publisher:
          type: string
        publisher_id:
          type: string
          format: uuid
        publisher_url:
          type: string
          format: uri
        publisher_logo:
          type: string
          format: uri
        item_summary:
          type: string
        type:
          type: string
        hosted_url:
          type: string
          format: uri
        snippet_count:
          type: integer
        cumulative_certainty:
          type: number
          format: float
        denomination:
          type: string
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Error:
      type: object
      properties:
        detail:
          type: string
          description: A human-readable description of the error.
      title: Error
    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:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form Bearer `<token>`, where
        `<token>` is your [auth token](/studio/manage-api-credentials).

````