DEV Community

Cover image for How can I test my API key?
Edward Izgorodin
Edward Izgorodin

Posted on Edited on

How can I test my API key?

Send two requests before you trust it: one with no key at all, and one with a made-up key in the header the API documents. If the two answers differ, the API tells you whether a key reached it, and the answer to your real key means something. If the two answers are the same, a 401 cannot tell you whether your key arrived, and only a call that has to succeed proves the key works.

I sent exactly these two requests to six hosted memory APIs on 19 November 2026. Every request got a 401. Two APIs changed the message between the two requests, and four did not.

No key, then a made-up key, six memory APIs: Hindsight Cloud and Mnemoverse change the message, Letta Cloud, Mem0 Platform, Supermemory and Zep give the same answer both times

API (documented header) No key Made-up key in the documented header
Hindsight Cloud (Authorization: Bearer) "Authentication failed: API key required" "Authentication failed: Invalid API key format"
Mnemoverse (X-Api-Key) "Missing API key. Send X-Api-Key header." "This value does not have the shape of a Mnemoverse API key (mk_live_ followed by 32 lower-case hex characters)"
Letta Cloud (Authorization: Bearer) "Unauthorized" the same
Mem0 Platform (Authorization: Token) "Invalid API key. You can find your API key on https://app.mem0.ai/dashboard/api-keys." the same
Supermemory (Authorization: Bearer) "Unauthorized" the same
Zep (Authorization: Api-Key) "unauthorized" the same

Why a right key can still fail to arrive

An SDK sets the header for you. A proxy, a CI secret, a plain curl call or an MCP client configuration does not, and these six APIs alone use four ways to send a key: Bearer, Token and Api-Key in the Authorization header, and a separate X-Api-Key header. A key in a header the server does not read is, for the server, no key at all. At the four APIs that answer both requests the same way, that mistake looks exactly like a wrong key.

The two-minute check

URL=https://api.vendor.example/v1/some-endpoint
curl -s -w ' %{http_code}\n' "$URL"
curl -s -w ' %{http_code}\n' "$URL" -H "Authorization: Bearer not-a-real-key"
curl -s -w ' %{http_code}\n' "$URL" -H "Authorization: Bearer $KEY"
Enter fullscreen mode Exit fullscreen mode

Put the header your vendor documents in the second and third lines. If the first two answers differ, the third one tells you what happened to your key: the "missing" message means the header was not read, the "invalid" message means the key arrived and was rejected, and a 200 means it works. If the first two answers are the same, a 401 on the third line proves nothing, so test the key with a request that has to succeed, such as listing your own resources.

Sources and method. The requests were sent on 19 November 2026 with curl from one machine, one at a time, with the made-up key probe-not-a-real-key-0000000000; the answers are quoted as the APIs returned them that day. The same requests on 17 November got the same answers. No accounts or keys were created. This article describes the APIs as of 19 November 2026.

I work on Mnemoverse; this comparison uses the same two requests for every API, Mnemoverse included.

Top comments (3)

Collapse
 
ar9avg profile image
Arnav Gupta •

Nice method. The 'same answer twice tells you nothing' case is the one that bites in practice, and it gets worse with agents: an MCP client config that drops or renames a header leaves the agent staring at a 401 it cannot reason about, and it will happily retry the same wrong header forever. We ended up treating 'credential arrived but rejected' vs 'credential never arrived' as two distinct failure classes for exactly this reason. The no-key vs junk-key probe is a clean way to tell them apart.

Collapse
 
izgorodin profile image
Edward Izgorodin •

The retry loop is the part I would design for first. An agent can only tell a rejected key from a missing one if the tool passes it the status code and the error message, not just a failure. Two identical 401s in a row with the same header is a good point to stop and report, because nothing on the next attempt will be different.

Collapse
 
ar9avg profile image
Arnav Gupta •

Exactly, the loop is where the cost hides. Passing the status code and error body through to the agent instead of a bare failure makes each retry smarter too, not just the stop condition. Two identical 401s as the halt signal is a clean rule, I'll steal that one.