API Reference
Functions, the in-app AI agent, and an MCP server for external agents. Every call runs as the signed-in user.
- Functions
- 39Functions
- MCP tools
- 88MCP tools
- Agent tools
- 81Agent tools
- Scoped to the signed-in user
- RLSScoped to the signed-in user
Base URL
Start here
- Functions
- https://learnspace.io/functions/v1/<name>
- REST API (API keys)
- https://learnspace.io/functions/v1/public-api/v1 · openapi.json
- MCP endpoint (Streamable HTTP)
- https://learnspace.io/functions/v1/mcp-server
- Auth (Supabase-compatible)
- https://learnspace.io/auth/v1 · Authorization: Bearer <access token>
REST API
Courses, enrollments and progress over HTTP
For integrations that are not AI agents: HR systems, CRMs, dashboards and scripts.
- Base URL
- https://learnspace.io/functions/v1/public-api/v1
- Auth
Authorization: Bearer lsk_live_…(orx-api-key). Create keys under Settings → Developers. A key is shown once, can expire, and is limited to its scopes and a per-minute rate (see thex-ratelimit-*headers; 429 includesRetry-After).- Pagination
- Lists are newest first:
{ data, has_more, next_cursor }. Passnext_cursorback as?cursor=;?limit=is 1–100.
Scopes
read:coursesList and read your courses (any status) and published courses, with their outline.
write:enrollmentsEnroll existing LearnSpace users in your free courses and remove them.
read:progressRead enrollments, per-learner progress and quiz/assignment results in your courses, and your own enrollments.
admin:webhooksCreate, change, test and delete webhook endpoints, and read deliveries and events.
Endpoints
GET/me—The key and user behind the request.
GET/me/enrollmentsread:progressYour own enrollments as a learner.
GET/courses?owner=me|any&status=read:coursesYour courses, or every published course.
GET/courses/{id}read:coursesOne course.
GET/courses/{id}/outlineread:coursesSections and lessons, in order.
GET/courses/{id}/enrollmentsread:progressLearners enrolled in your course.
POST/courses/{id}/enrollmentswrite:enrollmentsEnroll a user by user_id or email. Paid courses answer 402 with checkout_url.
DELETE/courses/{id}/enrollments/{user_id}write:enrollmentsRemove a learner.
GET/courses/{id}/progress?user_id=read:progressLessons completed per learner; per-lesson detail for one learner.
GET/courses/{id}/quiz-submissionsread:progressQuiz scores, filterable by user_id and section_id.
GET/courses/{id}/assignment-submissionsread:progressAssignment submissions and grades.
GET/webhook-endpointsadmin:webhooksYour endpoints.
POST/webhook-endpointsadmin:webhooksAdd an endpoint; the response carries its signing secret.
PATCH/webhook-endpoints/{id}admin:webhooksChange url, events, description or is_active.
DELETE/webhook-endpoints/{id}admin:webhooksDelete an endpoint.
POST/webhook-endpoints/{id}/rotate-secretadmin:webhooksReplace the signing secret.
POST/webhook-endpoints/{id}/testadmin:webhooksSend a webhook.test event now and return the result.
GET/webhook-endpoints/{id}/deliveriesadmin:webhooksRecent deliveries with status and response.
POST/webhook-deliveries/{id}/redeliveradmin:webhooksSend a delivery’s event again.
GET/events?type=admin:webhooksYour events from the last 30 days.
curl "https://learnspace.io/functions/v1/public-api/v1/courses/<course-id>/progress?limit=50" \
-H "Authorization: Bearer lsk_live_…"
# 200
{
"data": [
{ "learner": { "id": "…", "name": "Ada", "email": "ada@example.com" },
"lessons_completed": 7, "lessons_total": 12, "percent": 58, … }
],
"has_more": true,
"next_cursor": "WyIyMDI2LTExLTE3…" # pass back as ?cursor=
# Errors always look like this (send x-request-id to set the id yourself):
{ "error": { "code": "insufficient_scope", "message": "…", "request_id": "…" } }Webhooks
Get notified when learners make progress
Add an endpoint under Settings → Developers. Events come from your own courses.
enrollment.createdA learner enrolled in one of your courses.
lesson.completedA learner completed a lesson.
course.completedA learner completed a course.
quiz.submittedA quiz was submitted (score, passed, correct answers).
assignment.submittedAn assignment was submitted.
assignment.gradedAn assignment was graded (score).
certificate.issuedA certificate was issued.
Each event is a signed JSON POST. Answer 2xx within 10 seconds. Failed deliveries are retried with exponential backoff (8 attempts over about an hour), and an endpoint that fails 15 times in a row is turned off until you re-enable it. Use the event id to ignore duplicates.
POST https://your-app.example.com/webhooks/learnspace
LearnSpace-Signature: t=1763398800,v1=5f2b…
LearnSpace-Event: enrollment.created
{
"id": "1f0c…",
"type": "enrollment.created",
"api_version": "2026-11-17",
"created_at": "2026-11-17T17:00:00.000Z",
"data": {
"enrollment_id": "…",
"course": { "id": "…", "title": "Intro to SQL" },
"learner": { "id": "…", "name": "Ada", "email": "ada@example.com" },
"enrolled_at": "2026-11-17T17:00:00.000Z"
}
}import crypto from "node:crypto";
// rawBody: the request body exactly as received (not re-serialized JSON).
export function verify(rawBody, header, secret, toleranceSeconds = 300) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(parts.v1 ?? "");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}Standards
SCORM, xAPI, LTI 1.3, SSO and SCIM
Paths are relative to https://learnspace.io. Authors import a SCORM package as a new course from the course list (Import SCORM).
POST/functions/v1/scorm { action: "launch", lesson_id }Start a SCORM lesson: returns a signed launch token, the content URL, the SCORM version, and the stored runtime data. User access token.
GET/functions/v1/scorm/c/<token>/<file>Package files, served from the site origin so the content can reach the player API.
POST/functions/v1/xapi/statementsStore one xAPI 1.0.3 statement or an array; returns their ids. PUT ?statementId= stores one with a given id.
GET/functions/v1/xapi/statementsRead your statements by ?statementId=, or filter with ?verb=&activity=&since=&limit=.
GET/functions/v1/xapi/activities/stateActivity state (GET, PUT, POST, DELETE) by activityId, agent, stateId and registration.
GET/functions/v1/xapi/aboutLRS version (1.0.3).
GET/lti/configThe URLs to register LearnSpace with an LMS as an LTI 1.3 tool (login, launch, JWKS, deep linking).
POST/lti/login, /lti/launchOIDC login initiation and the resource-link or deep-linking launch. A launch signs the learner in.
GET/lti/jwksThe tool's public keys.
POST/lti/grades/syncSend every learner's score to the LMS gradebook (Assignment and Grade Services). Course editors.
POST/lti/rosterRead the LMS roster (Names and Role Provisioning Services). Course editors.
POST/auth/v1/sso { domain }Single sign-on with a learnspace's own SAML 2.0 or OpenID Connect identity provider; works with supabase.auth.signInWithSSO.
GET/scim/v2/Users, /scim/v2/GroupsSCIM 2.0 provisioning for a learnspace's directory, with the learnspace's bearer token.
xAPI routes accept a user access token, or a SCORM launch token as Basic auth. Statements are always stored for the caller, and are forwarded to an external LRS when the course has one configured. Admins register LMS platforms at /admin/lti.
Billing
Paid courses and credits
Prices are set per course or bundle; learners pay in LearnSpace Credits held in a cred.diy wallet.
billing function
POST { action } with the learner's access token: quote, enroll, redeem_invite, checkout, subscribe, portal, cancel_subscription, wallet, tiers. Enrolling in a paid course deducts credits and enrolls on the server; learners can only enroll themselves directly in free courses. The REST API answers 402 with a checkout_url for a paid course.
Billing webhooks
cred.diy calls /functions/v1/cred-webhook with an HMAC-SHA256 signature. Credit purchases are added to the purchase history and subscription events keep All-Access in sync. Each event is stored once, so redeliveries are ignored. This endpoint is for cred.diy only; your own integrations use the REST API webhooks above.
Capabilities
What you can build
In-app AI agent
agent-chat calls 81 tools (with memory of your preferences, and an optional review mode where you approve each change to your courses): courses, enrollments, progress, goals, notifications, profile, flashcard review, grades, cohort schedules, read-only credits, navigation, course authoring, and the gradebook.
MCP server
A Streamable HTTP Model Context Protocol endpoint with 88 tools. Add the URL to Claude, Cursor, or any MCP client.
Course engine
Create and edit courses, sections, lessons, content blocks, and quizzes with the same APIs the authoring UI uses.
AI authoring
Generate courses, sections, blocks, quizzes, images, and alt text. Review outlines, check for outdated content and for claims the course source doesn’t support, find content gaps from learners’ questions, and translate whole courses.
Narration
MP3 narration for any lesson with ElevenLabs, returned as base64 JSON, in a stock voice or the author’s own cloned voice (recorded consent required).
Research and video
Cited research with Perplexity, web scraping with Firecrawl, YouTube summaries and chat, and lesson videos from MoviePro on your own MoviePro credits.
Cohorts and grades
Cohorts with section release schedules and due dates, a weighted gradebook with audited overrides, and spaced-repetition flashcards. Readable by the agent and the MCP server.
Standards
Import SCORM 1.2 / 2004 and H5P packages, import and export quizzes as GIFT and QTI, record xAPI statements, launch courses from an LMS over LTI 1.3, and sign in and provision learners with SSO and SCIM.
Paid courses
Courses, bundles, coupons, and an All-Access subscription, paid in LearnSpace Credits through cred.diy.
Functions
Every public function
Call one with POST and a JSON body, or supabase.functions.invoke('<name>', { body }).
Agents
agent-chatThe in-app LearnSpace AI agent. POST { conversationId, message, attachments? } (attachments: up to 3 { name, kind, text } documents whose text the caller extracted, 30,000 characters each); it calls tools for courses, enrollments, progress, goals, notifications, profile, flashcard review, grades, cohort schedules, read-only credits and purchases, navigation, course authoring (content blocks of every widget type, validated against the widget schemas) and the gradebook, and returns { reply, tool_events }. With the conversation review_changes flag on, edits to existing course content are staged in agent_pending_changes; POST { action: "decide_change", conversationId, changeId, approve } applies or rejects one.
mcp-serverModel Context Protocol endpoint (Streamable HTTP) for external AI agents: course authoring (content blocks of every widget type, validated against the widget schemas), cohorts and release schedules, gradebook, flashcards, read-only credits and purchases, API key listing and revocation, discussions (list, read, reply, pin/remove), course audit and find & replace, and issued certificates (list, revoke). Lesson tools set optional lessons and completion rules; section tools set prerequisites, availability and drip release.
Course authoring
ai-content-generatorGenerate block content (text, callouts, code, summaries) for the editor. Pass stream: true for token streaming.
ai-generate-courseGenerate a course from a topic, URL, YouTube video (one without captions is transcribed by AI for signed-in callers), YouTube playlist (mode "playlist": outline lessons carry video ids and get the video embedded) or document text (with pages from a PDF, lessons cite page numbers). action: "outline" returns an editable outline; action: "fromOutline" writes the course for that outline section by section and returns { courseId, missingSections } (sections that failed are kept for later); action: "resume" with courseId writes those missing sections in place. Applies the course style guide. Can combine up to 3 extra links, read a whole site (crawl), and ends each lesson with its source and a checked quote.
apply-lesson-contentPreview staged block text as a per-block diff, then apply it with apply: true (merging into the block, under the caller's permissions) and insert new blocks at a position.
check-course-linksCheck that the links in a course still resolve.
generate-alt-textWrite descriptive alt text for an uploaded image.
generate-course-imageGenerate cover, header, and inline images for courses and lessons, in the course image style when a courseId is sent.
generate-course-sectionGenerate one section with its content blocks for an existing course.
improve-blockRewrite a block for clarity, a target grade level, or a tone. Other modes: continue (keep writing), mermaid (a diagram from a description), color (suggest a brand color for the course), gaps (content gaps from the questions learners asked the tutor), posts (social posts to share a course).
learning-objectivesPropose learning objectives for a course or section, and check that every saved objective is assessed by at least one quiz question. The coverage check saves which objective each quiz question assesses (question_objectives), which drives mastery per objective on the grades and gradebook pages.
review-course-outlineReview a course outline for thin lessons, missing assessments, and uneven modules. Findings name the lesson or section they concern. Focus "outdated" flags time-sensitive claims that may be out of date; focus "claims" checks lessons against the course’s saved source text (course_ai_sources) for unsupported claims.
rewrite-lesson-contentExpand, shorten or rewrite every text block of a lesson or section. Returns a per-block before/after proposal; writes nothing.
suggest-quizSuggest quiz questions from a lesson's existing content, shaped as quiz blocks, each citing (and checked against) the passage it is based on.
translate-courseCopy a course into a new course in another language, translating every human-readable string. The copy stays linked to its source; pass targetCourseId (and lessonIds) to re-translate only out-of-date lessons in place. targetLanguage may be a code ("nl") or a name ("Dutch"); the copy stores the code. A large course can answer { pending: true, done, total } when a call’s time budget runs out: call again with the same body to continue (finished parts are kept for 7 days).
write-course-content-claudeWrite long-form lesson content with Claude.
Learning
ai-planning-assistantPlan a learning journey from goals, available time, and current skill level.
ai-reflection-analyzerAnalyze a learner reflection for themes, gaps, and next steps.
certificatesOpen Badges 3.0 endpoints for course certificates: credential (JSON-LD or signed VC-JWT), achievement, issuer profile, revocation list and JWKS. Public.
course-ai-qaAnswer questions about a specific course's content.
grade-quiz-submissionStart a quiz attempt (attempt limit, question-pool draw, time limit) with action: "start", then grade it, including partial credit and per-question feedback. Practice mode (practice: true) grades chosen questions without recording or using an attempt.
narrate-lessonGenerate MP3 narration for a lesson with ElevenLabs (base64 JSON response), or list the available voices with preview clips (action: "voices"). Cloned author voices (voice-clone) are listed only to their owner, and anyone else can use one only for a lesson of the owner’s course that has it as the narration voice (send lessonId), with text from that lesson.
scormLaunch a lesson that plays an imported SCORM 1.2 / 2004 package (returns a signed launch token and the learner's stored runtime data), then serve the package files from the site origin under that token.
study-assistantAI study help for learners: a lesson tutor grounded in the lesson with block citations (streaming), explanations for wrong quiz answers (cached per question and answer), and flashcards drafted from highlights and notes. Action "voice": transcript and feedback for a recorded spoken answer (audio not stored). Tutor questions are kept anonymously per course (learner_questions) for the course team’s content-gap insights.
suggest-gradeCourse team only: AI-suggested score and rationale for a free-response answer or assignment submission, scored against the rubric. Never saves a grade.
xapiMinimal xAPI Learning Record Store (statements and activity state) for imported content, with optional forwarding to an external LRS.
Research & media
chat-with-videoAsk questions about a YouTube video's transcript.
firecrawl-scrapeScrape or crawl a web page with Firecrawl. Scrapes are cached so retries do not re-bill.
movieproGenerate lesson videos with MoviePro on the user's own MoviePro credits, after they connect their account once (connect, status, generate, poll).
research-perplexityCited web research with Perplexity.
stock-photosSearch Unsplash stock photos for the image picker (action search) and record a chosen photo as downloaded (action download), as the Unsplash API requires. Needs UNSPLASH_ACCESS_KEY.
transcribe-mediaCaptions (WebVTT) and chapters for a video or audio file uploaded to LearnSpace storage, via Gemini (files up to 14 MB). POST { url }; signed-in authors only.
voice-cloneClone the signed-in author’s own voice for narration (action create: a spoken consent statement plus a sample; the statement and same speaker are checked before ElevenLabs creates it), list their voices, or delete one (also removed from ElevenLabs and their courses). Max 3 per author.
youtube-playlistList a YouTube playlist's public videos (id, title, description) so Create with AI can outline a course with one lesson per video. POST { playlistId }; uses the YouTube Data API when YOUTUBE_API_KEY is set (up to 200 videos), else the playlist's RSS feed (15 newest).
youtube-summarizeFetch a YouTube transcript with QuickTube and summarize it (with Gemini when QuickTube's summarizer is unavailable). For signed-in callers a video without captions is transcribed by AI (Gemini reads the link; a video without speech gets its steps described), cached for 90 days.
Platform
billingPaid enrollment with LearnSpace Credits (cred.diy): quotes with coupons, enroll in a course or bundle, redeem invite codes, top up credits through hosted checkout, read the wallet, and manage the All-Access subscription.
notificationsWeb push, email digests, weekly progress emails and goal reminders (cron), push subscription management, and email opt-out links.
public-apiVersioned REST API (/public-api/v1) for courses, enrollments, progress and webhooks, authenticated with scoped API keys. OpenAPI at /public-api/v1/openapi.json.
send-contact-emailSend a contact-form message to the LearnSpace team.
Example
Call the AI agent
# Ask the in-app agent. The conversation must be one of yours
# (a row in agent_conversations, created by the Ask AI page).
curl https://learnspace.io/functions/v1/agent-chat \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{"conversationId":"<CONVERSATION_ID>","message":"How many flashcards are due today?"}'
# 200
{ "reply": "You have 12 cards due…", "tool_events": [ { "name": "count_due_flashcards", … } ] }MCP
Connect external AI agents
88 tools, grouped by what they work on.
# Connect an MCP client (Claude, Cursor, and others)
# URL: https://learnspace.io/functions/v1/mcp-server
# Header: Authorization: Bearer <ACCESS_TOKEN>
# List the tools directly:
curl -X POST https://learnspace.io/functions/v1/mcp-server \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'Identity
1 tool- get_current_user
Courses
5 tools- list_courses
- create_course
- update_course
- delete_course
- get_course
Sections
4 tools- list_sections
- create_section
- update_section
- delete_section
Lessons
4 tools- list_lessons
- create_lesson
- update_lesson
- delete_lesson
Content blocks
7 tools- list_content_blocks
- create_content_block
- update_content_block
- delete_content_block
- reorder_blocks
- insert_content_block
- bulk_reorder_blocks
Enrollments
3 tools- list_enrollments
- enroll_user
- unenroll_user
Quizzes
8 tools- list_quiz_questions
- create_quiz_question
- update_quiz_question
- delete_quiz_question
- list_quiz_options
- create_quiz_option
- update_quiz_option
- delete_quiz_option
Password vault
2 tools- list_passwords
- create_password
Learnspaces
7 tools- list_learnspaces
- create_learnspace
- update_learnspace
- delete_learnspace
- get_learnspace
- add_course_to_learnspace
- remove_course_from_learnspace
Profiles
2 tools- get_profile
- update_profile
AI generation
2 tools- generate_lesson_content
- generate_quiz
Collaborators
4 tools- list_collaborators
- add_collaborator
- update_collaborator_role
- remove_collaborator
Versions & revisions
5 tools- list_block_versions
- restore_block_version
- list_lesson_revisions
- create_lesson_revision
- restore_lesson_revision
Internal comments
4 tools- list_internal_comments
- create_internal_comment
- delete_internal_comment
- update_internal_comment
Audit log
2 tools- list_audit_log
- log_audit_event
Analytics
2 tools- list_lesson_progress
- list_quiz_submissions
Cohorts & release schedules
8 tools- list_cohorts
- get_cohort
- create_cohort
- update_cohort
- set_section_release
- remove_section_release
- set_cohort_due_date
- remove_cohort_due_date
Gradebook
3 tools- get_gradebook
- get_learner_grades
- get_gradebook_settings
Spaced repetition
3 tools- count_due_flashcards
- list_due_flashcards
- create_flashcard
Credits & purchases (read-only)
2 tools- get_credit_balance
- list_my_purchases
API keys
2 tools- list_api_keys
- revoke_api_key
Course-wide tools & certificates
4 tools- find_replace_in_course
- audit_course
- list_certificates
- set_certificate_revoked
Discussions
4 tools- list_discussions
- get_discussion
- reply_to_discussion
- moderate_discussion
In-app agent
The agent's 81 tools
Available in Ask AI and the agent panel on every page. Authoring and gradebook tools check owner or editor access on the server. Billing tools are read-only.
- search_courses
- list_my_enrollments
- list_learnspaces
- list_my_learnspaces
- navigate
- get_current_time
- get_course_details
- list_course_lessons
- enroll_in_course
- unenroll_from_course
- mark_lesson_complete
- get_course_progress
- list_my_goals
- create_goal
- update_goal_progress
- list_milestones
- create_milestone
- complete_milestone
- list_notifications
- mark_notification_read
- get_my_profile
- update_my_profile
- list_authored_courses
- create_course
- update_course
- remember_preference
- forget_preference
- list_preferences
- find_replace_in_course
- audit_course
- delete_course
- list_sections
- create_section
- update_section
- delete_section
- create_lesson
- update_lesson
- delete_lesson
- list_content_blocks
- create_content_block
- insert_content_block
- update_content_block
- delete_content_block
- reorder_blocks
- list_quiz_questions
- create_quiz_question
- update_quiz_question
- delete_quiz_question
- list_quiz_options
- create_quiz_option
- update_quiz_option
- delete_quiz_option
- list_collaborators
- add_collaborator
- update_collaborator_role
- remove_collaborator
- list_block_versions
- restore_block_version
- list_lesson_revisions
- create_lesson_revision
- restore_lesson_revision
- list_internal_comments
- create_internal_comment
- update_internal_comment
- delete_internal_comment
- list_audit_log
- get_course_analytics
- get_credit_balance
- list_my_purchases
- count_due_flashcards
- list_due_flashcards
- create_flashcard
- list_discussions
- get_discussion
- reply_to_discussion
- moderate_discussion
- list_certificates
- set_certificate_revoked
- get_my_grades
- get_my_cohort_schedule
- get_gradebook_summary
FAQ
Common questions
How do I authenticate?
Functions and the MCP server: send the access token you get when you sign in (email and password, 1Profile, or your organization's SSO) as Authorization: Bearer <token>. The API is Supabase-compatible, so supabase-js pointed at learnspace.io works unchanged. Every call then runs as you, and row-level security limits it to data you can see. The public anon key is accepted too, but it only reaches public data. The REST API (/public-api/v1) uses scoped API keys instead; create them under Settings → Developers.
What is the MCP server?
A Streamable HTTP Model Context Protocol endpoint at /functions/v1/mcp-server with 88 tools for courses (including optional lessons, completion rules and drip release), discussions, certificates, course audit and find & replace, sections, lessons, content blocks, quizzes, enrollments, learnspaces, profiles, collaboration, version history, audit log, analytics, AI generation, cohorts and release schedules, the gradebook, flashcards, read-only credits and purchases, and your API keys. Call get_current_user first to confirm who you are acting as.
Which models power AI features?
Text runs through the Vercel AI Gateway, by default google/gemini-3.8-flash. Long-form lesson writing uses Claude, images use an OpenAI image model, narration uses ElevenLabs, research uses Perplexity, and YouTube transcripts come from QuickTube. No model keys ever reach the browser.
Are there rate limits?
Sign-in, sign-up, and email endpoints are rate limited per address and IP. Each REST API key has its own per-minute limit (60 by default, up to 300), reported in x-ratelimit-* headers. Over a limit you get 429; wait and retry.
Can an agent spend my credits?
No. The agent and the MCP server can read your credit balance, All-Access status, and purchase history, but no tool buys credits, pays for a course, redeems a code, or changes a subscription. Those happen on the Billing page.
How do I add a tool?
In-app agent: add the definition to supabase/functions/agent-chat/toolDefs.ts and its handler to handlers.ts. MCP: add it to a module in supabase/functions/mcp-server/tools. Then run npm run gen:api to refresh this page. The test suite fails until you do.
Try the agent first
The quickest way to see what these APIs do is to ask the LearnSpace agent.
