---
title: "Composite Recommendation"
method: POST
path: "/{databaseId}/recomms/composite/"
tags: ["Recommendations"]
---

# Composite Recommendation

`POST /{databaseId}/recomms/composite/`

Composite Recommendation returns both a *source entity* (e.g., an Item or [Item Segment](https://docs.recombee.com/segmentations)) and a list of related recommendations in a single response.

It is ideal for use cases such as personalized homepage sections (*Articles from <category>*), *Because You Watched <movie>*, or *Artists Related to Your Favorite Artist <artist>*.

See detailed **examples and configuration guidance** in the [Composite Scenarios documentation](https://docs.recombee.com/scenarios#composite-recommendations).

**Structure**

The endpoint operates in two stages:
1. Recommends the *source* (e.g., an Item Segment or item) to the user.
2. Recommends *results* (items or Item Segments) related to that *source*.

For example, *Articles from <category>* can be decomposed into:
  - [Recommend Item Segments To User](https://docs.recombee.com/api#recommend-item-segments-to-user) to find the category.
  - [Recommend Items To Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment) to recommend articles from that category.

Since the first step uses [Recommend Item Segments To User](https://docs.recombee.com/api#recommend-items-to-user), you must include the `userId` parameter in the *Composite Recommendation* request.

Each *Composite Recommendation* counts as a single recommendation API request for billing.

**Stage-specific Parameters**

Additional parameters can be supplied via [sourceSettings](https://docs.recombee.com/api#composite-recommendation-param-sourceSettings) and [resultSettings](https://docs.recombee.com/api#composite-recommendation-param-resultSettings).
In the example above:
  - `sourceSettings` may include any parameter valid for [Recommend Item Segments To User](https://docs.recombee.com/api#recommend-items-to-user) (e.g., `filter`, `booster`).
  - `resultSettings` may include any parameter valid for [Recommend Items To Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment).

See [this example](https://docs.recombee.com/api#composite-recommendation-example-setting-parameters-for-individual-stages) for more details.

## Path parameters

- `databaseId` string, required

## Request body

- CompositeRecommendationParameters
  - `scenario` string, required — Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". You can set various settings to the [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.
  - `count` integer, required — Number of items to be recommended (N for the top-N recommendation).
  - `itemId` string — ID of the item for which the recommendations are to be generated.
  - `userId` string — ID of the user for which the recommendations are to be generated.
  - `logic` union
    - string
    - object
      - `name` string — Name of the logic that should be used
      - `settings` object — Parameters passed to the logic
  - `segmentId` string — ID of the segment from `contextSegmentationId` for which the recommendations are to be generated.
  - `searchQuery` string — Search query provided by the user. It is used for the full-text search. Only applicable if the *scenario* corresponds to a search scenario.
  - `cascadeCreate` boolean — If the entity for the source recommendation does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that entity, as the entity will be already known to the system.
  - `sourceSettings` object — Parameters applied for recommending the *Source* stage. The accepted parameters correspond with the recommendation sub-endpoint used to recommend the *Source*.
  - `resultSettings` object — Parameters applied for recommending the *Result* stage. The accepted parameters correspond with the recommendation sub-endpoint used to recommend the *Result*.
  - `expertSettings` object — Dictionary of custom options.

## Response `200`

Successful operation.

- CompositeRecommendationResponse
  - `recommId` string, required — Id of the composite recommendation request
  - `source` Recommendation, required
    - `id` string, required — Id of the recommended item
    - `values` object — Property values of the recommended item
    - `reqlEvaluations` object — Dictionary of evaluated ReQL expressions specified in the request and calculated for the recommended item. The keys are the names of the ReQL expressions, and the values are the results of the evaluations.
  - `recomms` Recommendation[], required — Obtained recommendations
    - `id` string, required — Id of the recommended item
    - `values` object — Property values of the recommended item
    - `reqlEvaluations` object — Dictionary of evaluated ReQL expressions specified in the request and calculated for the recommended item. The keys are the names of the ReQL expressions, and the values are the results of the evaluations.
  - `numberNextRecommsCalls` integer — How many times *Recommend Next Items* have been called for this `recommId`

## Other responses

- `400` — Count is not a positive integer, provided scenario not found.
- `404` — contextSegmentId not found in the context segmentation, userId not found in the database and cascadeCreate is false, itemId not found in the database and cascadeCreate is false.

---

[API](https://skmtc.dev/recombee/apis/recombee-api.md) · [All operations](https://skmtc.dev/recombee/apis/recombee-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/recombee/recombee-api/revisions/a9c9c33eb2e8/schema)
