Skip to content

tys.recommendationHandle()

Method@tryyoursize/sdk

A sealed handle for your server’s POST /v1/recommendations (headless or server-rendered pages). Send handle to your server; it gets sizes only. Null when the shopper is not signed in to TryYourSize on your site, has no body yet, or is in the A/B holdout. Expires after an hour.

recommendationHandle(): Promise<RecommendationHandle | null>;

Promise<RecommendationHandle | null>: { handle, expiresAt }, or null.

handlestringRequired

Opaque, starts with tys_rh_; send it to your server as is.

expiresAtstringRequired

ISO date-time; ask for a new one after it (an hour).

Browser: get a handle, send it to your server

Section titled “Browser: get a handle, send it to your server”
const h = await tys.recommendationHandle();
const res = await fetch("/api/sizes", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ handle: h?.handle, products: ["SKU-123", "SKU-456"] }),
});
const { data } = await tys.recommendations.create({ handle, products: ["SKU-123", "SKU-456"] });

Was this page helpful?