Create a Delivery Preview for Checkout
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.
This topic contains examples of requests and responses that show how to Create Delivery Previews that you can display on a checkout page.
Sample data
The examples in this topic use the following sample data.
Sample catalog data
val inSearchOfLostTime = {
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"
};
val prideAndPrejudice = {
title: "Pride and Prejudice",
isbn: "example-isbn-2",
isPrimeIntended: true,
sku: "example-sku-2",
mSku: "example-msku-2",
imageUrl: "https://example.com/images/example-image-2.jpg",
detailPageUrl: "https://www.amazon.com/dp/example-detail-page-2"
};
Get a delivery preview for a single item
The following example uses the deliveryPreview
query to get the delivery preview for a single item. To improve the accuracy and reliability of the delivery options presented to the shopper during checkout, this example takes into account both the shipping address that the shopper entered and the shopper identity.
Request
# Variables from sample data
inSearchOfLostTime
// GraphQL query
query deliveryPreview($input: DeliveryPreviewInput!) {
deliveryPreview(input: $input) {
id
deliveryGroups {
id
deliveryOffers {
id
date {
earliest
latest
}
policy {
messaging {
messageText
locale
badge
}
}
expiresAt
}
}
}
}
// Query variables
{
"input": {
"items": [
{
"itemIdentifier": {
"SKU": inSearchOfLostTime.sku
},
"amount": {
"unit:" "UNIT",
"value": 1
}
}
],
"terms": {
"location": {
"shippingAddress": {
"streetAddress": "410 Terry Ave N",
"locality": "Seattle",
"region": "WA",
"postalCode": "98109",
"countryCode": "US"
}
},
"shopperIdentity": {
"lwaAccessToken":{
"value": "EXAMPLE_LWA_ACCESS_TOKEN",
"externalId": "EXAMPLE_EXTERNAL_ID"
}
}
]
}
}
Response
{
"data":{
"deliveryPreview":{
"id":"example-delivery-preview-id",
"deliveryGroups":[
{
"id":"example-delivery-group-id",
"deliveryOffers":[
{
"id":"example-delivery-offer-id",
"date":{
"earliest":"2023-12-07T04:00:00Z",
"latest":"2023-12-07T04:00:00Z"
},
"policy":{
"messaging":{
"messageText":"Get it Tomorrow Dec 6",
"locale":"en-US",
"badge":"PRIME"
}
},
"expiresAt":null
}
]
}
]
}
}
}
Get a delivery preview for multiple items
The following example uses the deliveryPreview
query to get the delivery preview for a multiple items. To improve the accuracy and reliability of the delivery options presented to the shopper during checkout, this example takes into account both the shipping address that the shopper entered and the shopper identity.
Request
# Variables from sample data
inSearchOfLostTime
prideAndPrejudice
// GraphQL query
query deliveryPreview($input: DeliveryPreviewInput!) {
deliveryPreview(input: $input) {
id
deliveryGroups {
id
items {
itemIdentifier {
value
}
amount {
unit
value
}
}
deliveryOffers {
id
date {
earliest
latest
}
policy {
messaging {
messageText
locale
badge
}
}
expiresAt
}
}
}
}
// Query variables
{
"input": {
"items": [
{
"itemIdentifier": {
"SKU": inSearchOfLostTime.sku
},
"amount": {
"unit:" "UNIT",
"value": 1
}
},
{
"itemIdentifier": {
"SKU": prideAndPrejudice.sku
},
"amount": {
"unit:" "UNIT",
"value": 1
}
}
],
"terms": {
"location": {
"shippingAddress": {
"streetAddress": "410 Terry Ave N",
"locality": "Seattle",
"region": "WA",
"postalCode": "98109",
"countryCode": "US"
}
},
"shopperIdentity": {
"lwaAccessToken":{
"value": "EXAMPLE_LWA_ACCESS_TOKEN",
"externalId": "EXAMPLE_EXTERNAL_ID"
}
}
]
}
}
Response
{
"data":{
"deliveryPreview":{
"id":"example-delivery-preview-id",
"deliveryGroups":[
{
"id":"example-delivery-group-id",
"items":[
{
"itemIdentifier":{
"value":"example-item-id"
},
"amount": {
"unit:" "UNIT",
"value": 1
}
}
],
"deliveryOffers":[
{
"id":"example-delivery-offer-id-1",
"date":{
"earliest":"2023-12-11T04:00:00Z",
"latest":"2023-12-11T04:00:00Z"
},
"policy":{
"messaging":{
"messageText":"Get it as soon as Sun, Dec 10",
"locale":"en-US",
"badge":"PRIME"
}
},
"expiresAt":null
}
]
},
{
"id":"example-delivery-offer-id-2",
"items":[
{
"itemIdentifier":{
"value":"example-item-id"
},
"amount": {
"unit:" "UNIT",
"value": 1
}
}
],
"deliveryOffers":[
{
"id":"dbf63bfc-aa0a-4f6a-8d51-da419b310932",
"date":{
"earliest":"2023-12-11T04:00:00Z",
"latest":"2023-12-11T04:00:00Z"
},
"policy":{
"messaging":{
"messageText":"Get it as soon as Sun, Dec 10",
"locale":"en-US",
"badge":"PRIME"
}
},
"expiresAt":null
}
]
}
]
}
}
}
Related topics
Updated 3 days ago