Skip to content

tys.orders.create()

Method@tryyoursize/node

create(order: OutcomeOrderInput, options?: RequestOptions): Promise<OutcomeOrderResult>
orderOutcomeOrderInputRequired
Properties
idstringRequired

Your order ID.

ordered_atstringRequired
currencystringOptional

ISO 4217, e.g. EUR.

visitor_idstringOptional

The 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"Optional

The arm, when you cannot send visitor_id.

linesOutcomeLineInput[]Required
Properties
idstringRequired

Your order line ID (unique within the order).

productstringRequired

Your product ID (the one you pass to the SDK).

variantstringOptional
sizestringRequired

The size bought, in your labels.

quantityintegerRequired
unit_price_minorintegerOptional

Price of one unit in minor units (5995 = 59.95). Optional; used for the refund value estimate.

tys_shownbooleanOptional

A TryYourSize element was shown for this purchase.

recommended_sizestringOptional

The size TryYourSize recommended (the SDK's recommendation event, or the _tys_size cart line property).

attribution"cart_attribute" | "sdk" | "api"Optional

Where recommended_size came from.

optionsRequestOptionsOptional

Promise<OutcomeOrderResult>: What was recorded.

idstringRequired
external_idstringRequired
createdbooleanRequired

False when the order already existed and was updated.

experiment_arm"treatment" | "holdout"Optional
linesintegerRequired
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 },
],
});

Was this page helpful?