REST API

Everything in Lectro is an API call. Scripts and agents outside the MCP flow use the same routes the app does, with an API key.

API keys

In the app, open Settings, turn on Show advanced tools, and create a key under API keys. It is shown once and starts with crt_. Send it as Authorization: Bearer crt_…. A key can read and write everything you study but cannot manage your account or its keys. Revoking a key stops whatever uses it at once.

A first request

All routes live under https://app.lectro.ai/api/v1. This one creates a note and files it in a node:

Creating a note with the REST API
curl https://app.lectro.ai/api/v1/notes \
  -H "Authorization: Bearer crt_…" \
  -H "Content-Type: application/json" \
  -d '{
    "notetype_id": "…",
    "fields": { "Front": "Why does SN2 invert?", "Back": "Back-side attack." },
    "node_ids": ["…"]
  }'

Conventions

  • Bodies are JSON with snake_case fields. IDs are UUIDv7 strings.
  • Times are ISO-8601 in UTC.
  • Reviews take a client_request_id, so a retried request is recorded once.
  • Requests are rate limited per client; past the limit you get a 429 with code rate_limited.

Errors

Every error has the same shape, with a stable code beside the HTTP status:

An error response
{
  "error": {
    "code": "validation_failed",
    "message": "Invalid request",
    "details": [
      { "keyword": "invalid_type", "instancePath": "/notetype_id", "message": "…" }
    ]
  }
}
CodeStatusMeaning
unauthorized401No key, or one that was revoked
forbidden403The key may not do this
not_found404Nothing with that ID in your account
validation_failed400The body or query does not fit the schema
conflict, stale_version409Someone changed it first; read it and retry
plan_required402Needs a plan you don’t have, e.g. Teacher to publish a course
limit_reached402A plan limit is used up, e.g. the monthly assistant allowance
rate_limited429Too many requests; slow down

Routes

ResourceRoutes
AccountGET /me, GET /billing
TodayGET /today
Skill treesCRUD on /trees, nodes under /trees/:id/nodes, edges under /trees/:id/edges
NotesCRUD on /notes (filter by tree_id, node_id, unfiled), GET /notes/:id/cards, GET /tags
Cards and reviewsGET /cards?due=true, GET /cards/:id, GET /cards/:id/reviews, POST /reviews
SessionsPOST /sessions, GET /sessions/:id and its items
SourcesCRUD on /sources, POST /sources/:id/merge, citations under /notes/:id/citations
NotetypesCRUD on /notetypes, fields and templates under /notetypes/:id
ProtocolsGET /me/protocol, GET/POST /protocol-revisions
FeedbackGET /feedback, POST /feedback/:id/resolve, GET/PUT /style-guide