Guide · Automate and connect an agent

Guide · Automate, connect an agent

API and MCP

Everything the interface does goes through an HTTP API: there is no privileged path. That is what makes automation possible, and it is also why an API key must be treated like a password.

Getting a key

  1. Account → API keys → Create a key.
  2. Name it after its use (“card import”, “backup robot”).
  3. Copy the value: it is not shown again.
  4. Revoke it as soon as it is no longer useful.

Every key acts with the rights of the account that created it. There is no finer scope: if you want a read-only key, create a dedicated account.

Calling the API

curl -H "Authorization: Bearer $OPENLEARN_KEY" \
     https://your-instance.example/api/v1/auth/me

Resources follow the objects of the product: /api/v1/wiki, /api/v1/quizzes, /api/v1/cards, /api/v1/auth, /api/v1/admin. Failures come back with an explicit HTTP code — 401 unauthenticated, 403 forbidden, 404 missing, 409 conflict, 422 validation, 429 too many requests.

Two practical rules:

The full reference

Every instance publishes its own reference, generated from the code:

An instance’s reference reflects exactly its version: that is more reliable than documentation copied out by hand.

The MCP server

OpenLearn embeds an MCP (Model Context Protocol) server. An agent — a desktop assistant, an MCP client, an orchestration script — can therefore read and create wiki pages or quizzes with the rights of the account that authorises it.

An agent writes, it does not check. A model drafting a wiki page produces a plausible page, not a true one. In a teaching context, have it reviewed: editorial responsibility is not delegated to an API key.

Reasonable use cases

Goal Means
Import a question bank prepared elsewhere POST /api/v1/quizzes, then add the questions
Back up a wiki’s pages as Markdown GET /api/v1/wiki, then export each page
Feed a results dashboard CSV export from the interface, or the statistics endpoints
Have an agent draft a card Dedicated key, then human review before publication
Sync with an LMS or another wiki JSON import/export, or scheduled API calls

Limits to know