Search code examples
amazon-selling-partner-api

What is the easiest way to get buyer-initiated cancellations via SP API with Amazon?


I want to use the Amazon SP API to get all orders where the buyer has initiated a cancellation. From what I can tell, the only way to do this is by calling their get-orders request to get all orders that have been changed in the last X hours/minutes then calling their get-order-items request on each returned order. The issue is that if we do that in 30 minute increments, we are making well over 100 API requests every 30 minutes to Amazon just to see if there was a cancellation. Due to performance concerns, this is not feasible.

I have also seen that they have their Notifications/Subscriptions system, which seems like a fancy way to say webhook, but we don't yet have any webhook server set up on our end as the seller.

Is there an easy way to get just the buyer-initiated cancellations via SP API, or do we either have to do webhooks or call a bunch of APIs?


Solution

  • The best approach, as you said, is to handle the OrderChange notification, since you can get it as soon as the buyer requests a cancellation. I totally agree that there is a lot to do, especially if you don't use AWS, in order to start this process.

    If you want to stay light, and avoid calling the GetOrders API, you could try to use the Reports API and request either a GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL or a GET_XML_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL. In both of them there is an order-status / OrderStatus field that, if set to Cancelled, will tell you that the order has been canceled.

    Unfortunately they cannot be scheduled but, when you are creating it, you can filter them by last update date passing the dataStartTime and dataEndTime parameters (i.e. these two fields act on the last update date field, since those reports are "by last update").