Developer

The Anatomy of a REST API Request: A Step-by-Step Walkthrough

Method, URL, headers, body, and the response, one piece at a time

By Kiran · 6 min read · 23-07-2026

The Anatomy of a REST API Request: A Step-by-Step Walkthrough

Every time an app loads your profile, saves a note, or checks out a cart, it sends a REST API request across the network and waits for an answer. It feels instant and invisible, but underneath there is a precise, predictable structure. Learn the anatomy of a REST API request once and almost every backend, mobile, and frontend bug becomes easier to read. This is a plain, step-by-step walkthrough of what actually travels over the wire and what comes back.

What a REST API request really is

REST stands for Representational State Transfer. In practice it means one thing: you act on resources (a user, an order, a photo) using standard HTTP. A REST API request is just a carefully formatted HTTP message that says what you want to do, to which resource, with what data, and who is asking. The server reads that message and sends back a response with a status code and, usually, some data.

Four parts make up the request: the request line (method plus URL), the headers, an optional body, and the network journey that carries it. Let's take them in order.

1. The request line: method and URL

The first line of a REST API request pairs an HTTP method with a URL. The method is the verb, the URL is the noun.

  • GET reads a resource and changes nothing. GET /api/users/42 fetches user 42.
  • POST creates a new resource inside a collection. POST /api/users adds a user.
  • PUT replaces a resource entirely, PATCH updates part of it.
  • DELETE removes a resource.

The URL has parts worth naming: the path (/api/users/42) points at the resource, and the query string (?fields=name,email&active=true) filters or shapes the result. A good REST URL reads like a sentence: this method, on that path. If you find yourself putting verbs in the path, like /api/getUser, that is a sign the method is doing the wrong job.

Labelled breakdown of a POST request showing request line, headers, and JSON body
The four parts of every request: method and URL, headers, and body.

2. Headers: the metadata around the message

Headers are key-value pairs that describe the request without being the request's content. They are easy to overlook and responsible for a huge share of real-world API bugs. The ones you meet daily:

  • Content-Type tells the server how to read the body, for example application/json. Send JSON without this header and many servers will refuse to parse it.
  • Accept tells the server what format you want back, usually application/json.
  • Authorization proves who you are, most often a bearer token: Authorization: Bearer <token>.
  • User-Agent and Content-Length are filled in for you by most HTTP clients.

A useful mental model: the body is the letter, the headers are everything written on the envelope. If the envelope is wrong, the letter never gets read correctly.

3. The body: the data you send

GET and DELETE requests usually carry no body. POST, PUT, and PATCH do, and for a REST API request that body is almost always JSON:

POST /api/users
Content-Type: application/json

{
  "name": "Ada Lovelace",
  "email": "[email protected]"
}

The body is where the actual payload lives. Two rules save hours of debugging. First, the body's format must match the Content-Type header exactly. Second, keep the body flat and predictable, because the shape you send is the contract the server validates against. A single stray comma or a field the API does not expect is the most common cause of a 400 Bad Request.

4. The journey: how the request reaches the server

Between pressing send and the server reading your request, a few things happen fast. The client resolves the domain name to an IP address through DNS. It opens a TCP connection, and for any HTTPS URL it performs a TLS handshake to encrypt the channel. Only then does your formatted request travel to the server, often passing through a load balancer, a gateway, or a reverse proxy on the way in.

You rarely touch this layer directly, but it explains real symptoms. A hostname typo surfaces as a DNS error, an expired certificate as a TLS error, and a slow first request as connection setup time. None of these are problems with your JSON. Knowing the layers means you stop debugging the body when the failure is three steps earlier.

5. The response: status code, headers, and body

The server answers with the same three-part shape: a status line, headers, and usually a body. The status code is the first thing to read, because it tells you which world you are in.

  • 2xx success. 200 OK for a normal read, 201 Created when a POST made something new, 204 No Content when the action worked but there is nothing to return.
  • 3xx redirection. The resource lives elsewhere now; the Location header points to the new URL.
  • 4xx client error. You sent something wrong. 400 is a malformed request, 401 means the server does not know who you are, 403 means it knows you but you are not allowed, 404 means the resource does not exist, 429 means you are rate limited.
  • 5xx server error. The request was fine but the server broke. 500 is a generic failure, 503 means the service is temporarily unavailable.

The line between 401 and 403 trips up almost everyone, so it is worth memorizing: 401 is "who are you?", 403 is "I know you, and no." Response headers then add context (Content-Type of the reply, caching hints, rate-limit counters), and the response body carries the data or an error message you can show the user.

The four HTTP status code families 2xx, 3xx, 4xx and 5xx with examples
Read the status code first: it tells you which of four worlds you are in.

Putting it together: one full round trip

Here is a complete REST API request and its response, end to end:

GET /api/orders/1001 HTTP/1.1
Host: api.example.com
Accept: application/json
Authorization: Bearer eyJhbGciOi...

--- response ---

HTTP/1.1 200 OK
Content-Type: application/json

{ "id": 1001, "status": "shipped", "total": 48.00 }

Read it top to bottom and every part has a job: the method and path name the action and the resource, the headers carry format and identity, the status code reports the outcome, and the body delivers the data. Once you see a request this way, tools like Postman, curl, and your browser's network tab stop looking like noise and start reading like a story.

Common mistakes and how to spot them

  • Forgetting Content-Type on a JSON body. The server cannot parse what it does not know is JSON. Symptom: a confusing 400 or an empty parsed body.
  • Confusing PUT and PATCH. PUT replaces the whole resource, so any field you omit can be wiped. Reach for PATCH when you mean to change one thing.
  • Reading only the body, ignoring the status. A 200 with an error message inside is a broken API, but a 500 with no body is a broken server. The status tells you which.
  • Retrying non-idempotent calls. Retrying a GET is safe. Blindly retrying a POST can create duplicate records.

Where to go from here

The anatomy is small and it repeats everywhere: method, URL, headers, body, and a status-coded response. Master those five pieces and you can read any API, from a payment gateway to a weather feed, without guessing. The diagrams in this article were built with Thridy's soft-3D server and code icons; if you are documenting your own API or drawing architecture diagrams, you can browse the full set in the 3D icon gallery or by theme in the category index. Clear visuals make a request's anatomy click a lot faster than a wall of text.

Key takeaways

  • A REST API request is just a formatted HTTP message: method, URL, headers, and an optional body.
  • Headers carry format and identity; the body's format must match its Content-Type header.
  • Read the response status code before the body: 2xx worked, 4xx is your mistake, 5xx is the server's.
  • 401 means who are you, 403 means I know you and no.
  • PUT replaces a whole resource, PATCH updates part of it, and GET should never change anything.

Questions people ask

What are the main parts of a REST API request?

Four parts: the request line (an HTTP method plus a URL), the headers (metadata like Content-Type and Authorization), an optional body carrying the data, and the network journey that delivers it. The server answers with a status code, response headers, and a response body.

What is the difference between 401 and 403 status codes?

A 401 Unauthorized means the server does not know who you are, so authentication is missing or invalid. A 403 Forbidden means the server knows who you are but you are not allowed to perform that action. Short version: 401 is who are you, 403 is I know you and no.

Which HTTP methods carry a request body?

POST, PUT, and PATCH typically carry a body, usually JSON. GET and DELETE normally do not. Whenever you send a body, set the Content-Type header so the server knows how to parse it.

Why does my JSON request return a 400 Bad Request?

The most common causes are a missing or wrong Content-Type header, malformed JSON such as a trailing comma, or a field the API does not expect. Check that the body matches the API contract and that Content-Type is application/json.

What is the difference between PUT and PATCH?

PUT replaces the entire resource, so any field you leave out can be cleared. PATCH updates only the fields you send. Use PATCH when you mean to change one part of a resource without touching the rest.

Sources

This article was produced with the help of generative AI, drawing on the sources above, and reviewed by a human before publishing. All 3D icons shown are original artwork from Thridy. If you spot anything that needs a correction, let us know.

Enjoyed this article?

Subscribe to the Thridy Journal. One great story at a time, no noise.

Keep reading