Hi Support,
Create Order API was working fine and then all of a sudden I started getting the following error message.
{“errors”: [{“code”: “BAD_REQUEST”,“detail”: “Order EhdRM9MomA2IFZL6RQRYY5nNIb4F already exists.”,“category”: “INVALID_REQUEST_ERROR”}]}
I am creating brand new order and every time I create one, I get an error with an order id already exists error.
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
Additional Documentation
Orders API: How It Works
Handling Errors
https://developer.squareup.com/docs/orders-api/quick-start/start
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
This error typically occurs when you’re using the same idempotency key for multiple CreateOrder requests. The idempotency key is used to prevent duplicate creation of orders. If you use the same idempotency key to create a new order, the API assumes you’re trying to create the same order again and returns this error.
To resolve this issue, ensure that you’re generating a new unique idempotency key for each CreateOrder request. The idempotency key can be any string, but it must be unique for each new order.
This answer was reviewed by @Bryan-Square.