Search code examples
restful-architectureapi-design

What is a proper verb for appending items to a resource in REST API?


My resource URL looks like this: /container/:id

I need an API to append items to a container, so I come up with something like /container/:id/items, now what should be the verb? POST?


Solution

  • Yes POST is correct here. It is used when creating new resources. An item in a container is a resource.

    Say your container is a chat, and items are chat messages,

    POST to /chat/:id/messages makes perfect sense.