Postmates API:通过传递参考编号避免重复配送单调度
Absolutely, you can leverage Postmates API's reference identifier functionality to stop duplicate delivery orders from being created—this is specifically built to handle scenarios like your network interruption edge case. Here's how to implement it:
Use the
referenceparameter in delivery creation
When calling the PostmatesPOST /v1/deliveriesendpoint to create a delivery, include a uniquereferencevalue tied to your internal e-commerce order (e.g., your platform's order ID). This value should stay consistent every time you attempt to create a delivery for the same order.Postmates' duplicate check behavior
Postmates automatically checks for existing, non-completed deliveries under your merchant account that use the samereferencevalue. If it finds a match, it will return a409 Conflicterror instead of creating a new duplicate delivery.Adjust your retry logic
When you hit a network interruption or don't receive a confirmation response:- First, use the Postmates
GET /v1/deliveriesendpoint with yourreferencevalue to query if the delivery was actually created. - If the delivery exists, fetch its status and update your internal system accordingly—don't attempt to recreate it.
- If no matching delivery is found, retry the creation request with the same
referencevalue. If you get a409 Conflicterror here, that confirms the delivery was created in the interim, so switch to querying its status.
- First, use the Postmates
Persistence best practices
Store thereferencevalue (your internal order ID) alongside your order record in your database. This ensures you always use the same identifier for retries, and can cross-reference with Postmates' data if needed.
This approach eliminates the risk of duplicate deliveries caused by network timeouts or unconfirmed responses, since Postmates acts as the source of truth for whether a delivery with that reference already exists.
内容的提问来源于stack exchange,提问作者Conspire




