What do you want to do?
When you send a request to a server, the very first thing you must specify is the verb (also called the method). This tells the server what action you want to perform on a specific resource. The URL identifies which resource; the verb identifies what to do with it.
Here are the four most common verbs, mapped to CRUD (Create, Read, Update, Delete) operations:
- GET (Read): "Please retrieve this data for me." The request has no body — you're only asking, not sending data. Example: Loading a webpage, fetching a user's profile.
- POST (Create): "Here is some new data; please accept and process it." The request carries a body with the new data. Example: Submitting a signup form, posting a tweet, placing an order.
- PUT (Update/Replace): "Here is a complete, updated version of a resource. Replace whatever you have with this." The entire resource is sent in the body. Example: Updating your entire user profile settings.
- DELETE (Delete): "Remove this resource." Typically has no body. Example: Deleting a photo from your account.
Two additional verbs appear frequently in practice:
- PATCH (Partial Update): Like PUT, but you only send the fields that changed, not the entire resource. Example: Changing just your email address without resending your entire profile.
- HEAD: Identical to GET, but the server returns only the headers — no body. Useful for checking whether a resource exists or has changed without downloading it.
The verb and URL together form the request line, the very first line of any HTTP request:
GET /users/42 HTTP/1.1
This reads: "Using HTTP version 1.1, perform a GET on the resource at path /users/42."
Key Point: The HTTP verb specifies the action; the URL specifies the resource. A well-designed API uses verbs and URLs together to make intent unambiguous — DELETE /photos/123 is clearer than POST /deletePhoto?id=123.