Bootstrap the measurement window
const url = 'https://api.tryyoursize.com/v1/embed/init';const options = { method: 'POST', headers: { 'TYS-Publishable-Key': '<TYS-Publishable-Key>', 'Content-Type': 'application/json' }, body: '{"parent_origin":"example"}'};
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/embed/init \ --header 'Content-Type: application/json' \ --header 'TYS-Publishable-Key: <TYS-Publishable-Key>' \ --data '{ "parent_origin": "example" }'Key: publishable (pk_test_… / pk_live_…), from an origin registered for the key.
Called when the measurement window opens. Checks the publishable key and that the brand page embedding the window (parent_origin) is allowed for the store.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Origin of the brand page that opened the window, e.g. https://shop.example
Example generated
{ "parent_origin": "example"}Responses
Section titled “Responses”The store the window works for
object
Example
{ "mode": "test"}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"}Was this page helpful?
Thank you. We read every answer.