DELETE Requests in Postman
Now that we’ve learned how to send information to a server using an API endpoint, let’s explore how to delete content from it using a DELETE
request.
To avoid deleting the image we uploaded earlier, we’ll start this section by uploading a new image — this one of a very festive (and slightly grumpy) cat:
Here’s the response returned by the API when the image was uploaded:
Now we’re ready to delete that image from our personal collection using its ID.
DELETE Request
To understand how to use the DELETE
request in the context of The Cat API, let’s return to the documentation — specifically to:
DEL /images/:image_id
According to the docs, this request requires one path parameter:
image_id
:string
. Example:dMsUj1-nz
And, as usual, two header parameters — including our already familiar x-api-key: {{api_token}}
.
Let’s set up the request:
- Create a new request in your CatAPI collection and name it “Delete Cat Image”.
- Change the request type to
DELETE
. - Make sure the
CatAPI
environment is selected. - In the URL field, enter the following base:
{{url}}/images
- Copy the
id
value from your last successful image upload. In my case, it’sxsOtklMbs
. - Append the ID to the URL like this:
{{url}}/images/xsOtklMbs
- Go to the Headers tab and add your authentication header:
- Key:
x-api-key
- Value:
{api_token}
Now you’re ready to send the request!
You won’t receive a confirmation or warning before deletion, so make sure you’re removing the image you intended to.
If the request is successful, you’ll receive a 204 No Content
status — this means the image was deleted.
And that’s it! ✅
You may have noticed that the endpoint used to GET
or DELETE
a record is the same:
{{url}}/images/{image_id}
That’s one of the core principles of REST APIs:
Each data entity — like images — is addressed by a consistent URL, while the HTTP method (GET
, POST
, DELETE
, etc.) defines what action is performed on it.
The Cat API is a user-friendly tool for getting familiar with the basic concepts of REST APIs. It also helped us explore some key features of Postman, such as environments, headers, and request bodies.
As mentioned earlier, APIs can range from very simple to quite complex. The GitHub API falls somewhere in the middle. It’s highly comprehensive, but you can interact with many of its endpoints using just an authorization token.
In the next section, we’ll explore some of those endpoints through a series of hands-on exercises — introducing you to the use of APIs in a more “real-world” context.