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

# Compose a recommendation surface

> Composes a surface by id (or an unsaved `draft` of it) from the merchant's current candidate pools, as the storefront would, and returns the product id per slot with the shuffle seed used. Pass `anchor` for a product or category surface and `recent_views` to exercise history-seeded steps. Use it to test what shoppers would see; for the editor's saved-surface preview by name, see the surface preview routes. Read-only: nothing is written or recomputed.



## OpenAPI

````yaml /api-reference/openapi/lite.json post /recommendations/compose
openapi: 3.1.0
info:
  title: Search & Merchandising API
  version: 1.0.0
  description: >-
    REST API behind Depict: Search & Merchandising, the native Shopify app:
    onboarding, collections, boost & bury, dashboards, A/B testing and
    multi-store management. Endpoints are served under the /api/lite prefix and
    are authenticated with the Shopify session token that App Bridge issues to
    the embedded app.
servers:
  - url: /api/lite
security:
  - ShopifySessionToken: []
paths:
  /recommendations/compose:
    post:
      summary: Compose a recommendation surface
      description: >-
        Composes a surface by id (or an unsaved `draft` of it) from the
        merchant's current candidate pools, as the storefront would, and returns
        the product id per slot with the shuffle seed used. Pass `anchor` for a
        product or category surface and `recent_views` to exercise
        history-seeded steps. Use it to test what shoppers would see; for the
        editor's saved-surface preview by name, see the surface preview routes.
        Read-only: nothing is written or recomputed.
      operationId: recsCompose
      parameters:
        - schema:
            type: string
            description: Lite merchant id, e.g. `shopify-<shop id>`.
          required: true
          description: Lite merchant id, e.g. `shopify-<shop id>`.
          name: merchant_id
          in: query
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecsComposeRequest'
      responses:
        '200':
          description: The composed slots, dense from position 0.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecsComposeResponse'
        '400':
          description: >-
            The query or body failed the schema, or the body is not JSON;
            `detail` carries zod's messages.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Detail'
        '401':
          description: Not authenticated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Detail'
        '403':
          description: Authenticated, but this identity may not call the API.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Detail'
        '404':
          description: >-
            Merchant not found for this caller, or recommendations not
            configured.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Detail'
        '415':
          description: Content-Type is not application/json.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Detail'
        '422':
          description: The composer rejected the input (e.g. an unknown market or surface).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Detail'
        '500':
          description: Internal error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Detail'
        '502':
          description: The candidate pools could not be read.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Detail'
components:
  schemas:
    RecsComposeRequest:
      type: object
      properties:
        surface:
          type: string
          minLength: 1
        market:
          type: string
          minLength: 1
        anchor:
          type: object
          properties:
            kind:
              type: string
              enum:
                - product
                - category
            id:
              type: string
              minLength: 1
          required:
            - kind
            - id
        client_id:
          type: string
          minLength: 1
        recent_views:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                minLength: 1
              at:
                type: integer
                minimum: 0
            required:
              - id
              - at
        excluded_product_ids:
          type: array
          items:
            type: string
            minLength: 1
        limit:
          type: integer
          minimum: 1
          maximum: 100
        shuffle_seed:
          type: integer
          minimum: 0
          maximum: 4294967295
        draft:
          type: object
          properties:
            id:
              type: string
              minLength: 1
            steps:
              type: array
              items: {}
              maxItems: 32
          required:
            - id
          additionalProperties: {}
      required:
        - surface
    RecsComposeResponse:
      type: object
      properties:
        surface_id:
          type: string
        context:
          type: string
          enum:
            - product
            - category
            - any
        market_id:
          type: string
        available_markets:
          type: array
          items:
            type: string
        generated_at:
          type: string
        shuffle_seed:
          type: integer
        slots:
          type: array
          items:
            type: object
            properties:
              position:
                type: integer
              product_id:
                type: string
            required:
              - position
              - product_id
      required:
        - surface_id
        - context
        - market_id
        - available_markets
        - generated_at
        - shuffle_seed
        - slots
    Detail:
      type: object
      properties:
        detail:
          type: string
      required:
        - detail
      description: 'Every 4xx/5xx body: `{detail}`.'
  securitySchemes:
    ShopifySessionToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Shopify App Bridge session token of the embedded Depict: Search &
        Merchandising app. The shop in the token determines the merchant;
        merchant_id parameters must belong to that shop.

````