Checkout links


A short Layout link where a person pays for a cart you built. When they tap Pay, Layout places the order right there. You do not call confirm; you only hear that it happened.

A checkout link pays for one order. A card link only saves a card, with no order on it, and leaves confirming to you. To compare both with Card Handoff, see Taking payment.

POST /v1/users/usr_4b8e9a01c2d3/links
{
  "purpose": "checkout",
  "cartId": "crt_0d928d04f1iQbL1AV4iXSKw2wabMk_B-",
  "returnUrl": "com.acme.assistant:/layout/checkout",
  "state": "c1f9e2"
}

→ 201
{
  "url": "https://pay.layout.link/3q2Xw7…",
  "expiresAt": "2026-10-21T17:15:00.000Z",
  "purpose": "checkout",
  "cartId": "crt_0d928d04f1iQbL1AV4iXSKw2wabMk_B-"
}
FieldNotes
purposeRequired. "checkout". Card links use "card".
cartIdRequired with checkout, and refused with card (400 invalid_request). It must be a cart you built for that same person with POST /v1/carts, or the answer is 404 not_found.
returnUrlOptional. Where the page sends the person when they finish. The same rules as a card link: it must be exactly one of your registered return URLs.
stateOptional. The same rules as a card link: 1 to 512 characters, with no control characters. Layout hands it back on the return URL.

It takes your secret key, on the same endpoint as card links. The person must have verified their number with your application first (see Verify their phone), or it is 409 person_not_ready.

  • Single use. The first open spends the link. Once open, the page keeps working for 30 minutes.
  • 15 minutes to open. expiresAt says when. Mint a new link when one expires.
  • Different host. The url is on pay.layout.link. Card links stay on layout.link/h/.

When to send one

Mint it for a cart that is ready: a link to a cart that already closed still mints, but its page only says the order closed. Send it once the cart is ready and the person has seen what they are about to buy in your product. It replaces the confirm step: do not call POST /v1/carts/:id/confirm. A ready cart lasts 15 minutes from when it is ready, however long the link has left, so mint and send the link as soon as the cart is ready. When the person opens it after the cart expired, the page says the order closed, nothing is charged, and the return carries status=canceled&reason=cart_closed: build the cart again and send a new link. In a chat, say in the same message that the link is good for about 15 minutes.

What the person sees

They do not sign in to Layout. The page is Layout’s confirm screen for that cart: the restaurant’s name and address, the items, subtotal, tax and fees, Layout’s service fee, the total, and one Pay button that states the total. For the fee rules, see Fees and Layout One.

  • A card on their account. Pay charges that card. In live, Layout first texts the person a 6-digit code and they type it on the page, because a link can be forwarded and a saved card should not pay on the link alone. They can switch to Apple Pay or add a card instead, unless their account already holds all the cards it can.
  • No card yet. The button reads Add payment method and opens a sheet with Apple Pay first and the card form one tap away. Adding a card never pays: the sheet closes, the page shows the card beside the total, and the button becomes Pay. The order is placed only when they tap it. The card they add is saved to their Layout account and is the one this order bills. When it is their first card it becomes their default, so the later carts you confirm yourself bill it too. When they already had a card, their default stays as it was.
  • A code. Whenever Layout needs the person’s 6-digit code for this order, the page asks for it after Pay, and the person types it there. You never handle the code.

Layout places the order the moment the person taps Pay. You are not asked to do anything: there is no "card added, now confirm" step on your side. The return URL and the order.placing and order.placed webhooks tell you it happened. The card is entered on Layout’s page and never touches your servers.

Without a return URL the page stays open when it is done: “Order confirmed. Go back to {your app} to follow your order.”, or, for a cart that closed, “This order closed” with nothing charged. A chat app usually has no return URL, which is fine: follow the order from your server.

Return URLs

Register a return URL in the console, as for card links, and name it exactly when you mint the link. See Return URLs for how to register one and what a return URL can be.

What comes back

The page sends the person’s browser to your return URL with state, when you sent one, and then status added to its query.

ReturnMeaning
status=confirmedThe person paid and the order is placing. It is not placed yet: follow the order.
status=pendingLayout could not tell whether the confirm went through, because the answer was lost. Do not build or confirm again. Read GET /v1/orders/:id or wait for the webhooks.
status=canceled&reason=cart_closedThe cart can no longer be paid for: it expired, was canceled or failed. A card declined while paying can end the cart too. Nothing was charged. Build a new cart and mint a new link.
status=canceledThe person left without paying, or closed the sheet. Nothing was charged. The cart stays ready until its own expiresAt, 15 minutes after it was ready. Mint a new link to try again.
  • It can come more than once. Handle a repeat as a no-op.
  • It may never come. Never wait on the return to move on.
  • It is not proof. Anyone can open your return URL with any status.
  • It is not a webhook. It is the person’s own browser opening your URL.

Check it on your side

  1. When you mint the link, send a fresh random state and keep it with the person and the cart.
  2. When a return arrives, look up its state. Ignore one you did not send or have already handled.
  3. On confirmed or pending, read the cart and the order from your server, or wait for the webhooks below. Treat the webhooks as the answer.
  4. On canceled, say nothing was charged and offer to try again with a new link. Build a new cart first when the return carries reason=cart_closed.

Webhooks

There is nothing new to subscribe to. Without a webhook endpoint, read GET /v1/carts/:id, then GET /v1/orders/:id with its order.id, until the order is placed or failed.

  • card.added when the person adds a card on the checkout page, with the same payload and your link’s state.
  • The usual order events for that cart’s order: order.placing, order.placed, order.failed and order.unconfirmed, each carrying cart_id. See Event types.

GET /v1/carts/:id reads order.confirmedVia: "checkout" once the person paid on the checkout page. A confirm you send after that answers 409 already_confirmed and charges nothing again. See Already confirmed elsewhere.

Open it in your app

  • iOS app. Use ASWebAuthenticationSession or SFSafariViewController, never your own WKWebView. If the person closes the sheet, ASWebAuthenticationSession reports .canceledLogin: treat it as canceled. The code is on Card links.
  • Web app. Open it in the same tab, with an https return URL on your site.
  • Agent, chat or SMS app. Send the url in the conversation with one line that says what it is.

In sandbox

A sandbox key mints a sandbox checkout link. The page shows the cart with a Sandbox note, and Add payment method opens a sheet with one Add test card button; then Pay places the order. No card is collected and nothing is charged. The order is simulated exactly as a sandbox confirm is: use the cart’s simulate ending. Returns and webhooks behave as live.

Cost

Checkout links are free for developers. The person pays the order total, which includes Layout’s service fee unless your application covers it or they have Layout One. See Fees and Layout One.

Errors

StatusCodeMeaning
400invalid_requestcartId is missing with checkout, or sent with card. Or state or returnUrl breaks its rule, as for card links. The message says which.
404not_foundNo such user for this application in this environment, or no such cart that you built for this person.
409person_not_readyThe person has not verified their number with your application. Verify them, then mint the link.
429rate_limitedThe same limits as card links. Wait Retry-After.