tys.orders.create()
create(order: OutcomeOrderInput, options?: RequestOptions): Promise<OutcomeOrderResult>Parameters
Section titled “Parameters”orderOutcomeOrderInputRequiredProperties
idstringRequiredYour order ID.
ordered_atstringRequiredcurrencystringOptionalISO 4217, e.g. EUR.
visitor_idstringOptionalThe SDK's anonymous visitor ID ((await tys.experiment())?.visitorId), saved with the cart. TryYourSize recomputes the A/B arm from it and stores only its hash. Never a customer ID.
experiment_arm"treatment" | "holdout"OptionalThe arm, when you cannot send visitor_id.
linesOutcomeLineInput[]RequiredProperties
idstringRequiredYour order line ID (unique within the order).
productstringRequiredYour product ID (the one you pass to the SDK).
variantstringOptionalsizestringRequiredThe size bought, in your labels.
quantityintegerRequiredunit_price_minorintegerOptionalPrice of one unit in minor units (5995 = 59.95). Optional; used for the refund value estimate.
tys_shownbooleanOptionalA TryYourSize element was shown for this purchase.
recommended_sizestringOptionalThe size TryYourSize recommended (the SDK's recommendation event, or the _tys_size cart line property).
attribution"cart_attribute" | "sdk" | "api"OptionalWhere recommended_size came from.
optionsRequestOptionsOptionalReturns
Section titled “Returns”Promise<OutcomeOrderResult>: What was recorded.
idstringRequiredexternal_idstringRequiredcreatedbooleanRequiredFalse when the order already existed and was updated.
experiment_arm"treatment" | "holdout"OptionallinesintegerRequiredExample
Section titled “Example”await tys.orders.create({ id: "1001", // your order ID: re-sending updates it ordered_at: new Date().toISOString(), currency: "EUR", visitor_id, // from tys.experiment() in the browser, saved with the cart lines: [ { id: "1", product: "TEE-001", size: "M", quantity: 1, recommended_size: "M", tys_shown: true }, ],});from datetime import datetime, timezone
tys.orders.create({ "id": "1001", "ordered_at": datetime.now(timezone.utc).isoformat(), "currency": "EUR", "visitor_id": visitor_id, "lines": [{"id": "1", "product": "TEE-001", "size": "M", "quantity": 1, "recommended_size": "M", "tys_shown": True}],})curl -X POST https://api.tryyoursize.com/v1/orders \ -H "Authorization: Bearer $TRYYOURSIZE_SECRET_KEY" \ -H "TYS-Version: 2026-10-25" \ -H "Content-Type: application/json" \ -d '{"id":"1001","ordered_at":"2026-10-26T10:00:00Z","lines":[{"id":"1","product":"TEE-001","size":"M","quantity":1}]}'See also
Section titled “See also”Was this page helpful?
Thank you. We read every answer.