Seal the signed-in shopper's body into a handle for the brand's server
const url = 'https://api.tryyoursize.com/v1/recommendation_handles';const options = { method: 'POST', headers: { 'TYS-Publishable-Key': '<TYS-Publishable-Key>', 'Content-Type': 'application/json' }, body: '{"basics":{"sex":"female","age_years":1,"height_mm":1,"weight_kg":1},"measurements":[{"code":"neck_girth","value_mm":1,"source":"tape_self"}],"body_state":[1]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tryyoursize.com/v1/recommendation_handles \ --header 'Content-Type: application/json' \ --header 'TYS-Publishable-Key: <TYS-Publishable-Key>' \ --data '{ "basics": { "sex": "female", "age_years": 1, "height_mm": 1, "weight_kg": 1 }, "measurements": [ { "code": "neck_girth", "value_mm": 1, "source": "tape_self" } ], "body_state": [ 1 ] }'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.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”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.
object
object
object
Body measurement from set v1.
Measured value in millimetres.
Responses
Section titled “Responses”Created
An opaque, sealed handle for one signed-in shopper on one store and mode. Pass it to your server, which sends it to POST /v1/recommendations with a secret key. It is encrypted: neither your page nor your server can read anything from it, and it never carries the shopper’s email. It expires after an hour.
object
Starts with tys_rh_. Up to 4 KB.
Example
{ "handle": "tys_rh_AbC…", "mode": "test"}Invalid request
Every error has this shape. error is a human-readable message, status the HTTP status. code is stable and machine-readable; doc_url links its explanation; request_id identifies the request (also in the X-Request-ID response header): quote it to support.
object
Stable error code, e.g. invalid_request, unauthorized, reauth_required, payment_required, forbidden, not_found, conflict, unprocessable, rate_limited, internal_error, not_implemented, unavailable, invalid_api_version, idempotency_key_in_use, idempotency_key_reused, invalid_idempotency_key, handle_expired, handle_invalid.
Example
{ "code": "not_found", "doc_url": "https://docs.tryyoursize.com/api/errors/#not_found"}Missing or invalid credentials
Every error has this shape. error is a human-readable message, status the HTTP status. code is stable and machine-readable; doc_url links its explanation; request_id identifies the request (also in the X-Request-ID response header): quote it to support.
object
Stable error code, e.g. invalid_request, unauthorized, reauth_required, payment_required, forbidden, not_found, conflict, unprocessable, rate_limited, internal_error, not_implemented, unavailable, invalid_api_version, idempotency_key_in_use, idempotency_key_reused, invalid_idempotency_key, handle_expired, handle_invalid.
Example
{ "code": "not_found", "doc_url": "https://docs.tryyoursize.com/api/errors/#not_found"}Not allowed
Every error has this shape. error is a human-readable message, status the HTTP status. code is stable and machine-readable; doc_url links its explanation; request_id identifies the request (also in the X-Request-ID response header): quote it to support.
object
Stable error code, e.g. invalid_request, unauthorized, reauth_required, payment_required, forbidden, not_found, conflict, unprocessable, rate_limited, internal_error, not_implemented, unavailable, invalid_api_version, idempotency_key_in_use, idempotency_key_reused, invalid_idempotency_key, handle_expired, handle_invalid.
Example
{ "code": "not_found", "doc_url": "https://docs.tryyoursize.com/api/errors/#not_found"}The content is rejected (e.g. a body that cannot be rebuilt)
Every error has this shape. error is a human-readable message, status the HTTP status. code is stable and machine-readable; doc_url links its explanation; request_id identifies the request (also in the X-Request-ID response header): quote it to support.
object
Stable error code, e.g. invalid_request, unauthorized, reauth_required, payment_required, forbidden, not_found, conflict, unprocessable, rate_limited, internal_error, not_implemented, unavailable, invalid_api_version, idempotency_key_in_use, idempotency_key_reused, invalid_idempotency_key, handle_expired, handle_invalid.
Example
{ "code": "not_found", "doc_url": "https://docs.tryyoursize.com/api/errors/#not_found"}Was this page helpful?
Thank you. We read every answer.