What are the HTTP methods used in REST APIs?

HTTP methods are the standard set of verbs a client uses to tell a server what kind of action to perform on a resource.

Key Points

Example

A blog API uses GET /posts/1 to read a post, POST /posts to create a new one, PUT /posts/1 to replace it entirely, PATCH /posts/1 to update just the title, and DELETE /posts/1 to remove it.

@RestController
@RequestMapping("/posts")
public class PostController {

    @GetMapping("/{id}")                       // read: safe, idempotent -> 200
    public Post get(@PathVariable Long id) { return service.find(id); }

    @PostMapping                               // create: not idempotent -> 201
    @ResponseStatus(HttpStatus.CREATED)
    public Post create(@RequestBody NewPost p) { return service.create(p); }

    @PutMapping("/{id}")                       // replace whole resource: idempotent -> 200
    public Post replace(@PathVariable Long id, @RequestBody NewPost p) { return service.replace(id, p); }

    @PatchMapping("/{id}")                     // partial update -> 200
    public Post rename(@PathVariable Long id, @RequestBody Map<String, String> changes) {
        return service.updateTitle(id, changes.get("title"));
    }

    @DeleteMapping("/{id}")                    // delete: idempotent -> 204
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public void delete(@PathVariable Long id) { service.delete(id); }
}

Interview Tip

A concise interview answer is

The core HTTP methods are GET for reading, POST for creating, PUT for replacing a resource entirely, PATCH for partial updates, and DELETE for removing a resource. They map cleanly onto CRUD operations, which is why REST APIs are built around them.

Last updated: 11 November 2026

Previous question: How would you use the JUnit @Before, @After and @BeforeAll annotations in a practical test case?

Next question: When should you use each HTTP method in a RESTful API?

More Spring Boot - Level IV (Advanced) interview questions

All Spring Boot - Level IV (Advanced) questions