# tys.recommendationHandle()

> A sealed handle for your server's POST /v1/recommendations (headless or server-rendered pages).

Source: https://docs.tryyoursize.com/reference/web/client-recommendation-handle/

*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.

```ts
recommendationHandle(): Promise<RecommendationHandle | null>;
```

## Returns

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

- **`handle`** (`string`, required): Opaque, starts with `tys_rh_`; send it to your server as is.
- **`expiresAt`** (`string`, required): ISO date-time; ask for a new one after it (an hour).

## Examples

### Browser: get a handle, send it to your server

**JavaScript**

```js
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"] }),
});
```

### Server: exchange it for sizes

**Node.js**

```ts
const { data } = await tys.recommendations.create({ handle, products: ["SKU-123", "SKU-456"] });
```

**Python**

```python
answer = tys.recommendations.create(handle=handle, products=["SKU-123", "SKU-456"])
```

## See also

- [Server-side recommendations](https://docs.tryyoursize.com/guides/server-side-recommendations.md)
- [recommendations.create() (Node.js)](https://docs.tryyoursize.com/reference/node/recommendations-create.md)
