Airwallex logo

Merchant-hosted endpoints

Reference for the create checkout and generate session token endpoints that you host for the Agentic Commerce Suite.

Copy for LLMView as Markdown

Airwallex calls two endpoints that you host: POST /create_checkout and POST /chat/generate_session_token. Create checkout is used on your storefront and on external AI surfaces. The session token is for a chat on your own site. Airwallex hosts every other endpoint in the suite. This page lists the fields for the two you host.

For the steps, see Airwallex runs discovery and checkout on your storefront and Airwallex runs discovery and checkout on external surfaces.

Generate a session token

POST /chat/generate_session_token

Return a short-lived session token that your chat app carries for the rest of the conversation. Use this endpoint on your own storefront. External surfaces use OAuth instead. Omit the Authorization header for a guest. You host this endpoint.

See Expose an authentication method for the Airwallex APIs this endpoint calls.

Request headers

HeaderRequiredDescription
AuthorizationNoWebsite session for a signed-in shopper, for example Bearer {{MERCHANT_WEBSITE_TOKEN}}.
X-Requested-WithNoClient identifier. Use awx-shopper-assistant.

Request body

An empty JSON object.

Response body

FieldRequiredTypeDescription
access_tokenYesstringBearer token the chat app sends on later calls. Must not be empty.
expires_inNointegerToken lifetime in seconds.

Guest shopper example

text
1POST /chat/generate_session_token HTTP/1.1
2Content-Type: application/json
3X-Requested-With: awx-shopper-assistant
JSON
1{
2 "access_token": "eyJhbGciOiJIUzI1NiJ9.example_access_token",
3 "expires_in": 3600
4}

Signed-in shopper example

text
1POST /chat/generate_session_token HTTP/1.1
2Content-Type: application/json
3X-Requested-With: awx-shopper-assistant
4Authorization: Bearer {{MERCHANT_WEBSITE_TOKEN}}
JSON
1{
2 "access_token": "eyJhbGciOiJIUzI1NiJ9.example_client_secret",
3 "expires_in": 900
4}

For a guest, call Obtain an access tokenAPI with the scoped API key from onboarding, and return that token as access_token. That key needs only Read access to the Payment Acceptance > Customs Declarations scope, and no wider access. Create it as a scoped key rather than an Admin key. See Manage API keys.

A shopper who is already signed in sends your website session on the same endpoint. Validate it, then return the client secret from Generate a client secret for a CustomerAPI as access_token.

Create a checkout

POST /create_checkout

Airwallex calls this endpoint when a shopper is ready to buy, on your storefront and on external AI surfaces. Return the items you can sell, the fulfillment choices you offer, and the order cost. Airwallex renders the cart from your response.

Check the signature before you act on the request. x-signature is the lowercase hex HMAC-SHA256 of the x-timestamp value concatenated with the exact request body, with no separator, keyed with the signing secret your Account Manager gives you after onboarding. The signing secret is not an API access token. See Verify the signature.

Request headers

HeaderRequiredDescription
x-timestampYesEpoch milliseconds, as a decimal string. Included in the signature. Reject a timestamp more than five minutes from your clock.
x-signatureYesLowercase hex HMAC-SHA256 of x-timestamp and the raw body, keyed with the signing secret your Account Manager gives you after onboarding.

Request body

FieldRequiredTypeDescription
line_itemsYes[]LineItemLine items in the basket.
currencyYesstringThree-letter ISO 4217 currency code, for example USD.
customerNoCustomerShopper details.
shipping_addressNoAddressShipping or fulfillment destination.

A request with no customer and no shipping_address is still a valid basket.

Line item object

FieldRequiredTypeDescription
idYesstringLine item id, unique within the checkout request.
item_idYesstringProduct or variant id from your catalog.
requested_quantityYesintegerQuantity the shopper requested. Echo this value in the response.
available_quantityNointegerQuantity you can sell. Return it in the response only. An equal quantity is available, a lower quantity is partially available, and 0 is out of stock.

Customer object

FieldRequiredTypeDescription
idNostringCustomer id. Present when the shopper is signed in. Omitted for a guest.
emailYesstringShopper email. Can be an empty string when the email is unknown.
first_nameNostringFirst name. Maximum length is 128.
last_nameNostringLast name. Maximum length is 128.
phone_numberNostringPhone number.

Address object

FieldRequiredTypeDescription
streetYesstringStreet. Maximum length is 1000.
cityYesstringCity. Maximum length is 100.
stateNostringState or province. Maximum length is 100.
postcodeYesstringPostcode. Maximum length is 10.
country_codeYesstringTwo-letter ISO 3166-1 alpha-2 country code.

Response body

FieldRequiredTypeDescription
idYesstringYour checkout session id. Airwallex returns it as merchant_order_id on the PaymentIntent Webhook so you can reconcile the payment with your order.
line_itemsNo[]LineItemRequested line items with their requested_quantity and available_quantity.
fulfillmentNoFulfillmentFulfillment choices available for this checkout.
totalsNo[]TotalsCheckout cost breakdown, excluding fulfillment.
permalink_urlNostringLink to this checkout on your site.

Return the same checkout id on retries for the same basket. Do not create an order or decrement stock. Create checkout is not an order. The response only indicates that the shopper started checkout. Fulfill when the PaymentIntent Webhook arrives.

Totals object

FieldRequiredTypeDescription
typeYesstringCost category, such as subtotal, tax, fee, or total. Do not include fulfillment. Airwallex adds it from the selected option's cost.
amountYesintegerAmount in minor units. Detail entries must sum to total, excluding fulfillment. Airwallex calculates the amount charged from the line item amounts you return, and adds fulfillment from the option the shopper selects.
display_textNostringLabel shown to the shopper, for example Subtotal or Tax.

Fulfillment object

FieldRequiredTypeDescription
methodsNo[]FulfillmentMethodFulfillment methods you offer. In this release, each method covers the whole cart and each type appears at most once. Ids for methods, destinations, and options must be unique across the whole response, stable across retries, and meaningful in a log.

Fulfillment method object

FieldRequiredTypeDescription
idNostringMethod id. Airwallex returns it as the fulfillment group id on the PaymentIntent Webhook after the shopper pays.
typeNostringFulfillment type. Known values are PICKUP, SHIPPING, DIGITAL, and LOCAL_DELIVERY. Only ACP supports DIGITAL and LOCAL_DELIVERY. The PaymentIntent Webhook uses lowercase values, such as shipping.
line_item_idsNo[]stringLine items this method covers. In this release, that is the whole cart.
fulfillable_onNostringWhen the items become available to fulfill.
descriptionNostringDescription shown to the shopper.
destinationsNo[]DestinationDestinations or collection locations for this method. Every option is offered for every destination.
optionsNo[]OptionOptions the shopper can choose for this method.

Destination object

FieldRequiredTypeDescription
idYesstringDestination id.
addressNoAddressShipping address.
nameNostringName shown to the shopper, for example a store name for pickup.

Option object

FieldRequiredTypeDescription
idYesstringOption id.
titleYesstringOption label, such as Standard shipping or In-store pickup.
costYesintegerFulfillment cost in minor units. A zero-cost option adds no fulfillment entry to the totals.
carrierNostringShipping carrier.
descriptionNostringMore detail about the option.
earliest_delivery_atNostringEarliest estimated delivery time, in ISO 8601.
latest_delivery_atNostringLatest estimated delivery time, in ISO 8601.

Example request

JSON
1{
2 "line_items": [
3 {
4 "id": "line_item_001",
5 "item_id": "dress_tropical_s",
6 "requested_quantity": 1
7 },
8 {
9 "id": "line_item_002",
10 "item_id": "dress_floral_s",
11 "requested_quantity": 1
12 }
13 ],
14 "currency": "USD",
15 "customer": {
16 "id": "cus_hkpdxxxxxxxx",
17 "email": "[email protected]",
18 "first_name": "Jane",
19 "last_name": "Merchant",
20 "phone_number": "+1 415 555 0100"
21 },
22 "shipping_address": {
23 "street": "123 Market Street",
24 "city": "San Francisco",
25 "state": "CA",
26 "postcode": "94103",
27 "country_code": "US"
28 }
29}

Example response

JSON
1{
2 "id": "mch_co_01EXAMPLE",
3 "line_items": [
4 {
5 "id": "line_item_001",
6 "item_id": "dress_tropical_s",
7 "requested_quantity": 1,
8 "available_quantity": 1
9 },
10 {
11 "id": "line_item_002",
12 "item_id": "dress_floral_s",
13 "requested_quantity": 1,
14 "available_quantity": 1
15 }
16 ],
17 "fulfillment": {
18 "methods": [
19 {
20 "id": "ship",
21 "type": "SHIPPING",
22 "line_item_ids": ["line_item_001", "line_item_002"],
23 "destinations": [
24 {
25 "id": "dest_home",
26 "address": {
27 "street": "123 Market Street",
28 "city": "San Francisco",
29 "state": "CA",
30 "postcode": "94103",
31 "country_code": "US"
32 }
33 }
34 ],
35 "options": [
36 {
37 "id": "std",
38 "title": "Standard shipping (4-5 days)",
39 "carrier": "USPS",
40 "cost": 500
41 },
42 {
43 "id": "exp",
44 "title": "Express shipping (1-2 days)",
45 "carrier": "FedEx",
46 "cost": 1500
47 }
48 ]
49 },
50 {
51 "id": "pickup",
52 "type": "PICKUP",
53 "line_item_ids": ["line_item_001", "line_item_002"],
54 "destinations": [
55 {
56 "id": "loc_downtown",
57 "name": "Downtown Store"
58 }
59 ],
60 "options": [
61 {
62 "id": "pu_instore",
63 "title": "In-store pickup",
64 "cost": 0
65 }
66 ]
67 }
68 ]
69 },
70 "totals": [
71 {
72 "type": "subtotal",
73 "amount": 11798,
74 "display_text": "Subtotal"
75 },
76 {
77 "type": "tax",
78 "amount": 950,
79 "display_text": "Tax"
80 },
81 {
82 "type": "total",
83 "amount": 12748,
84 "display_text": "Total"
85 }
86 ],
87 "permalink_url": "https://www.merchant.example/checkout/mch_co_01EXAMPLE"
88}
Was this page helpful?