Use a Delivery Offer to Create an Order
Buy with Prime API is now available for early access
Sign up for early access to the Buy with Prime API using the 'Sign Up' button below. The API may change as Amazon receives feedback and iterates on it.
After you Create Delivery Previews to surface delivery offers on product detail pages and during checkout, you Create a Buy with Prime Order. When you create an order, you specify the delivery offer that the shopper chose for each item. This topic shows how to pass the chosen delivery offer to the order.
To learn how to call the Buy with Prime API, see Call the Buy with Prime API.
Sample data
The examples in this topic use the following sample data.
Sample product details
{
title: "In Search of Lost Time",
isbn: "example-isbn-1",
isPrimeIntended: true,
sku: "example-sku-1",
mSku: "example-msku-1",
imageUrl: "https://example.com/images/example-image-1.jpg",
detailPageUrl: "https://www.amazon.com/dp/example-detail-page-1",
price: {
amount: "10.00",
currencyCode: "USD"
}
variationDetails: [
{
type: "format",
value: "Hardcover"
},
{
type: "version",
value: "Abridged"
}
]
}
Sample customer details
{
contact: {
name: "Jane Doe",
email: "[email protected]"
}
}
Sample recipient details
{
deliveryAddress: {
name: "John Doe",
streetAddress: "440 Terry Ave N" ,
locality: "Seattle",
region: "WA",
countryCode: "US",
postalCode: "98109",
contactNumber: "206-555-0100"
}
}
Sample delivery offer details
# See other tab for sampleDeliveryPreviewQueryResponse
# Assume that the first delivery offer from the delivery group is selected to create a fulfillment order
deliveryPreviewId: sampleDeliveryPreviewQueryResponse["data"]["deliveryPreview"]["id"]
deliveryOfferId: sampleDeliveryPreviewQueryResponse["data"]["deliveryGroups"][0]["deliveryOffers"][0]["id"]
{
"data": {
"deliveryPreview": {
"id": "example-delivery-preview-id",
"deliveryGroups": [
{
"id": "example-delivery-group",
"items": [
{
"itemIdentifier": {
"__typename": "SKU",
"value": "example-sku-1" # In Search of Lost Time SKU
},
"quantity": {
"unit": "UNIT",
"amount": 1
}
}
],
"deliveryOffers": [
{
"id": "example-delivery-offer-id-1",
"charge": {
"totalCharge": {
"currencyCode": "USD",
"amount": 0
},
"rollupCharges": [
]
},
"date": {
"earliest": "2023-08-24T03:00:00Z",
"latest": "2023-08-28T03:00:00Z"
},
"policy": {
"messaging": {
"messageText": "Get it on August 24",
"locale": "en-US",
"badge": "PRIME"
}
},
"expiresAt": "2023-08-21T21:27:35.016842Z"
},
{
"id": "example-delivery-offer-id-2",
"charge": {
"totalCharge": {
"currencyCode": "USD",
"amount": 0
},
"rollupCharges": [
]
},
"date": {
"earliest": "2023-08-26T14:14:06Z",
"latest": "2023-08-30T14:14:06Z"
},
"policy": {
"messaging": {
"messageText": "Get it on August 26th",
"locale": "en-US",
"badge": "PRIME"
}
},
"expiresAt": null
}
]
}
]
}
}
}
Use a delivery offer to create a Buy with Prime order
The following example shows how to pass a delivery offer to the createOrder
mutation. When you create the order, you specify the selectedDeliveryOffer
for each line item.
In the DeliveryOfferDetails
, make sure to provide both the deliveryPreviewId
and the id
for accurate representation of the chosen delivery option within the finalized order.
Request
# Variables from sample data
inSearchOfLostTimeBook
deliveryPreviewId
deliveryOfferId
reversalOfferId
janeDoeCustomer
johnDoeRecipient
// GraphQL mutation
mutation createOrder($input: CreateOrderInput) {
createOrder(input: $input) {
id
orderLinks {
destinationType
url
}
}
}
// Mutation variables
{
"input": {
"desiredExecutionState": "STARTED",
"customer": janeDoeCustomer,
"recipient":johnDoeRecipient,
"lineItems": [
{
"purchasedItem": {
"itemId": {
"space": "SKU",
"value": inSearchOfLostTimeBook.sku
},
"title": inSearchOfLostTimeBook.title,
"price": {
"currentPrice": {
"amount": inSearchOfLostTimeBook.price.amount,
"currencyCode": inSearchOfLostTimeBook.price.currencyCode
}
}
},
"quantity": {
"amount": 1
},
"selectedDeliveryOffer": {
"details": {
"deliveryPreviewId": deliveryPreviewId,
"id": deliveryOfferId
"deliveryProvider": "BUY_WITH_PRIME"
}
}
}
]
}
}
Response
orderResponse =
{
"data": {
"createOrder": {
"id": "example-order-id",
"orderLinks": [
{
"destinationType": "BWP_STOREFRONT",
"url": "https://order.buywithprime.amazon.com/orders/example"
}
]
}
}
}
Related topics
Updated 3 days ago