Show a curl example without a live API key

AI-assisted article. Reviewed by Codebuff automated editorial review on 2026-11-13. Examples are illustrative, not real user data.
A curl command is the clearest way to describe an API problem: the reader can run it and see the same response. It is also a command that carries an authorization header, a token in a query string or a cookie, and those survive in shell history, in the issue text and in every copy of it. Replacing the credential costs the reader nothing, as long as the flags and the request shape stay exactly as they were.
Where does the key hide in a curl example?
Credentials appear in three places in a curl invocation: an `Authorization` header, a query parameter such as `?api_key=`, and a cookie. All three are visible in the pasted text, and the first two are also in your shell history on the machine where you ran it.
If the key is already in the text you intend to send, replace it before sending rather than after. Rotating afterwards is the right response to an exposure, but it does not undo a paste that has already been read.
Replace the value, keep the flags
A reader reproducing your bug needs the method, the path, the content type, the body and the options that change error handling. None of those depend on the credential value. Use a shell variable or a visible placeholder, and say which environment variable you expect the reader to set.
Keep `--fail-with-body` if you used it, because the difference between a curl that exits zero on a 500 and one that fails is often the whole confusion. Keep `-v` out of the pasted command unless the verbose output is the evidence, and if it is, remove the request headers that carry the credential.
# What was run, credential included
curl -X POST https://pastesite.com/api/pastes -H "Authorization: Bearer [REDACTED_STRIPE_SECRET]" \
-H "Content-Type: application/json" -d '{"text":"hello"}'
# The same request, ready to share
curl --fail-with-body -X POST https://pastesite.com/api/pastes \
-H "Authorization: Bearer $PASTESITE_TOKEN" \
-H "Content-Type: application/json" -d '{"text":"hello"}'
# Response: HTTP 401
{"error":"Invalid token"}
Say what the request returned
The command is half the evidence; the response is the other half. Include the status code and the body, trimmed to the part that matters. A 401 with `{"error":"Invalid token"}` and a 403 with `{"error":"Scope denied"}` are different problems that look identical if you only say it did not work.
For a large response, keep the first few lines and the field that surprised you. If the response contains other people's data or a freshly issued token, replace those fields before pasting and say which ones you replaced.
Point at the documentation you used
An API example is more useful when it names the document it came from and the version of the API, because endpoints move and parameters get renamed. One line is enough, and it saves the reader from testing your command against a newer contract.
If the failure is that the documentation and the behaviour disagree, that is the finding. Show both, side by side, instead of only the request that failed.
Sources and editorial review
Prepared with AI assistance and checked against the code-sharing and API documentation pages at the reviewed revision: the three credential locations, flag preservation, response detail and documentation attribution. The example token is a fake prefix followed by REDACTED and the response body is illustrative.