Question:

What is a PUT request?

A PUT request is an HTTP request that replaces a resource on the server with the data you send. If POST creates something new, PUT updates something that already exists.

The key thing about PUT is that it replaces the entire resource. If you have a user with a name, email, and phone number, and you send a PUT with just a new name, you’re expected to include all the other fields too, otherwise they’ll be wiped out. PUT says “replace this resource with exactly what I’m sending.”

PUT is idempotent. Sending the same PUT request twice has the same result as sending it once. The resource ends up in the same state either way. This makes it safer to retry than a POST.

PATCH is the alternative when you only want to update part of a resource rather than replace it entirely. In practice, many APIs use POST or PATCH for updates and skip PUT altogether, but understanding the distinction helps when reading API documentation or designing your own.

You might also like