POST https://api.humalike.com/v1/turn-taking/actions/whoami
Check that a token is valid and find out which account it belongs to. The call
takes no parameters — the account is read from the token itself.
Use it as a cheap preflight: call it once at startup to confirm a token still
works before sending real traffic, rather than discovering a revoked token on
your first billable call.
This call is free and never billed. See
Credits and billing.
Authorization
Request body
The request body is an empty object.
Response
The id of the account the token belongs to.
{
"user_id": "user_31kQd7mS2wYpLc8vF0aBnR4tXe"
}
Errors
| Status | Code | When |
|---|
401 | UNAUTHORIZED | The bearer token is missing, invalid, expired, or revoked. |
403 | forbidden | The token is valid but not allowed here. |
A 200 means the token is good. See Errors for the
envelope shape.
Example
curl https://api.humalike.com/v1/turn-taking/actions/whoami \
-H "Authorization: Bearer $HUMALIKE_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'
import os
import httpx
resp = httpx.post(
"https://api.humalike.com/v1/turn-taking/actions/whoami",
headers={"Authorization": f"Bearer {os.environ['HUMALIKE_TOKEN']}"},
json={},
)
if resp.status_code == 401:
raise SystemExit("token is invalid or revoked")
resp.raise_for_status()
print("authenticated as", resp.json()["user_id"])
const res = await fetch("https://api.humalike.com/v1/turn-taking/actions/whoami", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HUMALIKE_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
});
if (res.status === 401) throw new Error("token is invalid or revoked");
if (!res.ok) throw new Error(`whoami failed: ${res.status}`);
const { user_id } = await res.json();
Next