---
title: "Whoami"
description: "1 operation under /v1/whoami (GET): parameters, status codes, refusal bodies, and the same request in curl, HTTP, Python and TypeScript."
---

Base URL: `https://api.codespar.dev`

Every operation below requires a Bearer token. See [Authentication](/docs/concepts/authentication).

### GET `/v1/whoami`

<Endpoint method="GET" path="/v1/whoami" base="https://api.codespar.dev" />

What 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](/docs/api/reference/schemas#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. |

<Split min={380}>
<SplitPane label="Example request">

<Tabs items={["curl","HTTP","Python","TypeScript","SDK"]}>
<Tab value="curl">

```bash
curl -X GET https://api.codespar.dev/v1/whoami \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
```

</Tab>
<Tab value="HTTP">

```http
GET /v1/whoami HTTP/1.1
Host: api.codespar.dev
Authorization: Bearer $CODESPAR_API_KEY
```

</Tab>
<Tab value="Python">

```python
import 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()
```

</Tab>
<Tab value="TypeScript">

```ts
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();
```

</Tab>
<Tab value="SDK">

```ts
const result = await cs.api.get("/v1/whoami");
```

</Tab>
</Tabs>

</SplitPane>
<SplitPane label="Example response 200">

```json title="application/json"
{
  "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"
    ]
  }
}
```

</SplitPane>
</Split>

<TryIt method="GET" path="/v1/whoami" />

