Merchant-hosted endpoints
Reference for the create checkout and generate session token endpoints that you host for the Agentic Commerce Suite.
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
| Header | Required | Description |
|---|---|---|
Authorization | No | Website session for a signed-in shopper, for example Bearer {{MERCHANT_WEBSITE_TOKEN}}. |
X-Requested-With | No | Client identifier. Use awx-shopper-assistant. |
Request body
An empty JSON object.
Response body
| Field | Required | Type | Description |
|---|---|---|---|
access_token | Yes | string | Bearer token the chat app sends on later calls. Must not be empty. |
expires_in | No | integer | Token lifetime in seconds. |
Guest shopper example
1POST /chat/generate_session_token HTTP/1.12Content-Type: application/json3X-Requested-With: awx-shopper-assistant
1{2 "access_token": "eyJhbGciOiJIUzI1NiJ9.example_access_token",3 "expires_in": 36004}
Signed-in shopper example
1POST /chat/generate_session_token HTTP/1.12Content-Type: application/json3X-Requested-With: awx-shopper-assistant4Authorization: Bearer {{MERCHANT_WEBSITE_TOKEN}}
1{2 "access_token": "eyJhbGciOiJIUzI1NiJ9.example_client_secret",3 "expires_in": 9004}
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
| Header | Required | Description |
|---|---|---|
x-timestamp | Yes | Epoch milliseconds, as a decimal string. Included in the signature. Reject a timestamp more than five minutes from your clock. |
x-signature | Yes | Lowercase hex HMAC-SHA256 of x-timestamp and the raw body, keyed with the signing secret your Account Manager gives you after onboarding. |
Request body
A request with no customer and no shipping_address is still a valid basket.
Line item object
| Field | Required | Type | Description |
|---|---|---|---|
id | Yes | string | Line item id, unique within the checkout request. |
item_id | Yes | string | Product or variant id from your catalog. |
requested_quantity | Yes | integer | Quantity the shopper requested. Echo this value in the response. |
available_quantity | No | integer | Quantity 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
| Field | Required | Type | Description |
|---|---|---|---|
id | No | string | Customer id. Present when the shopper is signed in. Omitted for a guest. |
email | Yes | string | Shopper email. Can be an empty string when the email is unknown. |
first_name | No | string | First name. Maximum length is 128. |
last_name | No | string | Last name. Maximum length is 128. |
phone_number | No | string | Phone number. |
Address object
| Field | Required | Type | Description |
|---|---|---|---|
street | Yes | string | Street. Maximum length is 1000. |
city | Yes | string | City. Maximum length is 100. |
state | No | string | State or province. Maximum length is 100. |
postcode | Yes | string | Postcode. Maximum length is 10. |
country_code | Yes | string | Two-letter ISO 3166-1 alpha-2 country code. |
Response body
| Field | Required | Type | Description |
|---|---|---|---|
id | Yes | string | Your checkout session id. Airwallex returns it as merchant_order_id on the PaymentIntent Webhook so you can reconcile the payment with your order. |
line_items | No | []LineItem | Requested line items with their requested_quantity and available_quantity. |
fulfillment | No | Fulfillment | Fulfillment choices available for this checkout. |
totals | No | []Totals | Checkout cost breakdown, excluding fulfillment. |
permalink_url | No | string | Link 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
| Field | Required | Type | Description |
|---|---|---|---|
type | Yes | string | Cost category, such as subtotal, tax, fee, or total. Do not include fulfillment. Airwallex adds it from the selected option's cost. |
amount | Yes | integer | Amount 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_text | No | string | Label shown to the shopper, for example Subtotal or Tax. |
Fulfillment object
| Field | Required | Type | Description |
|---|---|---|---|
methods | No | []FulfillmentMethod | Fulfillment 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
| Field | Required | Type | Description |
|---|---|---|---|
id | No | string | Method id. Airwallex returns it as the fulfillment group id on the PaymentIntent Webhook after the shopper pays. |
type | No | string | Fulfillment 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_ids | No | []string | Line items this method covers. In this release, that is the whole cart. |
fulfillable_on | No | string | When the items become available to fulfill. |
description | No | string | Description shown to the shopper. |
destinations | No | []Destination | Destinations or collection locations for this method. Every option is offered for every destination. |
options | No | []Option | Options the shopper can choose for this method. |
Destination object
| Field | Required | Type | Description |
|---|---|---|---|
id | Yes | string | Destination id. |
address | No | Address | Shipping address. |
name | No | string | Name shown to the shopper, for example a store name for pickup. |
Option object
| Field | Required | Type | Description |
|---|---|---|---|
id | Yes | string | Option id. |
title | Yes | string | Option label, such as Standard shipping or In-store pickup. |
cost | Yes | integer | Fulfillment cost in minor units. A zero-cost option adds no fulfillment entry to the totals. |
carrier | No | string | Shipping carrier. |
description | No | string | More detail about the option. |
earliest_delivery_at | No | string | Earliest estimated delivery time, in ISO 8601. |
latest_delivery_at | No | string | Latest estimated delivery time, in ISO 8601. |
Example request
1{2 "line_items": [3 {4 "id": "line_item_001",5 "item_id": "dress_tropical_s",6 "requested_quantity": 17 },8 {9 "id": "line_item_002",10 "item_id": "dress_floral_s",11 "requested_quantity": 112 }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
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": 19 },10 {11 "id": "line_item_002",12 "item_id": "dress_floral_s",13 "requested_quantity": 1,14 "available_quantity": 115 }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": 50041 },42 {43 "id": "exp",44 "title": "Express shipping (1-2 days)",45 "carrier": "FedEx",46 "cost": 150047 }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": 065 }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}