New: Learny Brain for Sales & Support — an AI agent for your website.
Learny Brain

API

Automate Learny Brain from your own code. Create a workspace-scoped bearer token and call the API to list brains and trigger a fresh crawl of indexed URLs.

Get an API key

  1. As a workspace admin, open Settings in the left sidebar.
  2. Scroll to the API Keys panel at the bottom and click Manage API keys (or go to /settings/api-keys).
  3. Optionally give the key a name (e.g. Production script) and click Generate API key.
  4. Copy the secret shown on the next screen — it starts with lba_ and is shown only once. Store it securely; it is hashed in the database and cannot be recovered.

All keys for the workspace are listed with their prefix, name, creation date, and last-used timestamp. Revoke any key at any time — it stops working immediately.

Treat keys like passwords. Use a secrets manager or environment variable, never commit them to git, and revoke and rotate if a key may have leaked.

Authentication

Pass the key as a Bearer token in the Authorization header on every request. Keys are scoped to the workspace that created them — they cannot access other workspaces.

Authorization: Bearer lba_<your-secret>

Base URL: your workspace host, e.g. https://acme.learny.co (or https://brain.learny.co — the token determines the workspace). All API paths below are relative to that host.

curl -H "Authorization: Bearer lba_xxxxxxxxxxxxxxxx" https://acme.learny.co/api/brains

A missing or invalid token returns 401 { "error": "missing bearer token" } or 401 { "error": "invalid bearer token" }.

List brains

GET /api/brains — returns every brain in your workspace with its identifier.

GET /api/brains
Authorization: Bearer lba_...

Example response:

{
  "ok": true,
  "org": { "id": 12, "subdomain": "acme", "name": "Acme Inc" },
  "brains": [
    {
      "id": 7,
      "public_id": "3ec4c2a8-5f1e-4b5a-9b1a-0f2a5a6b7c8d",
      "name": "Company Brain",
      "slug": "company-brain",
      "is_company_brain": true,
      "access": "org",
      "composio_entity_id": "brn_abc123"
    }
  ]
}

Use public_id (the UUID you also see in /brains/<public_id>/chat) as the brain identifier for other endpoints. id and slug are also returned for convenience.

Recrawl URLs for a brain

POST /api/brains/:brainPublicId/recrawl — re-scrapes and re-indexes every enabled context source (URLs and sitemaps) attached to that brain. This is the same job that runs on “Re-crawl all now” in the UI and nightly via cron, but triggered on demand.

POST /api/brains/3ec4c2a8-5f1e-4b5a-9b1a-0f2a5a6b7c8d/recrawl
Authorization: Bearer lba_...

Example response:

{
  "ok": true,
  "brain": { "id": 7, "public_id": "3ec4c2a8-...", "name": "Company Brain" },
  "result": { "sources": 3, "docs": 12, "skipped": 0 }
}
  • 404 { "error": "brain not found" } if the UUID does not belong to your workspace.
  • 500 { "error": "failed to trigger recrawl" } if the scrape/index job fails.

Examples

curl -X POST \
  -H "Authorization: Bearer lba_xxxxxxxxxxxxxxxx" \
  https://acme.learny.co/api/brains/3ec4c2a8-5f1e-4b5a-9b1a-0f2a5a6b7c8d/recrawl
// Node.js (Node 18+)
const res = await fetch('https://acme.learny.co/api/brains/3ec4c2a8-.../recrawl', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer ' + process.env.LEARNY_API_KEY }
});
const json = await res.json();
console.log(json.result); // { sources: 3, docs: 12 }

Rate limits & errors

The API shares the global rate limiter (400 requests per 15 minutes per IP) and the per-brain crawl limits. Exceeding it returns 429. All endpoints return JSON; non-2xx responses include an error key.

What’s next: listing brains and recrawling URLs are the first endpoints. We’ll expand the API over time; this page will stay up to date as new capabilities land.