# Seal the signed-in shopper's body into a handle for the brand's server

```http
POST /v1/recommendation_handles
```

Source: https://docs.tryyoursize.com/api/reference/operations/createrecommendationhandle/

**Key:** publishable (`pk_test_…` / `pk_live_…`), from an origin registered for the key.

Called by the TryYourSize window (the SDK's invisible status frame), never by a brand's code: it needs the shopper's session (`Authorization: Bearer tys_sess_…`), which only our origin can read, plus the store's publishable key. The answer is an encrypted handle bound to the store, the mode and the shopper; the page passes it to the brand's server for POST /v1/recommendations. Nothing is stored: the handle itself is the sealed body, and neither the page nor the brand's server can read it. Expires after an hour.

## Authentication

Publishable key (`pk_test_…` / `pk_live_…`), from an origin registered for the key.

## Request body

`application/json`: `RecommendationHandleRequest`

The signed-in shopper's body as the TryYourSize window holds it (the same fields as POST /v1/tryon, without the product). Sent only by our window (status frame) or SDKs, never by a brand's page or server.

- `basics` (`BodyBasics`, required)
  - `sex` (`"female" | "male"`, required)
  - `age_years` (`integer`, required)
  - `height_mm` (`number (double)`, required)
  - `weight_kg` (`number (double)`, required)
- `measurements` (`Measurement[]`, optional, max 64 items)
  - `code` (`"neck_girth" | "shoulder_width" | "arm_length" | "armscye_girth" | "upper_arm_girth" | "wrist_girth" | "chest_girth" | "underbust_girth" | "bust_point_to_bust_point" | "shoulder_to_bust_point" | "back_length" | "waist_girth" | "front_waist_arc" | "high_hip_girth" | "abdomen_girth" | "hip_girth" | "front_hip_arc" | "thigh_girth" | "knee_girth" | "calf_girth" | "ankle_girth" | "inseam" | "outseam" | "crotch_length"`, required): Body measurement from set v1.
  - `value_mm` (`number (double)`, required): Measured value in millimetres.
  - `source` (`"tape_self" | "tape_helper" | "flat_garment" | "estimated" | "bra_size"`, required): How the value was obtained. bra_size: derived from the shopper's bra size (underbust and bust only).
  - `sd_mm` (`number (double)`, optional): The value's uncertainty (one standard deviation, mm), when known: set for values from a bra size; a tape measured twice may send its own. Omitted: the default for its source.
- `fit` (`FitProfile`, optional): The shopper's fit preference and usual sizes (optional). Without it, a signed-in shopper's saved profile is used; a guest gets sizes for a regular fit.
  - `preference` (`PreferredFit`, optional)
  - `preference_tops` (`PreferredFit`, optional)
  - `preference_bottoms` (`PreferredFit`, optional)
  - `usual_sizes` (`UsualSize[]`, optional, max 20 items)
    - `id` (`string (uuid)`, optional)
    - `brand` (`string`, required, max length 40): A brand key from GET /v1/usual-size-brands.
    - `line` (`"tops" | "bottoms"`, required)
    - `sex` (`"female" | "male"`, optional): The brand's women's (female) or men's (male) line. Defaults to the shopper's own.
    - `size` (`string`, required, max length 16): The size label as the brand writes it (one of the brand's sizes for this line).
    - `source` (`"declared" | "kept_purchase"`, optional)
    - `created_at` (`string (date-time)`, optional)
  - `updated_at` (`string (date-time)`, optional)
- `body_state` (`number (double)[]`, required, max 64 items)

## Responses

### 201

Created (`RecommendationHandle`)

- `handle` (`string`, required): Starts with `tys_rh_`. Up to 4 KB.
- `expires_at` (`string (date-time)`, required)
- `mode` (`"test" | "live"`, required)

### 400

Invalid request (`Error`)

### 401

Missing or invalid credentials (`Error`)

### 403

Not allowed (`Error`)

### 422

The content is rejected (e.g. a body that cannot be rebuilt) (`Error`)

## Example

```bash
curl -X POST https://api.tryyoursize.com/v1/recommendation_handles \
  -H "Authorization: Bearer pk_test_…" \
  -H "TYS-Version: 2026-10-25" \
  -H "Content-Type: application/json" \
  -d @body.json
```
