Echo API: see exactly what your HTTP client sends (headers, body, query)
When an API rejects your request, the first question is what the server actually got. Not what your code meant to send, but the bytes that arrived: the method, the query string, every header and the body. Logging on your side shows the first. An echo API shows the second, because it sends the request back to you as JSON.
This post uses the free echo endpoint at https://api.testingapis.com/api/echo. It needs no key, takes any method and any sub-path, and parses JSON, form and multipart bodies for you. Every response below was captured on 5 December 2026. The bugs it shows are real defaults in curl, fetch and Python requests.
What the echo API returns
$ curl -s -X POST "https://api.testingapis.com/api/echo/orders/42?source=cli" \
-H "Content-Type: application/json" -d '{"sku":"A-1","qty":2}'
{
"method": "POST",
"url": "https://api.testingapis.com/api/echo/orders/42?source=cli",
"path": "/api/echo/orders/42",
"subPath": "orders/42",
"query": { "source": "cli" },
"headers": { "Accept": "*/*", "User-Agent": "curl/8.18.0", "Content-Type": "application/json", "Content-Length": "21", ... },
"cookies": {},
"contentType": "application/json",
"contentLength": 21,
"body": "{\"sku\":\"A-1\",\"qty\":2}",
"bodyEncoding": "utf-8",
"bodyTruncated": false,
"json": { "sku": "A-1", "qty": 2 },
"jsonError": null,
"form": null,
"files": null,
"client": { "ip": "<your IP>", ... },
"protocol": "HTTP/1.1",
"timestamp": "2026-12-05T07:06:11Z"
}The response is trimmed for length (...), and the IP is replaced. The fields worth knowing:
| Field | What it tells you |
|---|---|
method | The verb that arrived. Useful after redirects, which can turn a POST into a GET |
subPath | Anything after /api/echo/, so you can check how your client joins a base URL and a path |
query | Parsed query parameters. A repeated key comes back as an array |
headers | Every header the server received, including ones your library added on its own |
contentType | The Content-Type header, or null if none was sent |
body | The raw body as text, or base64 for binary (bodyEncoding says which) |
json / jsonError | The parsed JSON body, or the parser's error message if the body isn't valid JSON |
form / files | Parsed form fields, and name, type and size for each uploaded file |
client | Your IP as the server saw it, and the X-Forwarded-For value |
It accepts GET, POST, PUT, PATCH, DELETE, HEAD and OPTIONS. Three shortcuts return one part only:
$ curl -s https://api.testingapis.com/api/echo/user-agent -A "demo/1.0"
{"userAgent":"demo/1.0"}
$ curl -s https://api.testingapis.com/api/echo/headers
{"count":23,"headers":{"Accept":"*/*","Host":"api.testingapis.com","User-Agent":"curl/8.18.0", ...}}
$ curl -s https://api.testingapis.com/api/echo/ip
{"ip":"<your IP>","port":0,"forwardedFor":"<your IP>","realIp":null}Bug 1: curl -d sends a form, not JSON
curl -d sets Content-Type: application/x-www-form-urlencoded unless you say otherwise. Send a JSON string that way and the server reads it as a form with one odd key:
$ curl -s -X POST https://api.testingapis.com/api/echo --data-binary '{"a":1}'
"contentType": "application/x-www-form-urlencoded",
"json": null,
"form": { "{\"a\":1}": "" }An API that only accepts JSON answers this with a 415 or a 400, and the body looks fine in your terminal, which is why it takes a while to spot. Add -H "Content-Type: application/json", or use --json on curl 7.82 or newer, which sets both Content-Type and Accept.
Bug 2 and 3: fetch and the missing header, and arrays in the query
fetch has the same trap. Pass a string body with no header and it sends text/plain;charset=UTF-8. And URLSearchParams, given an object with an array, joins the array with a comma:
const URL_ = "https://api.testingapis.com/api/echo";
const pick = (d) => ({ contentType: d.contentType, json: d.json });
// A JSON body without a Content-Type header
let r = await fetch(URL_, { method: "POST", body: JSON.stringify({ sku: "A-1", qty: 2 }) });
console.log("no header ", JSON.stringify(pick(await r.json())));
// The same body with the header
r = await fetch(URL_, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ sku: "A-1", qty: 2 }),
});
console.log("with header ", JSON.stringify(pick(await r.json())));
// An array in the query string, built two ways
const tags = ["red", "blue"];
r = await fetch(`${URL_}?${new URLSearchParams({ tags })}`);
console.log("object ", JSON.stringify((await r.json()).query));
r = await fetch(`${URL_}?${new URLSearchParams(tags.map((t) => ["tags", t]))}`);
console.log("pairs ", JSON.stringify((await r.json()).query));$ node fetch-demo.mjs
no header {"contentType":"text/plain;charset=UTF-8","json":null}
with header {"contentType":"application/json","json":{"sku":"A-1","qty":2}}
object {"tags":"red,blue"}
pairs {"tags":["red","blue"]}tags=red%2Cblue is one value, "red,blue". Most servers expect tags=red&tags=blue, so a filter that should match two tags matches none. Build the params from key/value pairs, or call append once per item, and the echo shows an array.
Bug 4: requests data= vs json=
In Python requests, data= with a dict form-encodes it and json= serialises it as JSON. Both look reasonable in code:
import requests
URL = "https://api.testingapis.com/api/echo"
order = {"sku": "A-1", "qty": 2, "tags": ["red", "blue"]}
for label, kwargs in [("data=", {"data": order}), ("json=", {"json": order})]:
d = requests.post(URL, timeout=10, **kwargs).json()
print(f"{label:6} {d['contentType']:35} json={d['json']} form={d['form']}")$ python req_demo.py
data= application/x-www-form-urlencoded json=None form={'sku': 'A-1', 'qty': '2', 'tags': ['red', 'blue']}
json= application/json json={'sku': 'A-1', 'qty': 2, 'tags': ['red', 'blue']} form=NoneWith data=, the number 2 arrives as the string "2", and the server has no way to tell. A form can't carry types or nesting, so a nested object loses its structure. The echo makes the difference plain in one call.
Bodies the server can't read
The echo keeps the raw body even when it can't parse it, and it says what went wrong. That helps when you build JSON by hand, or with multipart uploads, where the library writes the boundary for you:
# Broken JSON: the raw body is kept, and the parser error tells you where
$ curl -s -X POST https://api.testingapis.com/api/echo -H "Content-Type: application/json" -d "{'sku':1,}"
"json": null,
"jsonError": "''' is an invalid start of a property name. Expected a '\"'. LineNumber: 0 | BytePositionInLine: 1."
# Multipart: fields and file metadata, not the file bytes
$ curl -s -X POST https://api.testingapis.com/api/echo -F note=hi -F file=@a.txt
"form": { "note": "hi" },
"files": [{ "field": "file", "fileName": "a.txt", "contentType": "text/plain", "size": 5 }]
# Binary: returned as base64
$ curl -s -X POST https://api.testingapis.com/api/echo -H "Content-Type: application/octet-stream" --data-binary @b.bin
"body": "ztJhE78lMJc=", "bodyEncoding": "base64", "contentLength": 8Bodies over 1 MiB (1,048,576 bytes) are cut off, and bodyTruncated is true, while contentLength still reports the full size. For uploads in more depth, see the multipart upload testing guide. For responses that are broken on purpose, to test your parser rather than your sender, see the edge-case endpoints.
Test your API client against the echo
Most apps wrap fetch in a small client that adds a base URL, a token and a trace id. Those wrappers are rarely tested, because the usual way is to mock fetch, and then the test only checks that you called your mock the way you meant to. Point the wrapper at the echo API instead, and you assert on what really went over the wire:
// A small wrapper of the kind most apps have: base URL, token, trace id, JSON body.
export function createClient({ baseUrl, token }) {
return async function request(method, path, { query, body } = {}) {
const url = new URL(path.replace(/^\//, ""), baseUrl.endsWith("/") ? baseUrl : baseUrl + "/");
for (const [k, v] of Object.entries(query ?? {})) {
for (const item of [].concat(v)) url.searchParams.append(k, item);
}
const headers = { Accept: "application/json", Authorization: `Bearer ${token}`, "X-Trace-Id": crypto.randomUUID() };
if (body !== undefined) headers["Content-Type"] = "application/json";
const res = await fetch(url, {
method,
headers,
body: body === undefined ? undefined : JSON.stringify(body),
signal: AbortSignal.timeout(5000),
});
return res.json();
};
}import { test } from "node:test";
import assert from "node:assert/strict";
import { createClient } from "./api-client.js";
// Point the client at the echo API instead of the real backend.
const api = createClient({ baseUrl: "https://api.testingapis.com/api/echo", token: "test-token" });
test("keeps the path and sends the token", async () => {
const seen = await api("GET", "/orders/42");
assert.equal(seen.method, "GET");
assert.equal(seen.subPath, "orders/42");
assert.equal(seen.headers.Authorization, "Bearer test-token");
});
test("repeats array query params instead of joining them", async () => {
const seen = await api("GET", "/orders", { query: { status: ["paid", "shipped"], page: 2 } });
assert.deepEqual(seen.query, { status: ["paid", "shipped"], page: "2" });
});
test("sends the body as JSON, with the header", async () => {
const seen = await api("POST", "/orders", { body: { sku: "A-1", qty: 2 } });
assert.equal(seen.contentType, "application/json");
assert.deepEqual(seen.json, { sku: "A-1", qty: 2 });
assert.equal(seen.jsonError, null);
});
test("a GET has no body and no Content-Type", async () => {
const seen = await api("GET", "/orders");
assert.equal(seen.contentLength, 0);
assert.equal(seen.contentType, null);
});
test("every request gets its own trace id", async () => {
const [a, b] = await Promise.all([api("GET", "/a"), api("GET", "/b")]);
assert.match(a.headers["x-trace-id"], /^[0-9a-f-]{36}$/);
assert.notEqual(a.headers["x-trace-id"], b.headers["x-trace-id"]);
});$ node --test api-client.test.js
✔ keeps the path and sends the token (635.8443ms)
✔ repeats array query params instead of joining them (268.8088ms)
✔ sends the body as JSON, with the header (267.9208ms)
✔ a GET has no body and no Content-Type (270.5796ms)
✔ every request gets its own trace id (544.3635ms)
ℹ tests 5
ℹ pass 5
ℹ fail 0| Test | The bug it catches |
|---|---|
| Path and token | A base URL joined with new URL() drops its own path when the second part starts with a slash |
| Array query params | The comma-joined tags=red,blue from bug 3 |
| JSON body with header | Bugs 1 and 2: a JSON string labelled as text or a form |
| GET has no body | A wrapper that sends an empty body or a Content-Type on every call, which some servers and proxies reject |
| Own trace id | An id created once when the module loads, so every request shares it |
The first test is the one that catches the most. new URL("/orders", "https://host/api/echo") gives https://host/orders, because a leading slash means "from the root". That's why the wrapper strips it and adds a trailing slash to the base. Remove that line and the test fails with a 404.
These tests need the network, so run them in a separate job from your unit tests. To get the same calls as code in another language, paste the curl commands into the curl to Python or curl to JavaScript converter.
Questions
What is an echo API?
An HTTP endpoint that answers every request with a description of that request: method, URL, headers and body. It exists for debugging and testing clients, proxies and webhooks. The response doesn't depend on any stored data, so it is the same for everyone.
Is this the same as httpbin's /anything?
Close to it. /api/echo covers /anything, /headers, /ip and /user-agent, and it adds parsed json, jsonError, cookies and file metadata. The httpbin alternative guide maps every common httpbin route to its equivalent here.
Is it safe to send real tokens to an echo API?
No. Use test tokens, like test-tokenabove. The request travels over HTTPS, but any echo service, this one included, sees everything you send, and the response contains it in plain text. Don't send real credentials or personal data to any public test endpoint.
How do I see where a redirect sends my request?
Use the redirect endpoints: every one ends at /api/echo, so the last response shows what survived. With curl -L -d x=1 .../api/redirect/status/302 the echo reports a GET with no form, because clients turn a POST into a GET after a 302. With /status/307 it reports a POST with {"x":"1"} still in the form.
Can I inspect requests that someone else's server sends to me?
That is a webhook, and it needs a URL that stores requests so you can read them later. Use the webhook tester, or see webhook testing for signed webhooks.
All the echo endpoints, with request samples in several languages, are in the echo API reference.