Skip to main content

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
View MarkdownEdit on GitHub

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

Every operation below requires a Bearer token. See Authentication.

GET /v1/whoami

GEThttps://api.codespar.dev/v1/whoami

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

StatusBodyDescription
200WhoamiOK

Response 200

FieldTypeRequiredDescription
keyobjectyes—
organizationobjectyes—
projectobjectyes—
userobject,nullyesAlways 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_KEY
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()
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
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"
    ]
  }
}

On this page

Whoami | CodeSpar