# Timeouts, fallback and testing your TMS

What the customer sees when a Shipping Assistant call to your TMS fails or times out, how fallback works and how to test your integration in playground.

If `POST /shippingoptions` fails, Kustom shows the merchant's fallback options without an
error. Reservation failures stop the purchase. Use the behavior below to test each failure
in playground.

## What each failure does

| What happens | What the customer sees |
| --- | --- |
| `POST /shippingoptions` times out, answers anything but `200`, or returns a body Kustom can't use | The merchant's fallback options. **For the rest of that checkout**: Kustom stops calling you for it |
| `POST /auth` fails, or a call still gets `401` after a fresh token | Same as above |
| `POST /shippingoptions` returns an empty list | "We cannot ship to the given address". Not a fallback: the customer changes the address, and Kustom asks again |
| `POST /shipment` or `PUT /shipment/{shipment_id}` fails in any way | The purchase stops, Kustom asks for options again and the customer picks again. See [Refusing a reservation](/checkout/shipping/shipping-assistant/reserve-shipment/#refusing-a-reservation) |
| That new `POST /shippingoptions` fails too | The merchant's fallback options |
| `POST /shipment/{shipment_id}/confirm` fails | Nothing. The purchase is already complete |

During fallback, the customer chooses from the merchant's fixed list. If no list was supplied,
they can buy with a delivery address but no delivery option. Kustom makes no reservation in
your TMS, so the merchant must arrange delivery separately.

Invalid field values can reject the whole response even when the JSON is valid. Validate
responses against the [options page](/checkout/shipping/shipping-assistant/shipping-options/#response)
before going live.

## Time limits

Calls time out after **8 seconds** by default, or less for some integrations. Aim for well
under a second for `POST /shippingoptions` and `POST /shipment` to limit the customer's wait.

Kustom repeats a call once, a second later, after some network errors. That's why the same
`POST /shipment` can arrive twice — see
[Make `POST /shipment` safe to repeat](/checkout/shipping/shipping-assistant/reserve-shipment/#make-post-shipment-safe-to-repeat).

If many calls to your host fail in a short time, Kustom pauses calls for a few seconds.
Every checkout in that window falls back, even if its call would have succeeded.

## Test in playground

Kustom's playground environment is separate from production, with its own merchant accounts.
Build against it first.

1. **Try your endpoints in [Shipwreck](https://shipwreck.playground.kustom.co/)**, Kustom's test
   tool for TMS integrations. It calls your API the way the checkout does and shows how your
   options render in the shipping selector.
2. **Connect a playground merchant.** A playground merchant account adds a Shipping Assistant
   profile pointing at your TMS, with an identifier and key you issue — see
   [Shipping options in the checkout](/checkout/shipping/#shipping-assistant). Create a test
   merchant with **Get playground access** at the top of this page or
   at [portal.playground.kustom.co](https://portal.playground.kustom.co/onboarding).
3. **Walk through a real checkout.** Enter an address, change it, search for a pickup point, press
   Buy and complete the purchase. Check that each call from the
   [flow](/checkout/shipping/shipping-assistant/#how-your-tms-fits-into-a-checkout) reaches you
   and that your `shipment_id` arrives on the order as `tms_reference`.
4. **Test the failures.** Answer `401` once and watch Kustom re-authenticate. Refuse a
   reservation with a `failure_reason`. Make `PUT /shipment/{shipment_id}` answer `404`.
5. **Check the merchant's fallback.** A customer email containing `+fallback`, such as
   `jane+fallback@example.com`, makes playground skip your TMS and show the fallback options, so
   the merchant can see what their customers get when you're unavailable.

## Before you go live

- Every response validates against the lists on the
  [options page](/checkout/shipping/shipping-assistant/shipping-options/), for every carrier and
  type you'll return.
- `POST /shipment` returns the same `shipment_id` when it's repeated for a `session_id`.
- `PUT /shipment/{shipment_id}` replaces the reservation rather than adding one.
- `POST /shippingoptions` answers inside a second under your expected load.
- Each merchant has their own Identifier and Key, and you can revoke one without the others.
- You log `Klarna-Correlation-Id`, so Kustom support can find a call you're asking about.

## Related

- [Build a TMS integration](/checkout/shipping/shipping-assistant/) — the flow and what you must build
- [Shipping options in the checkout](/checkout/shipping/#basic-shipping-options) — what the merchant's fallback list looks like
- [Shipping Service Callback API](/api/shipping-service-callback/)
