3

I want to do a partial delete of resources, which means that after calling that API, some of the data will be deleted, but we will retain some minimal information about the deleted data, this data will be accessible by the user.

On the one hand, I read that DELETE doesn't guarantee to delete the resource, but this action is different from a complete delete and more similar to an update.

So what is the correct HTTP operation to use, DELETE or PATCH?

shinzou
  • 5,850
  • 10
  • 60
  • 124

1 Answers1

3

Yes, for example JSON patch document uses this approach. It has a Remove operation. You can use something similar in your API.

https://en.wikipedia.org/wiki/JSON_Patch

https://en.wikipedia.org/wiki/PATCH_(HTTP)

PATCH /users/123 { "op": "remove", "path": "./address" }

Another approach is creating a resource, which represents the part you want to delete.

DELETE /users/123/address
inf3rno
  • 24,976
  • 11
  • 115
  • 197