C#C
C#2y ago
LazyGuard

✅ Which API design is better

I have orders that can be put in an issue status and then resolve that issue

There is two options:
  1. The first one is having two different endpoints
    PATCH /orders/{orderId}/create-issue with the following body
    {
    "issueDate": ......
    "reason": ......
    }
and

PATCH /orders/{orderId}/resolve with the following body
{
  "resolveDate": ......
  "solution": ......
}


  1. The second one is having a single endpoint
PATCH /orders/{orderId}/issue and we either pass an issueDate + reason OR resolveDate + solution plus a validation if we pass inconsistent data (for example passing a body that contains a reason + solution will result in a validation error since we can not create an issue and resolve it at the same time

Question: Which option is better and why?
Was this page helpful?