Custom Algorithms

Prev Next

Custom is the serve endpoint for custom algorithms (Bring Your Own Recommendations (BYOR)). It lets you serve product lists computed outside Insider One, an in-house ML model, a third-party engine, or a hand-curated business list, through the same delivery pipeline as native algorithms: in-stock control, attribute filters, category filters, user-based exclusions, affinity re-ranking (hp), variant handling, and fallbacks all still apply on top of your-supplied list.

A custom algorithm is addressed by an ID of the form cus-{subType}-{algoId} (e.g. cus-p-8842). The sub-type decides the serve contract:

Sub-type

Id prefix

What is stored

Serve-time requirement

Native analogue

Personalized

cus-p-

One recommendation list per user, inside the partner + algorithm + locale partition

userId

User Based

Contextual

cus-c-

One recommendation list per base product, inside the partner + algorithm + locale partition

productId

Purchased Together

Generic

cus-g-

One scored list for the whole partner + algorithm + locale partition (no additional key)

Most Popular Items

locale is part of the partition key for every sub-type, not just Generic; it's the same catalog locale required as a query parameter below. Only the row key inside that partition differs: userId for cus-p-, the base productId for cus-c-, and one row per scored product for cus-g-.

Working principles

  • Identity. The request must carry either algorithm (a full cus- id; the request itself is the whole configuration; strategyId, when also present, is recorded for attribution only) or strategyId (a stored strategy whose algorithm is custom, resolved with full /v2/strategy semantics; stored endpoint_template values merge under request values). A native (non-cus-) value on either path is rejected with a 400.

  • Gate validation. Partner, authentication, rate-limit, and requesting origin validation checks run before any strategy resolution.

  • Store lookup. Candidate ids are read from the custom-scores store, partitioned by {partnerName}:{customAlgorithmId}:{locale}. Personalized and contextual serves are point reads keyed by userId / productId; a generic serve drains the whole partition and orders by score (descending, stable).

  • Enrichment and ranking. Candidates (over-fetched at 4× the requested size so filter drops don't under-fill) are enriched from the product catalog: out-of-stock and filtered-out items drop, the stored order is preserved, the hp affinity re-rank applies when requested, and the list is cut to size.

  • Response. Custom-served products are keyed in the types map by the full custom id (e.g. "cus-p-8842": 12); fallback-filled products keep their native type codes.

Generic (cus-g-) results are served through a shared query cache with a fixed ~10-minute TTL, so newly ingested generic scores can take up to ~10 minutes to appear. Personalized and contextual serves are never written to the shared cache.

Custom ids also participate in the wider V2 surface: a stored custom strategy called via /v2/strategy transparently serves through this same path, cus- entries are admitted inside Chef and /v2/mixed strategy lists, and a cus- id can itself be used as a fallback candidate for another strategy.

Endpoint

GET https://recommendation.api.useinsider.com/v2/custom

Fallbacks

  • Due to possibilities such as:

    • No custom personalized algorithm results row for the user in the SR API request /

    • No custom contextual algorithm results for the product in the SR API

    • Filtering applied in the SR API endpoint causing custom recommendations to be filtered out,

      In such cases, Insider One returns an empty response for the custom part of the request, not an error. Then, if fallbacks are enabled, it hands over to the standard fallback flow exactly like a native algorithm that returned nothing.

  • Fallbacks are filled from your prebuilt (static) chain, or from a dynamic chain requested with fallbacks (CSV of up to 4 fallback strategy ids, or none to disable filling). Consumption mode is set with fbType (agg default, first alternative).

  • When the store has no data and no fallback is selected, the response is a well-formed empty success (success: true, empty data), by design, not an error.

  • Fallback products appear in types under their own native codes; per-source attribution is available with fbDetails=true (fallbackInfo block).

Query Parameters

Field Name

Description

Data Type

Required

Valid Values

Default

algorithm

Full custom algorithm id. When present, the serve resolves directly from the request (no stored-strategy fetch). One of algorithm or strategyId is required.

String

Yes, unless strategyId is given

cus-[pcg]-{algoId}

strategyId

Stored strategy id of a custom strategy. Resolves the serve when algorithm is absent; with algorithm present, it is recorded for attribution only.

Integer

Yes, unless algorithm is given

partnerName

Partner name or id

String

Yes

locale

Locale of requested product catalog (must match the catalog spelling exactly, e.g. en_US). Part of the custom-scores partition key for all three sub-types.

String

Yes

userId

End-user identifier, the personalized list key. Missing it on a cus-p- serve returns 400.

String

Yes for cus-p-

productId

Base product id, the contextual list key. Missing it on a cus-c- serve returns 400.

String

Yes for cus-c-

currency

Requested currency of the products

String

No

platform

Requested platform

Enum

No

web, app

web

size

Requested size of the products

Integer

No

0 to 100

30

categoryList

Category filter of the products (JSON array)

Array (of string)

No

[]

filter

Smart Recommender Filtering

String

No

details

Adds details to the products of the response

Boolean

No

false

shuffle

Shuffles the products of the response

Boolean

No

false

getGroupProducts

Shows variant products under the products of the response

Boolean

No

false

groupProductsFields

Adds these fields to the variant products' details

String

No

excludeVariants

Exclude variants from response

Boolean, Integer

No

1, 0, true, false

false

excludeViewDay

After how many days ago products viewed should be excluded

Integer

No (Can be used only with userId)

-1

excludeViewItem

How many viewed products should be excluded

Integer

No (Can be used only with userId)

-1

excludePurchaseDay

After how many days ago products purchased should be excluded

Integer

No (Can be used only with userId)

-1

excludePurchaseItem

How many purchased products should be excluded

Integer

No (Can be used only with userId)

-1

hp

Re-ranks the served list by the user's attribute affinities

Boolean

No

false

dayLimit

Publisher day-limit filter

Integer

No

2

ibp

Include the base product in the served list (contextual serves)

String

No

true, 1

false

fallbacks

Dynamic fallback chain: none, or a CSV of up to 4 fallback strategy ids in priority order

String

No

upf

Use prebuilt (static) fallbacks; dominates the fallbacks parameter

String

No

true, 1

false

fbType

Fallback consumption mode: agg fills from the primary and then each fallback in priority order; first serves the entire result of the first candidate meeting the requested size

String

No

agg, first

agg

fbFresh

Preview-only fallback refresh hint (re-resolves the fallback chain so previews reflect just-saved edits)

String

No

true, 1

false

fbDetails

Adds the fallbackInfo attribution block to the response

String

No

true, 1

false

campaignId

Campaign attribution id

String

No

Examples

Generic — cus-g-

One shared list per partner + algorithm + locale. No user or product context is needed.

Request

https://recommendation.api.useinsider.com/v2/custom?partnerName=demoshop&locale=en_US&algorithm=cus-g-1024

Response

{
    "success": true,
    "total": 8,
    "types": {
        "cus-g-1024": 8
    },
    "data": [
        "SKU-77120",
        "SKU-88431",
        "SKU-10294",
        "SKU-55710",
        "SKU-31448",
        "SKU-90021",
        "SKU-66317",
        "SKU-24805"
    ]
}

Personalized — cus-p- (requires userId)

The list stored for this specific user is served; without userId, the request is rejected with 400 (Missing parameter: userId).

Request

https://recommendation.api.useinsider.com/v2/custom?partnerName=demoshop&locale=en_US&algorithm=cus-p-8842&userId=usr-5f2a91c3

Response

{
    "success": true,
    "total": 6,
    "types": {
        "cus-p-8842": 6
    },
    "data": [
        "SKU-40233",
        "SKU-11876",
        "SKU-93012",
        "SKU-77120",
        "SKU-58649",
        "SKU-30215"
    ]
}

Contextual — cus-c- (requires productId)

The list stored for the base product is served; without productId, the request is rejected with 400 (Missing parameter: productId).

Request

https://recommendation.api.useinsider.com/v2/custom?partnerName=demoshop&locale=en_US&algorithm=cus-c-4519&productId=SKU-30215

Response

{
    "success": true,
    "total": 5,
    "types": {
        "cus-c-4519": 5
    },
    "data": [
        "SKU-30990",
        "SKU-30218",
        "SKU-41102",
        "SKU-77120",
        "SKU-15530"
    ]
}

With details and fallback attribution

When the custom list cannot fill the requested size, fallbacks top it up — fallback products keep their native type codes in types, and fbDetails=true names each contributing source.

Request

https://recommendation.api.useinsider.com/v2/custom?partnerName=demoshop&locale=en_US&algorithm=cus-p-8842&userId=usr-5f2a91c3&size=3&details=true&fbDetails=true

Response

{
    "success": true,
    "total": 3,
    "types": {
        "cus-p-8842": 2,
        "mvop": 1
    },
    "data": [
        {
            "item_id": "SKU-40233",
            "name": "Cap",
            "in_stock": 1,
            "price": { "USD": 16 },
            "locale": "en_US"
        },
        {
            "item_id": "SKU-11876",
            "name": "Belt",
            "in_stock": 1,
            "price": { "USD": 55 },
            "locale": "en_US"
        },
        {
            "item_id": "SKU-90021",
            "name": "Scarf",
            "in_stock": 1,
            "price": { "USD": 24 },
            "locale": "en_US"
        }
    ],
    "fallbackInfo": [
        { "source": "cus-p-8842", "count": 2 },
        { "source": "mvop", "count": 1 }
    ]
}

Common 400 responses

Condition

Message

Neither algorithm nor strategyId given

Request needs either an 'algorithm' (cus- id) or a 'strategyId' query parameter.

algorithm is a native (non-cus-) value

algorithm must be a custom (cus-) id; native algorithms serve via their own endpoints or /v2/strategy.

strategyId points to a native strategy

Strategy {strategyId} is not a custom algorithm; serve it via /v2/strategy.

Malformed custom id (e.g., cus-x-1, cus-p-abc)

Custom algorithm id sub-type is invalid; expected cus-[pcg]-<id>.

cus-p- without userId

Missing parameter: userId

cus-c- without productId

Missing parameter: productId