Explain the difference between POST and PUT when creating a resource.

Last updated 29 June 2026

Both can create a resource, but POST lets the server assign the URI and is non-idempotent, while PUT creates (or replaces) a resource at a client-specified URI and is idempotent.

  • POST to a collection:

    • POST /users: the server generates the ID and returns it (often with 201 Created and a Location header).

    • Calling it twice makes two resources, so it is not idempotent.

  • PUT to a specific URI:

    • PUT /users/42: the client chooses the identifier; the server creates it if absent or replaces it if present.

    • Calling it twice with the same body leaves the same single resource, so it is idempotent.

  • Rule of thumb: use POST when the server owns ID generation, PUT when the client knows the target URI.

  • https://www.sendowl.com/s/job-search
  • https://www.ashokit.in/blog/top-microservices-interview-questions-and-answers
  • https://www.resumeadapter.com/blog/full-stack-developer-resume-keywords
  • https://meduzzen.com/hire/backend-developers/
  • https://www.greatfrontend.com/blog/latest
  • https://prepfully.com/interview-guides/hubspot-software-engineer
  • https://www.getsmartresume.com/article/netflix-internship-new-grad-opportunities
All REST API interview questions