Skip to content

Set Checkout Address

About

The createCheckoutAddress mutation sets the billing and shipping address for the current checkout session. This is a single mutation that handles both addresses based on the useForShipping flag:

  • useForShipping: true — Only billing address fields are required. The billing address is automatically copied to the shipping address.
  • useForShipping: false — Both billing and shipping address fields must be provided separately. This allows the customer to ship to a different address than their billing address.

Authentication

This mutation supports both authenticated customers and guest users:

  • Authenticated customers: Provide a valid customer authentication token in the Authorization header. Obtain this token via the Customer Login API.
  • Guest users: Provide the Guest Cart Token cartToken obtained from the Create Cart mutation.
Authorization: Bearer <accessToken>

Arguments

Billing Address (always required)

NameTypeRequiredDescription
billingFirstNameStringYesBilling first name
billingLastNameStringYesBilling last name
billingEmailStringYesBilling email address
billingAddressStringYesBilling street address
billingCityStringYesBilling city
billingCountryStringYesBilling country code (ISO 3166-1 alpha-2)
billingStateStringYesBilling state/province code
billingPostcodeStringYesBilling postal/zip code
billingPhoneNumberStringYesBilling phone number
useForShippingBooleanNoIf true, billing address is used as shipping address. If false, separate shipping fields are required. Default: false

Shipping Address (required when useForShipping is false)

NameTypeRequiredDescription
shippingFirstNameStringConditionalShipping first name
shippingLastNameStringConditionalShipping last name
shippingEmailStringConditionalShipping email address
shippingAddressStringConditionalShipping street address
shippingCityStringConditionalShipping city
shippingCountryStringConditionalShipping country code (ISO 3166-1 alpha-2)
shippingStateStringConditionalShipping state/province code
shippingPostcodeStringConditionalShipping postal/zip code
shippingPhoneNumberStringConditionalShipping phone number

Response

FieldTypeDescription
_idIntegerInternal address identifier
idStringAddress ID
successBooleanSuccess status
messageStringSuccess or error message
cartTokenStringCart token for the checkout session
billingFirstNameStringBilling first name
billingLastNameStringBilling last name
billingAddressStringBilling street address
billingCityStringBilling city
billingStateStringBilling state/province
billingPostcodeStringBilling postal/zip code
billingPhoneNumberStringBilling phone number
shippingFirstNameStringShipping first name
shippingLastNameStringShipping last name
shippingAddressStringShipping street address
shippingCityStringShipping city
shippingStateStringShipping state/province
shippingPostcodeStringShipping postal/zip code
shippingPhoneNumberStringShipping phone number

Validation Rules

  • All required billing address fields must be provided
  • billingEmail must be a valid email address
  • Country codes must be valid ISO 3166-1 alpha-2 codes
  • Phone numbers should be in valid format
  • When useForShipping is false, all shipping address fields become required

Error Responses

json
{
  "errors": {
    "billingEmail": ["The billing email must be a valid email address."],
    "billingCountry": ["Invalid country code."],
    "shippingFirstName": ["The shipping first name field is required."]
  }
}

Released under the MIT License.