Whoami
1 operation under /v1/whoami (GET): parameters, status codes, refusal bodies, and the same request in curl, HTTP, Python and TypeScript.
1 min read
Base URL: https://api.codespar.dev
Every operation below requires a Bearer token. See Authentication.
GET /v1/whoami
GET
https://api.codespar.dev/v1/whoamiWhat this credential is
The cheapest way to prove a key works and to see which org, project and environment it resolves to. key.scopes is what the key holds, which is not the same as what each route requires. It names no person: user is null for an API key.
Responses
| Status | Body | Description |
|---|---|---|
200 | Whoami | OK |
Response 200
| Field | Type | Required | Description |
|---|---|---|---|
key | object | yes | — |
organization | object | yes | — |
project | object | yes | — |
user | object,null | yes | Always null for an API key and for an OAuth token: a key is scoped to an org and a project, not to a user, so there is no person to name. Identify the credential by organization, project and key. A person appears only on the service path the dashboard uses, and is the member it is acting for. |
Example request
curl -X GET https://api.codespar.dev/v1/whoami \
-H "Authorization: Bearer $CODESPAR_API_KEY"GET /v1/whoami HTTP/1.1
Host: api.codespar.dev
Authorization: Bearer $CODESPAR_API_KEYimport os
import requests
res = requests.get(
"https://api.codespar.dev/v1/whoami",
headers={"Authorization": f"Bearer {os.environ['CODESPAR_API_KEY']}"},
)
res.raise_for_status()
data = res.json()const res = await fetch("https://api.codespar.dev/v1/whoami", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
},
});
const data = await res.json();const result = await cs.api.get("/v1/whoami");Example response 200
{
"user": {
"email": "person@example.com",
"name": "Example"
},
"organization": {
"id": "whoami_0000000000000000",
"name": "Example"
},
"project": {
"id": "whoami_0000000000000000",
"name": "Example"
},
"key": {
"id": "whoami_0000000000000000",
"environment": "string",
"scopes": [
"string"
]
}
}