Request Anatomy: Endpoint, Headers, Body

Request

Part of: Your First API Call

In lesson 4 the SDK built the request for you in one tidy messages.create call. Pop the hood and that call expands into three separate parts that every HTTP request on the internet shares: an endpoint , a set of headers , and a body . Knowing those three parts is the difference between "the SDK is magic" and "I know exactly what crossed the wire." What it is An HTTP request is a structured envelope with three pieces: - Endpoint : the URL you send to, plus the HTTP method. For Claude it's a POST to https://api.anthropic.com/v1/messages. The method POST means "I'm sending data up"; the path /v1/messages names the exact thing you want. - Headers : labeled metadata about the request: who you are and what format you're speaking. The two that matter here are your auth header (the API key from lesson 3) and content-type: application/json (telling the server "my body is JSON"). - Body : the actual payload: the JSON object (lesson 2) holding model, messages, and parameters like max tokens. How it works Picture mailing a package. The endpoint is the address on the box. The headers are the labels stuck on the outside, return address, "FRAGILE", "contents: documents". The body is what's actual

Challenge: Request Linter