Baskets

Set the customer on a Basket

Attaches a Customer to the basket so the resulting Order is correctly attributed and surfaced in the customer's history. There are three modes:

  1. Authenticated customer — the request is authenticated as a Customer for the basket's brand. The authenticated customer is linked directly. If they don't have a phone number on file, supply one with phone (and optionally phone_country).
  2. Existing customer by email — pass email, first_name, last_name, and optionally phone. If a customer with that email already exists for the brand they are linked; otherwise a new Customer is created using these details.
  3. Guest checkout — the same payload as mode 2 is used; the newly-created customer is linked to the basket and saved against any marketing preferences supplied.

Phone numbers are normalised to E.164 using phone_country (or the site's country code) as the default region.

post/shop/basket/{basketId}/customer

Request body

emailstring

Customer email address. Required for guest checkout. Used to look up existing customers within the site's brand before creating a new record.

first_namestring

Customer's given name. Required for guest checkout.

last_namestring

Customer's family name. Required for guest checkout.

phonestring nullable

Customer's phone number. Required when the authenticated customer doesn't already have one on file; optional otherwise. Accepted in any format parseable against phone_country or the site's country code; persisted as E.164.

phone_countrystring nullable

Two-letter ISO country code used to interpret an unprefixed phone. Defaults to the site's country code when omitted.

marketing_preferencesstring[]

IDs of marketing preferences the customer has opted in to. Only honoured when creating a brand-new customer.

Example request

{
  "email": "avery.lin@example.com",
  "first_name": "Avery",
  "last_name": "Lin",
  "phone": "+447700900100",
  "phone_country": "GB",
  "marketing_preferences": [
    "5f5555555555555555555555"
  ]
}

Response

The updated Basket with the customer attached.

Changes

No recorded changes to this endpoint across all 1 revision of this API.