Query a Buy with Prime 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.

This topic provides examples of how to get information about a Buy with Prime order. In general, you might want to query Buy with Prime orders in the following situations:

  • Before updating a Buy with Prime order (for example, to indicate that a pending refund was successful).
  • Before updating the status of a Buy with Prime order in your order management system (for example, if you receive a Buy with Prime PACKAGE_DELIVERY_CANCELLED event).
  • To show information, such as package tracking, on your site.

The query input takes either an orderIdentifier or an orderId, never both.

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.

Order identifier
orderIdentifier: { alias: { aliasType: "EXTERNAL_ID", aliasId: "example-alias-id" } }
Order aliases
{ "data": { "order": { "aliases": [ { "aliasId": "example-alias-id", "aliasType": "EXTERNAL_ID" } ] } } }
Customer
{ "data": { "order": { "id": "example-order-id", "customer": { "contact": { "id": "example-contact-id", "name": "John Doe", "email": "[john_doe@example.com](mailto:john_doe@example.com)" } } } } }
Tax summary
{ "data": { "order": { "id": "example-order-id", "taxes": { "summary": { "collectableTaxAmount": { "amount": 10, "currencyCode": "USD" } } } } } }
Discount summary
{ "data": { "order": { "id": "example-order-id", "discounts": { "summary": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100" } } } } }
Discount details
{ "data": { "order": { "id": "example-order-id", "discounts": { "details": \[ { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100", "aliases": [ { "aliasType": "EXTERNAL_ID", "aliasId": "M001" } ], "couponCode": "BWP001" } ] } } } }
Order total price
{ "data": { "order": { "id": "example-order-id", "totalPrice": { "summary": { "amount": { "amount": 10, "currencyCode": "USD" } }, "details": { "breakdown": [ { "breakdownType": "ORDER_SUB_TOTAL", "amount": { "amount": 10, "currencyCode": "USD" } } ], "amount": { "amount": 10, "currencyCode": "USD" } } } } } }
Payment summary
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "quantity": { "unit": "ONE", "amount": 1 }, "payments": { "summary": { "amount": { "amount": 10, "currencyCode": "USD" }, "paymentMethodDisplayString": "Visa ending in 1234", "state": "CAPTURED" } } } ], } } }
Payment details
{ "data": { "order": { "id": "example-order-id", "payments": { "details": [ { "id": "example-payment-transfer-id", "amount": { "amount": 10 }, "paymentMethod": { "displayString": "AmazonPay", "type": "AMAZON_PAY" }, "state": "SUCCESS", "payer": { "id": "amzn1.account.ABCDE12345" }, "aliases": [ { "aliasType": "EXTERNAL_ID", "aliasId": "PAY_001-123-456" } ], "createdAt": "2022-02-03T18:17:19Z", "updatedAt": "2022-02-04T18:17:19Z" } ] } } } }
Refund summary
{ "data": { "order": { "id": "example-order-id", "refunds": { "summary": { "refundTotal": { "totalAmount": { "amount": 30, "currencyCode": "USD" } }, "paymentSummary": { "amount": { "amount": 30, "currencyCode": "USD" }, "paymentMethodDisplayString": "Visa ending in 1234", "state": "REFUNDED" } } } } } }
Refund details
{ "data": { "order": { "id": "example-order-id", "refunds": { "details": [ { "id": "example-refund-id", "createdAt": "2022-02-03T18:17:19Z", "updatedAt": "2022-02-04T18:17:19Z", "aliases": { "aliasType": "EXTERNAL_ID", "aliasId": "example-refund-alias" }, "createdAt": "2022-02-03T18:17:19Z", "updatedAt": "2022-02-03T18:17:19Z", "refundTotal": { "totalAmount": { "amount": 30, "currencyCode": "USD" } }, "state": "SUCCESS", "refundFor": { "orderLineItems": [ { "lineItem": { "id": "example-line-item-id" }, "amount": { "value": 1 } } ] }, "paymentDetails": [ { "id": "example-payment-transfer-id", "amount": { "amount": 10 }, "paymentMethod": { "displayString": "AmazonPay", "type": "AMAZON_PAY" }, "state": "SUCCESS", "payer": { "id": "amzn1.account.12345ABCDE" }, "aliases": [], "createdAt": "2022-02-03T18:17:19Z", "updatedAt": "2022-02-04T18:17:19Z" } ] } ] } } } }
Returns
{ "data": { "order": { "id": "example-order-id", "returns": { "details": [ { "id": "example-refund-id", "createdAt": "2022-02-03T18:17:19Z", "updatedAt": "2022-02-03T18:17:19Z", "state": "COMPLETED", "returnFor": { "orderLineItems": [ { "lineItem": { "id": "example-line-item-id" }, "amount": { "value": 1 } } ] } } ] } } } }
Order metadata
{ "data": { "order": { "id": "example-order-id", "metadata": { "executionState": "NOT_STARTED", "createdAt": "2024-01-18T18:41:30.610Z", "updatedAt": "2024-01-18T18:41:30.610Z" } } } }
Order links
{ "data": { "order": { "id": "example-order-id", "orderLinks": [ { "destinationType": "BWP_STOREFRONT", "url": "https://order.buywithprime.amazon.com/1234ABCD/orders/example-order-id" } ] } } }

Email

This section contains a query that you can use to get order details for a confirmation email.

Get order details for a confirmation email

The following example gets information such as line items, customer details, and the order total. You might want this information for an order confirmation email.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id customer { contact { id name email } } lineItems { id quantity { unit amount } product { productId { value } title productDetailPageUrl image { displayReadyUrl sourceUrl altText } price { currencyCode amount } variationSelections { dimension value } } } totalPrice { summary { amount { amount currencyCode } } details { breakdown { breakdownType amount { amount currencyCode } } amount { amount currencyCode } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "customer": { "contact": { "id": "example-contact-id", "name": "John Doe", "email": "john_doe@example.com" } }, "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 2 }, "product":{ "productId": { "value": "product-id" }, "productDetailPageUrl": "productDetail-url" "image": { "displayReadyUrl": "https://example-image.jpeg", "sourceUrl": "example-image-url", "altText": "a11y friendly alternative text" }, "title": "example-title", "price": { "currencyCode": "USD", "amount":8.0 }, "variationSelections": [{ "dimension": "color", "value": "red" }] } } ], "totalPrice": { "summary": { "amount": { "amount": 10, "currencyCode": "USD" } }, "details": { "breakdown": [ { "breakdownType": "ORDER_SUB_TOTAL", "amount": { "amount": 10, "currencyCode": "USD" } }, { "breakdownType": "ORDER_TAX", "amount": { "amount": 2, "currencyCode": "USD" } }, { "breakdownType": "ORDER_SHIPPING", "amount": { "amount": 0, "currencyCode": "USD" } }, { "breakdownType": "DISCOUNT", "amount": { "amount": 2, "currencyCode": "USD" } }, ], "amount": { "amount": 10, "currencyCode": "USD" } } } } } }

Order detail page

This section contains queries that you can use to show items on an order detail page.

Get order details for an order detail page

The following example gets customer details, line items, delivery, and other information that you might show on an order detail page.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id customer { contact { id name email } } lineItems { id amount { unit value } product { productId { value } title productDetailPageUrl image { displayReadyUrl sourceUrl altText } price { currencyCode amount } variationSelections { dimension value } }, deliveryOffer { deliveryOfferDetails { deliveryProvider terms { isPrimeEligible deliverySpeed } taxes { summary { collectableTaxAmount { amount currencyCode } } } discounts { details { amount { amount currencyCode } couponCode aliases { aliasType } displayString } } } } taxes { summary { collectableTaxAmount { amount currencyCode } } } discounts { summary { amount { amount currencyCode } } } packageInformation { summary { state } } payments { summary { amount { amount } paymentMethodDisplayString state } } } taxes { summary { collectableTaxAmount { amount currencyCode } } } discounts { details { amount { amount currencyCode } couponCode aliases { aliasType } displayString } } totalPrice { summary { amount { amount currencyCode } } details { breakdown { breakdownType amount { amount currencyCode } } amount { amount currencyCode } } } payments { summary { amount { amount } paymentMethodDisplayString state } } refunds { details { id updatedAt state refundTotal { totalAmount { amount } } refundFor { orderLineItems { lineItem { id } } } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "customer": { "contact": { "id": "example-contact-id", "name": "John Doe", "email": "john_doe@example.com" } }, "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 }, "createdAt": "2024-01-18T18:41:30.569Z", "product": { "productId": { "value": "product-id" }, "title": "example-title", "image": { "displayReadyUrl": "https://example-image.jpeg", "sourceUrl": "example-image-url", "altText": "a11y friendly alternative text" }, "price": { "currencyCode": "USD", "amount":10.0 }, "variationSelections": [{ "dimension": "color", "value": "red" }] }, "deliveryOffer": { "deliveryOfferDetails": { "deliveryProvider": "AMAZON", "deliveryTerms": { "isPrimeEligible": true }, "taxes": { "summary": { "collectableTaxAmount": { "amount": 2, "currencyCode": "USD" } } }, "discounts": { "summary": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100" } } } }, "taxes": { "summary": { "collectableTaxAmount": { "amount": 2, "currencyCode": "USD" } } }, "discounts": { "summary": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100" } }, "packageInformation": { "summary": { "state": "PENDING" } }, "payments": { "summary": { "amount": { "amount": 10, "currencyCode": "USD" }, "paymentMethodDisplayString": "Visa ending in 1234", "state": "CAPTURED" } } } ], "taxes": { "summary": { "collectableTaxAmount": { "amount": 2, "currencyCode": "USD" } } }, "discounts": { "summary": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100" } }, "payments": { "summary": { "amount": { "amount": 10, "currencyCode": "USD" }, "paymentMethodDisplayString": "Visa ending in 1234", "state": "CAPTURED" } }, "totalPrice": { "summary": { "amount": { "amount": 10, "currencyCode": "USD" } }, "details": { "breakdown": [ { "breakdownType": "ORDER_SUB_TOTAL", "amount": { "amount": 10, "currencyCode": "USD" } }, { "breakdownType": "ORDER_TAX", "amount": { "amount": 2, "currencyCode": "USD" } }, { "breakdownType": "ORDER_SHIPPING", "amount": { "amount": 0, "currencyCode": "USD" } }, { "breakdownType": "DISCOUNT", "amount": { "amount": 2, "currencyCode": "USD" } }, ], "amount": { "amount": 10, "currencyCode": "USD" } } }, "refunds": { "details": [ { "id": "example-refund-id", "createdAt": "2022-02-03T18:17:19Z", "updatedAt": "2022-02-03T18:17:19Z", "aliases": { "aliasType": "EXTERNAL_ID", "aliasId": "example-alias-id" }, "refundTotal": { "totalAmount": { "amount": 30, "currencyCode": "USD" } }, "state": "SUCCESS", "refundFor": { "orderLineItems": [ { "lineItem": { "id": "example-line-item-id" }, "amount": { "value": 1 } } ] } } ] } } } }

Returns and refunds

This section contains queries that you can use to get information about the returns and refunds associated with an order.

Get all returns that have been initiated for an order

The following example gets all returns that have been initiated for an order. For possible return states, see ReturnDetails.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id returns { details { id createdAt updatedAt state returnFor { orderLineItems { lineItem { id } amount { value } } } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "returns": { "details": [ { "id": "example-refund-id", "createdAt": "2022-02-03T18:17:19Z", "updatedAt": "2022-02-03T18:17:19Z", "state": "COMPLETED", "returnFor": { "orderLineItems": [ { "lineItem": { "id": "example-line-item-id" }, "amount": { "value": 1 } } ] } } ] } } } }

Get refund details

The following example gets all refunds that are associated with an order. For possible refund states, see RefundDetails.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id lineItems { id quantity { unit amount } product { productId { value } title image { displayReadyUrl sourceUrl altText } price { currencyCode amount } variationSelections { dimension value } } refunds { details { id updatedAt state refundTotal { totalAmount { amount } } refundFor { orderLineItems { lineItem { id } amount { value } } } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 }, "createdAt": "2024-01-18T18:41:30.569Z", "product": { "productId": { "value": "product-id" }, "title": "example-item-title", "image": { "displayReadyUrl": "https://example-image.jpeg", "altText": "This is a picture of the item", "sourceUrl": "https://example-image-url.jpeg" }, "price": { "currencyCode": "USD", "amount":10.0 }, "variationSelections": [{ "dimension": "color", "value": "red" }] } } ], "refunds": { "details": [ { "id": "example-refund-id", "createdAt": "2022-02-03T18:17:19Z", "updatedAt": "2022-02-03T18:17:19Z", "aliases": { "aliasType": "EXTERNAL_ID", "aliasId": "example-alias-id" }, "refundTotal": { "totalAmount": { "amount": 30, "currencyCode": "USD" } }, "state": "SUCCESS", "refundFor": { "orderLineItems": [ { "lineItem": { "id": "example-line-item-id" }, "amount": { "value": 1 } } ] } } ] } } } }

Discounts and taxes

This section contains queries that you can use to get information about discounts that are associated with an order.

Get discount details and taxes that have been applied at the order and line-item level for an order

The following example looks for discount details and tax summary information at the order level, line item level, and delivery offer level. For details about discounts, see DiscountAllocationDetails.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id lineItems { id amount { unit value } deliveryOffer { deliveryOfferDetails { taxes { summary { collectableTaxAmount { amount currencyCode } } } discounts { details { amount { amount currencyCode } couponCode aliases { aliasType } displayString } } } } taxes { summary { collectableTaxAmount { amount currencyCode } } } discounts { details { amount { amount currencyCode } couponCode aliases { aliasType } displayString } } } taxes { summary { collectableTaxAmount { amount currencyCode } } } discounts { details { amount { amount currencyCode } couponCode aliases { aliasType } displayString } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "value": { "unit": "ONE", "value": 1 }, "deliveryOffer": { "deliveryOfferDetails": { "taxes": { "summary": { "collectableTaxAmount": { "amount": 2, "currencyCode": "USD" } } }, "discounts": { "details": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100", "aliases": [], "couponCode": "BWP001" } } } }, "taxes": { "summary": { "collectableTaxAmount": { "amount": 2, "currencyCode": "USD" } } }, "discounts": { "details": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100", "aliases": [], "couponCode": "BWP001" } } } ], "taxes": { "summary": { "collectableTaxAmount": { "amount": 2, "currencyCode": "USD" } } }, "discounts": { "details": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100", "aliases": [], "couponCode": "BWP001" } } } } }

Get summaries of all discounts and taxes that have been applied at the order and line-item level for an order

Discounts and taxes can be applied at the order level, line item level, and delivery offer level. The following example looks for discount and tax summary information at all levels.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id lineItems { id amount { unit value } deliveryOffer { deliveryOfferDetails { taxes { summary { collectableTaxAmount { amount currencyCode } } } discounts { summary { amount { amount currencyCode } } } } } taxes { summary { collectableTaxAmount { amount currencyCode } } } discounts { summary { amount { amount currencyCode } } } } taxes { summary { collectableTaxAmount { amount currencyCode } } } discounts { summary { amount { amount currencyCode } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 }, "deliveryOffer": { "deliveryOfferDetails": { "taxes": { "summary": { "collectableTaxAmount": { "amount": 2, "currencyCode": "USD" } } }, "discounts": { "summary": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100" } } } }, "taxes": { "summary": { "collectableTaxAmount": { "amount": 2, "currencyCode": "USD" } } }, "discounts": { "summary": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100" } } } ], "taxes": { "summary": { "collectableTaxAmount": { "amount": 2, "currencyCode": "USD" } } }, "discounts": { "summary": { "amount": { "amount": 1, "currencyCode": "USD" }, "displayString": "20% off on orders above $100" } } } } }

Customer, products, delivery, and payments

This section contains queries that you can use to get information about the customer, products, delivery, and payments that are associated with an order.

Get customer information for an order

The following example gets the customer information for an order. For details about customer information, see Customer.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id customer { contact { id name email } } } }
Response
{ "data": { "order": { "id": "example-order-id", "customer": { "contact": { "id": "example-contact-id", "name": "John Doe", "email": "john_doe@example.com" } } } } }

Get product information for all line items in an order

The following example gets the product information for all line items in an order. For details, see LineItem.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id lineItems { id amount { unit value } createdAt product { productId { value } title offerPrime productDetailPageUrl image { displayReadyUrl sourceUrl altText } price { currencyCode amount } variationSelections { dimension value } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 }, "createdAt": "2024-01-18T18:41:30.569Z", "product": { "productId": { "value": "product-id" }, "title": "example-item-title", "offerPrime": true, "image": { "displayReadyUrl": "https://example-image.jpeg", "altText": "This is a picture of the item", "sourceUrl": "https://example-image-url.jpeg" }, "price": { "currencyCode": "USD", "amount":10.0 }, "variationSelections": [{ "dimension": "color", "value": "red" }] } } ] } } }

Get package information for all line items in an order

The following example gets package information for all line items in an order. You can query for both PackageInformationSummary (minimal details like delivery state) and PackageInformationDetails (delivery state, estimated delivery date, tracking details, and so on). If an order only has summary information, the details will be empty.

Request
query order { order( orderIdentifier: { alias: { aliasType: "EXTERNAL_ID", aliasId: "example-alias-id" } } ) { id lineItems { id amount { unit value } packageInformation { summary { state } details { state reason deliverFromAddress { name streetAddress locality region countryCode postalCode } packageInformationDetailsFor { orderLineItems { lineItem { id } amount { value } } } packageTracker { packageTrackerIdentifier { trackingNumber carrierCode } estimatedDeliveryDate { earliest latest } latestMilestone { status { code message { locale value } } address { locality region country } occurredAt } milestones { status { code message { locale value } } address { locality region country } occurredAt } trackingUrl } } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 }, "packageInformation": { "summary": { "state": "PENDING" }, "details": [ { "state": "PENDING", "reason": null, "estimatedDeliveryDate": "2024-01-11", "deliverFromAddress": { "name": "John Doe", "streetAddress": "440 Terry Ave N", "locality": "Seattle", "region": "WA", "countryCode": "US", "postalCode": "98109" }, "packageInformationDetailsFor": { "orderLineItems": [ { "lineItem": { "id": "example-line-item-id" }, "amount": { "value": 1 } } ] }, "trackingDetails": { "trackingId": "example-tracking-id", "carrierCode": "UPS" } } ] } } ] } } }

Get package tracking information for a tracking page

The following example gets the estimated delivery date, latest milestone status, history of milestones for a package, and the items inside the package.

Request
query order($orderIdentifier: OrderIdentifierInput!) { order(orderIdentifier: $orderIdentifier) { id packageInformation { details { id state reason packageTracker { packageTrackerIdentifier { trackingNumber carrierCode } estimatedDeliveryDate { earliest latest } latestMilestone { status { code message { locale value } } address { locality region country } occurredAt } milestones { status { code message { locale value } } address { locality region country } occurredAt } trackingUrl } packageInformationDetailsFor { orderLineItems { lineItem { id amount { unit value } product { productId { value } title price { currencyCode amount } image { displayReadyUrl sourceUrl altText } variationSelections { dimension value } } } } } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "packageInformation": { "details": [{ "id": "example-package-id", "state": "DELIVERED", "reason": "example text about the package status", "packageTracker": { "packageTrackerIdentifier": { "trackingNumber": "example-package-tracking-numbaer", "carrierCode": "example-package-carrier-code" }, "estimatedDeliveryDate": { "earliest": "2024-09-20T14:21:11Z", "latest": "2024-09-20T14:21:11Z" }, "latestMilestone": { "status": { "code": "DELIVERED", "message": { "locale": "en-US", "value": "example text about the package milestone status" } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-09-20T09:21:11Z" }, "milestones": [{ "status": { "code": "DELIVERED", "message": { "locale": "en-US", "value": "example text about the package milestone status" } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-09-20T09:21:11Z" }, { "status": { "code": "OUT_FOR_DELIVERY", "message": { "locale": "en-US", "value": "example text about the package milestone status" } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-09-20T09:11:11Z" }, { "status": { "code": "IN_TRANSIT", "message": { "locale": "en-US", "value": "example text about the package milestone status" } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-09-20T09:01:11Z" }, { "status": { "code": "INFO_RECEIVED", "message": { "locale": "en-US", "value": "Order Placed" } }, "address": { "locality": "sample locality", "region": "sample region", "country": "US" }, "occurredAt": "2024-09-20T08:51:11Z" }], "trackingUrl": "https://example-track.com/track?id=example-tracking-number" }, "packageInformationDetailsFor": { "orderLineItems": [{ "lineItem": { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 }, "product": { "productId": { "value": "product-id" }, "title": "example-title", "price": { "currencyCode": "USD", "amount": 10.0 }, "image": { "displayReadyUrl": "https://example-image.jpeg", "sourceUrl": "example-image-url", "altText": "a11y friendly alternative text" }, "variationSelections": [{ "dimension": "color", "value": "red" }] } } }] } }] } } } }

Get all payments that have been applied at the order and line-item level for an order

While you create or update an order, you can input either a PaymentSummary that captures a summary of all payment transactions at the order and line-item level, or you can enter PaymentDetails to capture detailed information for each payment transaction. You can query for both summary and details, but the response contains either summary or details depending on what you passed in when you created or updated the order.

The following example gets payments at the order and line-item level in the case where the order was created with only a PaymentSummary at the line-item level.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id lineItems { id amount { unit value } payments { summary { amount { amount } paymentMethodDisplayString state } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 }, "payments": { "summary": { "amount": { "amount": 10, "currencyCode": "USD" }, "paymentMethodDisplayString": "Visa ending in 1234", "state": "CAPTURED" } } } ], } } }

The following example gets payments at the order and line-item level in the case where the order was created with a PaymentSummary at both the line-item level ($10 payment) and order level ($20 payment).

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id lineItems { id amount { unit value } payments { summary { amount { amount currencyCode } paymentMethodDisplayString state } } } payments { summary { amount { amount currencyCode } paymentMethodDisplayString state } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 }, "payments": { "summary": { "amount": { "amount": 10, "currencyCode": "USD" }, "paymentMethodDisplayString": "Visa ending in 1234", "state": "CAPTURED" } } } ], "payments": { "summary": { "amount": { "amount": 20, "currencyCode": "USD" }, "paymentMethodDisplayString": "Visa ending in 1234", "state": "CAPTURED" } } } } }

The following example gets payments at the order and line-item level in the case where the order was created with PaymentDetails at the order level.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id lineItems { id amount { unit value } payments { details { id amount { amount } paymentMethod { displayString type } state payer { id } aliases { aliasType aliasId } createdAt updatedAt } } } payments { details { id amount { amount } paymentMethod { displayString type } state payer { id } aliases { aliasType aliasId } createdAt updatedAt } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 }, "payments": { "details": [] } } ], "payments": { "details": [ { "id": "example-payment-transfer-id", "amount": { "amount": 10 }, "paymentMethod": { "displayString": "AmazonPay", "type": "AMAZON_PAY" }, "state": "SUCCESS", "payer": { "id": "amzn1.account.ABCDE12345" }, "aliases": [], "createdAt": "2022-02-03T18:17:19Z", "updatedAt": "2022-02-04T18:17:19Z" } ] } } } }

Overall order

This section contains queries that you can use to retrieve overall details about the order.

Get an order with the specified alias

An alias is an external ID, such as the order number in your own system, that you can optionally include when you create an order with the Order API. The following query gets an order with the specified alias. To query an order that has an alias, pass orderIdentifier in the query input. Note that the query input takes either an orderIdentifier (an alias) or an orderId (Buy with Prime order ID), never both.

Request
query order { order( orderIdentifier: { alias: { aliasType: "EXTERNAL_ID", aliasId: "example-alias-id" } } ) { id lineItems { id amount { unit value } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "amount": { "unit": "ONE", "value": 1 } } ] } } }

Get the order total, execution state, and last updated time for an order

The following example gets general information about an order. For details about order metadata, see OrderMetadata.

Request
query order { order(orderIdentifier: {orderId: "example-order-id"}) { id totalPrice { summary { amount { amount currencyCode } } details { breakdown { breakdownType amount { amount currencyCode } } amount { amount currencyCode } } } metadata { executionState createdAt updatedAt } } }
Response
{ "data": { "order": { "id": "example-order-id", "totalPrice": { "summary": { "amount": { "amount": 10, "currencyCode": "USD" } }, "details": { "breakdown": [ { "breakdownType": "ORDER_SUB_TOTAL", "amount": { "amount": 10, "currencyCode": "USD" } }, { "breakdownType": "ORDER_TAX", "amount": { "amount": 2, "currencyCode": "USD" } }, { "breakdownType": "ORDER_SHIPPING", "amount": { "amount": 0, "currencyCode": "USD" } }, { "breakdownType": "DISCOUNT", "amount": { "amount": 2, "currencyCode": "USD" } }, ], "amount": { "amount": 10, "currencyCode": "USD" } } }, "metadata": { "executionState": "NOT_STARTED", "createdAt": "2024-01-18T18:41:30.610Z", "updatedAt": "2024-01-18T18:41:30.610Z" } } } }

Order cancellation

This section contains queries that you can use to get cancellation information for an order.

Get the cancellation status for an order

This example shows how to check the cancellation status for an order. To see if the cancellation for an item succeeded or failed, see the order.lineItems[*].cancellations.details[*].state field of the response.

Request
// GraphQL query query order { order(orderIdentifier: {orderId: "example-order-id"}) { lineItems { cancellations { details { id state } } } } }
Response
{ "data": { "order": { "lineItems": [ { "cancellations": { "details": [ { "id": "example-order-cancellation-id", "state": "PENDING" } ] } } ] } } }

Get all cancellation details for an order

This example shows how to get all cancellation details for an order. Note that the cancellations object in the response contains cancellation details for each individual line item as well as the cancellation details for all of the line items in the order.

Request
// GraphQL query query order { order(orderIdentifier: {orderId: "example-order-id"}) { lineItems { id cancellations { details { id state aliases { aliasId aliasType } reason additionalComments canceledFor { orderLineItems { lineItem { id } amount { value } } } } } } } }
Response
{ "data": { "order": { "lineItems": [ { "id": "example-line-item-id-1", "cancellations": { "details": [ { "id": "example-cancellation-id", "state": "PENDING", "aliases": [ { "aliasType": "external-cancellation-id", "aliasId": "example-external-cancellation-id" } ], "reason": "OTHER", "additionalComments": "DAMAGED PRODUCT", "canceledFor": { "orderLineItems": [ { "lineItem": { "id": "example-line-item-id-1" }, "amount": { "value": 1 } }, { "lineItem": { "id": "example-line-item-id-2" }, "amount": { "value": 1 } } ] } } ] } }, { "id": "example-line-item-id-2", "cancellations": { "details": [ { "id": "example-cancellation-id", "state": "PENDING", "aliases": [], "reason": "OTHER", "additionalComments": "DAMAGED PRODUCT", "canceledFor": { "orderLineItems": [ { "lineItem": { "id": "example-line-item-id-1" }, "amount": { "value": 1 } }, { "lineItem": { "id": "example-line-item-id-2" }, "amount": { "value": 1 } } ] } } ] } } ] } } }

Get the cancellation and refund details for an order

This example shows how to check the cancellation and refund details for an order.

Request
// GraphQL query query order { order(orderIdentifier: {orderId: "example-order-id"}) { lineItems { cancellations { details { state aliases { aliasId aliasType } reason additionalComments canceledFor { orderLineItems { lineItem { id } amount { value } } } refundDetails { id state aliases { aliasType aliasId } createdAt updatedAt refundTotal { totalAmount { currencyCode amount } } refundFor { orderLineItems { lineItem { id } refundedQuantity { amount } } } paymentDetails { id amount { currencyCode amount } paymentMethod { displayString type } state } } } } } } }
Response
{ "data": { "order": { "lineItems": [{ "id": "example-line-item-id-1", "cancellations": { "details": [{ "id": "example-cancellation-id", "state": "PENDING", "aliases": [{ "aliasType": "external-cancellation-id", "aliasId": "example-external-cancellation-id" }], "reason": "CUSTOMER_REQUESTED", "additionalComments": "Customer requested to cancel", "canceledFor": { "orderLineItems": [{ "lineItem": { "id": "example-line-item-id-1" }, "amount": { "value": 1 } }, { "lineItem": { "id": "example-line-item-id-2" }, "amount": { "value": 1 } } ] }, "refundDetails": [{ "id": "example-refund-id-1", "state": "PENDING", "aliases": [], "createdAt": "2024-06-03T09:59:24.135Z", "updatedAt": "2024-06-03T09:59:24.307Z", "refundTotal": { "totalAmount": { "currencyCode": "USD", "amount": 10.00 } }, "refundFor": { "orderLineItems": [{ "lineItem": { "id": "example-line-item-id-1" }, "refundedQuantity": { "amount": 1 } }] }, "paymentDetails": [] }] }] } }, { "id": "example-line-item-id-2", "cancellations": { "details": [{ "id": "example-cancellation-id", "state": "PENDING", "aliases": [{ "aliasType": "external-cancellation-id", "aliasId": "example-external-cancellation-id" }], "reason": "CUSTOMER_REQUESTED", "additionalComments": "Customer requested to cancel", "canceledFor": { "orderLineItems": [{ "lineItem": { "id": "example-line-item-id-1" }, "amount": { "value": 1 } }, { "lineItem": { "id": "example-line-item-id-2" }, "amount": { "value": 1 } } ] }, "refundDetails": [{ "id": "example-refund-id-2", "state": "PENDING", "aliases": [], "createdAt": "2024-06-03T09:59:24.135Z", "updatedAt": "2024-06-03T09:59:24.307Z", "refundTotal": { "totalAmount": { "currencyCode": "USD", "amount": 10.00 } }, "refundFor": { "orderLineItems": [{ "lineItem": { "id": "example-line-item-id-2" }, "refundedQuantity": { "amount": 1 } }] }, "paymentDetails": [] }] }] } } ] } } }

Get line item IDs and package information details

This example shows how to get line item IDs and package information details. For example, you can use this query to determine whether you can display a "cancel order" button on your storefront. If the packageInformation.details.state isPENDING for all line items, you can display a "cancel order" button.

Request
// GraphQL query query order { order(orderIdentifier: {orderId: "example-order-id"}) { id lineItems { id packageInformation { details { id state } } } } }
Response
{ "data": { "order": { "id": "example-order-id", "lineItems": [ { "id": "example-line-item-id", "packageInformation": { "details": [ { "id": "example-delivery-information-id", "state": "PENDING" } ] }, } ] } } }

Related topics


Did this page help you?