HTTP raw examples

https://datatracker.ietf.org/doc/html/rfc9110

GET /users/42

Returns information about a single user.

Request

′′′ GET /users/42 HTTP/1.1 Host: api.example.com User-Agent: curl/8.5.0 Accept: application/json Accept-Encoding: gzip, deflate Authorization: Bearer eyJhbGciOiJIUzI1NiIs… Connection: keep-alive ′′′

Successful Response

′′′ HTTP/1.1 200 OK Date: Sun, 19 Jul 2026 18:35:12 GMT Server: ExampleAPI/2.4 Content-Type: application/json; charset=utf-8 Content-Length: 278 Cache-Control: private, max-age=60 ETag: “8d0c8d12” Last-Modified: Sun, 19 Jul 2026 18:30:01 GMT

{ “id”: 42, “username”: “alice”, “displayName”: “Alice Smith”, “email”: “alice@example.com”, “createdAt”: “2025-10-15T14:20:00Z”, “active”: true } ′′′

User Not Found

′′′ HTTP/1.1 404 Not Found Date: Sun, 19 Jul 2026 18:35:12 GMT Content-Type: application/json Content-Length: 78

{ “error”: “user_not_found”, “message”: “No user exists with id 42.” } ′′′

Unauthorized

′′′ HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer realm=“Example API” Content-Type: application/json

{ “error”: “invalid_token”, “message”: “Authentication is required.” } ′′′

POST /users

Creates a new user.

Request

′′′ POST /users HTTP/1.1 Host: api.example.com User-Agent: curl/8.5.0 Accept: application/json Content-Type: application/json Content-Length: 96 Authorization: Bearer eyJhbGciOiJIUzI1NiIs… Connection: keep-alive

{ “username”: “alice”, “displayName”: “Alice Smith”, “email”: “alice@example.com” } ′′′

Successful Response

′′′ HTTP/1.1 201 Created Date: Sun, 19 Jul 2026 18:35:12 GMT Server: ExampleAPI/2.4 Location: /users/42 Content-Type: application/json; charset=utf-8 Content-Length: 201

{ “id”: 42, “username”: “alice”, “displayName”: “Alice Smith”, “email”: “alice@example.com”, “createdAt”: “2026-07-19T18:35:12Z”, “active”: true } ′′′

Validation Error

′′′ HTTP/1.1 400 Bad Request Date: Sun, 19 Jul 2026 18:35:12 GMT Content-Type: application/json

{ “error”: “validation_failed”, “message”: “The ‘email’ field is required.” } ′′′

Unauthorized

′′′ HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer realm=“Example API” Content-Type: application/json

{ “error”: “invalid_token”, “message”: “Authentication is required.” } ′′′

This is a realistic HTTP exchange. It includes the headers typically seen in production APIs:

This style is suitable for protocol-level documentation because it shows the exact HTTP messages exchanged between the client and server rather than just the API schema.