42ADocs

Quickstart

Make your first API call in under five minutes.

Generate an API key

Open Settings → API keys in the 42A dashboard and click Create key. Copy the key immediately - it's shown once.

Two key types are supported:

  • Org keys - bound to one organization. Use these for backend integrations.
  • User keys - tied to your user; can act on any org you belong to. Use these when an agency manages multiple client orgs.

Make a call

export KEY=ck_live_...

curl -H "Authorization: Bearer $KEY" \
  https://api.42a.ai/api/v1/_health
const KEY = process.env.API_42A_KEY;

const res = await fetch("https://api.42a.ai/api/v1/_health", {
  headers: { Authorization: `Bearer ${KEY}` },
});
const body = await res.json();
console.log(body);
import os, requests

KEY = os.environ["API_42A_KEY"]

res = requests.get(
    "https://api.42a.ai/api/v1/_health",
    headers={"Authorization": f"Bearer {KEY}"},
)
print(res.json())

Expected response:

{
  "data": {
    "ok": true,
    "organization_id": "j97abc...",
    "organization_name": "Acme Inc",
    "key_type": "org"
  },
  "next_cursor": null,
  "meta": { "request_id": "...", "took_ms": 41 }
}

Pick an org (user keys only)

If you used a user key, list the orgs available to you:

curl -H "Authorization: Bearer $KEY" https://api.42a.ai/api/v1/organizations
const orgs = await fetch("https://api.42a.ai/api/v1/organizations", {
  headers: { Authorization: `Bearer ${KEY}` },
}).then((r) => r.json());

console.log(orgs.data); // [{ id: "org_xxx", name: "...", role: "..." }, ...]
res = requests.get(
    "https://api.42a.ai/api/v1/organizations",
    headers={"Authorization": f"Bearer {KEY}"},
)
print(res.json()["data"])

Then include X-Org-Id on every subsequent call:

curl -H "Authorization: Bearer $KEY" \
     -H "X-Org-Id: org_2abcde" \
     "https://api.42a.ai/api/v1/projects?limit=5"
const url = new URL("https://api.42a.ai/api/v1/projects");
url.searchParams.set("limit", "5");

const res = await fetch(url, {
  headers: {
    Authorization: `Bearer ${KEY}`,
    "X-Org-Id": "org_2abcde",
  },
});
console.log(await res.json());
res = requests.get(
    "https://api.42a.ai/api/v1/projects",
    params={"limit": 5},
    headers={
        "Authorization": f"Bearer {KEY}",
        "X-Org-Id": "org_2abcde",
    },
)
print(res.json())

Paginate

Every list endpoint takes ?limit= (1-100, default 25) and ?cursor=. The response includes next_cursor - pass it back to fetch the next page. null means you've reached the end.

curl -H "Authorization: Bearer $KEY" \
  "https://api.42a.ai/api/v1/citations?project_id=prj_xxx&limit=50&cursor=eyJ..."
async function* citations(projectId) {
  let cursor;
  do {
    const url = new URL("https://api.42a.ai/api/v1/citations");
    url.searchParams.set("project_id", projectId);
    url.searchParams.set("limit", "50");
    if (cursor) url.searchParams.set("cursor", cursor);

    const page = await fetch(url, {
      headers: { Authorization: `Bearer ${KEY}` },
    }).then((r) => r.json());

    yield* page.data;
    cursor = page.next_cursor;
  } while (cursor);
}

for await (const c of citations("prj_xxx")) console.log(c.url);
def citations(project_id):
    cursor = None
    while True:
        params = {"project_id": project_id, "limit": 50}
        if cursor:
            params["cursor"] = cursor
        page = requests.get(
            "https://api.42a.ai/api/v1/citations",
            params=params,
            headers={"Authorization": f"Bearer {KEY}"},
        ).json()
        yield from page["data"]
        cursor = page["next_cursor"]
        if not cursor:
            return

for c in citations("prj_xxx"):
    print(c["url"])

That's it. See the API reference for the full surface, or the MCP guide to use 42A from inside Claude.

Last updated