Skip to content

tys.orders.create()

Methodtryyoursize

Record an order (idempotent by order id; re-sending updates it). No customer data.

def create(order: OutcomeOrderInput, *, idempotency_key: Optional[str] = None) -> 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.

idempotency_keyOptional[str]Optional= None

OutcomeOrderResult: What was recorded.

idstringRequired
external_idstringRequired
createdbooleanRequired

False when the order already existed and was updated.

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

Was this page helpful?