Best Practices for Orders
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 best practices for when you Create and Manage Orders.
Providing order details
We recommend that you provide as many details to createOrder
as possible. In particular, we strongly recommend that you specify any monetary charges on the order, such as discounts or taxes, at the line-item level.
Providing payment details
Although you only need to provide minimal payment information, we recommend that you provide payment transaction details to help provide guidance for any shopper queries about the order.
Specifying a delivery preview
To avoid API call failures related to delivery previews, make sure that you heed the following requirements when you use createOrder
or updateOrder
to include line items for a Buy with Prime order. For details about troubleshooting orders, see Troubleshoot Order Errors.
- The identifiers that you provide to the
ProductIdentifierInput
of thecreateOrder
mutation must match the item identifiers of the selected delivery item from the response to adeliveryPreview
query. - The value in
AmountInput
must match the quantity of the delivery item in the selected delivery offer from thedeliveryPreview
response. - The
deliveryPreviewId
in theDeliveryOfferDetailsInput
must match thedeliveryPreviewId
from thedeliveryPreview
response. - The
selectedDeliveryOffer.details.id
in theDeliveryOfferDetailsInput
must match the selecteddeliveryOffer.id
from thedeliveryPreview
response. - If you pass a shipping address as an input to the
deliveryPreview
query, ensure that thedeliveryAddress
in theRecipientInput
of the call tocreateOrder
orupdateOrder
matches the shopper's provided shipping address that you used to generate the delivery preview. - The
shopperIdentity
information that you capture through theIdentityTokenInput
must match theshopperIdentity
information from thedeliveryPreview
response. If you pass in a valididpToken
that belongs to a different shopper , the API call fails with anValidationException
with codeShopperIdMismatch
.
Using order aliases
Order aliases enable you to associate Buy with Prime orders with unique identifiers in your systems. When you use order aliases, heed the following requirements:
- The Buy with Prime API requires order aliases to be unique across orders in the same store. If you use a non-unique order alias while you create or update an order, the API call fails with a
ValidationException
. - Currently, the Buy with Prime API allows a maximum of five order aliases per order. If the input has more than five order aliases, the API call fails with a
ValidationException
.
Updating the execution state
The OrderExecutionStateInput
enables you to configure when to trigger fulfillment of Buy with Prime items based on your ordering flows. The OrderExecutionStateInput
is an optional input. If you don't provide a value, the Buy with Prime API sets this state to NOT_STARTED
, which indicates that the order is confirmed but fulfillment hasn't started. When the order is in this state, you can call the updateOrder
mutation to set the desiredExecutionState
to STARTED
to start fulfillment.
However, the API call fails when the requested action can't be taken based on the value you provide to the API, such as in the following examples:
- If the
executionState
isSTARTED
and you callupdateOrder
to set the state toNOT_STARTED
, the API call fails with error codeInvalidOrderExecutionState
. To avoid this error, query the order to check theexecutionState
before you update the order. - If the
executionState
isSTARTED
and thepackageInformation
indicates that the delivery of the order isIN_TRANSIT
orCANCELLED
, if you callupdateOrder
to set the state toSTARTED
, the API call fails with error codeExecutionAlreadyStarted
orExecutionCannotBeStartedDueToCancellation
, respectively. To minimize this error, investigate the order execution flow in your system and avoid updating theexecutionState
in such cases.
Avoiding inventory failures
When you use the createOrder
mutation to place a Buy with Prime order, sometimes the requested item quantities aren't available in Buy with Prime inventory even though the deliveryOffer
for that item is still valid. This situation especially occurs when multiple shoppers try to purchase the same items and Buy with Prime inventory doesn't have sufficient quantities to fulfill all requests.
In these cases, the createOrder
mutation fails with a ValidationException
with code SelectedQuantityNotAvailable
. If the item is out of stock, the error code is ItemOutOfStock
. The best course of action in the case of these errors depends on whether you placed the order in your system yet. If you haven't placed the order in your system, it's best to surface these errors to shoppers to enable them to decide if they want to reduce the requested item quantity before placing the order.
Use sandbox shopper identity tokens during testing
In the sandbox environment, to call deliveryPreview
, shopperBwPEligibility
, or createOrder
, you must use one of the Sandbox shopper identity tokens.
Related topics
Updated 2 days ago