v2.4.1 Stable

API & Integrations

Build powerful integrations with LearnFlow's RESTful API. Manage users, courses, enrollments, and more programmatically. Our API supports webhooks, OAuth 2.0, and comprehensive SDKs for all major platforms.

Quick Start

Get up and running with the LearnFlow API in under 5 minutes. Follow these steps to make your first API call.

  1. 1

    Get Your API Key

    Navigate to Settings → Developer → API Keys in your LearnFlow dashboard. Generate a new key with the required permissions.

  2. 2

    Make Your First Request

    Use your API key to authenticate requests. Here's a simple example to fetch all users:

  3. 3

    Explore the API

    Use our Postman collection or SDKs to explore all available endpoints. Check the API Reference for detailed documentation.

curl -X GET "https://api.learnflow.com/v2/users" \
  -H "Authorization: Bearer sk_live_your_api_key_here" \
  -H "Content-Type: application/json"

Base URL: All API requests should be made to https://api.learnflow.com/v2/. The base URL is the same for both sandbox and live environments — the difference is determined by the API key prefix (sk_test_ vs sk_live_).

Authentication

LearnFlow uses API keys for authentication. Every request must include your API key in the Authorization header. You can manage your API keys from the Developer Dashboard.

API Key Authentication

Include your API key as a Bearer token in the Authorization header:

Authorization: Bearer sk_live_your_api_key_here

Never expose your API keys in client-side code. API keys have full access to your account. For client-side applications, use server-side proxying or OAuth 2.0 for user-level authentication.

OAuth 2.0 (User Authorization)

For applications that act on behalf of users, LearnFlow supports OAuth 2.0 with PKCE. This allows users to authorize your application to access their learning data without sharing credentials.

// Step 1: Redirect user to authorization URL
const authUrl = new URL('https://api.learnflow.com/oauth/authorize');
authUrl.searchParams.set('client_id', 'your_client_id');
authUrl.searchParams.set('redirect_uri', 'https://yourapp.com/callback');
authUrl.searchParams.set('response_type', 'code');
authUrl.searchParams.set('scope', 'read:enrollments read:progress');
authUrl.searchParams.set('state', 'random_csrf_token');

// Step 2: Exchange code for access token
const response = await fetch('https://api.learnflow.com/oauth/token', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    grant_type: 'authorization_code',
    client_id: 'your_client_id',
    client_secret: 'your_client_secret',
    code: 'authorization_code_from_callback',
    redirect_uri: 'https://yourapp.com/callback',
    code_verifier: 'your_code_verifier'
  })
});

Available Scopes

ScopeDescription
read:usersRead user profiles and preferences
write:usersCreate and update user accounts
read:coursesView course catalogs and details
write:coursesCreate, update, and manage courses
read:enrollmentsView enrollment data
write:enrollmentsCreate and modify enrollments
read:progressView user learning progress
read:certificatesAccess certificate data

Rate Limits

API rate limits are based on your subscription tier. If you exceed your rate limit, you'll receive a 429 Too Many Requests response. Rate limit information is included in response headers.

Starter
100
requests / minute
  • 10K requests / day
  • Read-only endpoints
  • Standard response time
Professional
500
requests / minute
  • 100K requests / day
  • Full CRUD access
  • Priority response
  • Webhooks included
Enterprise
custom limits
  • Unlimited requests
  • Dedicated endpoints
  • SLA guarantee
  • Dedicated support
Response Headers:
x-ratelimit-limit: 500
x-ratelimit-remaining: 498
x-ratelimit-reset: 1699900800
x-request-id: req_abc123def456

Error Handling

LearnFlow uses conventional HTTP status codes to indicate the success or failure of requests. Codes in the 2xx range indicate success, 4xx range indicate client errors, and 5xx range indicate server errors.

{
  "error": {
    "type": "invalid_request_error",
    "code": "resource_not_found",
    "message": "The user with id 'usr_12345' does not exist.",
    "param": "user_id",
    "request_id": "req_abc123def456"
  }
}

Common Error Codes

StatusError TypeDescription
400invalid_requestMalformed request or missing parameters
401authentication_errorInvalid or missing API key
403permission_errorInsufficient permissions for this action
404resource_not_foundRequested resource doesn't exist
409conflict_errorResource conflict (e.g., duplicate enrollment)
422validation_errorValidation failed on request parameters
429rate_limit_exceededRate limit exceeded
500server_errorInternal server error

API Reference

The LearnFlow API provides RESTful endpoints for managing all aspects of your learning platform. Below are the core endpoints organized by resource.

List Users

GET /v2/users

Returns a paginated list of users in your organization. Results are sorted by creation date in descending order.

Query Parameters

ParameterTypeRequiredDescription
page integer Optional Page number (default: 1)
per_page integer Optional Results per page (default: 20, max: 100)
role string Optional Filter by role: student, instructor, admin
search string Optional Search by name or email
status string Optional Filter by status: active, inactive, suspended

Example Response

{
  "data": [
    {
      "id": "usr_2xKj9mNpQr",
      "email": "sarah.johnson@example.com",
      "name": "Sarah Johnson",
      "role": "student",
      "status": "active",
      "avatar_url": "https://cdn.learnflow.com/avatars/usr_2xKj9mNpQr.jpg",
      "created_at": "2024-01-15T08:30:00Z",
      "last_login": "2024-03-14T14:22:00Z",
      "enrolled_courses": 5,
      "completed_courses": 2
    },
    {
      "id": "usr_8hRt4vLwMn",
      "email": "michael.chen@example.com",
      "name": "Michael Chen",
      "role": "instructor",
      "status": "active",
      "avatar_url": null,
      "created_at": "2024-02-01T10:15:00Z",
      "last_login": "2024-03-14T09:45:00Z",
      "enrolled_courses": 0,
      "completed_courses": 0
    }
  ],
  "pagination": {
    "current_page": 1,
    "per_page": 20,
    "total_pages": 12,
    "total_count": 234,
    "has_next": true,
    "has_prev": false
  },
  "request_id": "req_abc123def456"
}

Create User

POST /v2/users

Creates a new user in your organization. The user will receive an email invitation to set up their account.

Request Body

ParameterTypeRequiredDescription
email string Required User's email address (must be unique)
name string Required User's full name
role string Optional User role: student, instructor, admin (default: student)
metadata object Optional Custom key-value pairs (max 50 keys)
send_invite boolean Optional Send email invitation (default: true)

Example Request

curl -X POST "https://api.learnflow.com/v2/users" \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "john.doe@example.com",
    "name": "John Doe",
    "role": "student",
    "metadata": {
      "department": "Engineering",
      "employee_id": "EMP-2024-001"
    }
  }'

Example Response

{
  "data": {
    "id": "usr_5pQw3xYzAb",
    "email": "john.doe@example.com",
    "name": "John Doe",
    "role": "student",
    "status": "invited",
    "avatar_url": null,
    "metadata": {
      "department": "Engineering",
      "employee_id": "EMP-2024-001"
    },
    "created_at": "2024-03-14T16:30:00Z",
    "invitation_sent_at": "2024-03-14T16:30:00Z",
    "invitation_expires_at": "2024-03-21T16:30:00Z"
  },
  "request_id": "req_def456ghi789"
}

List Courses

GET /v2/courses

Returns a paginated list of courses available in your organization.

Query Parameters

ParameterTypeRequiredDescription
category string Optional Filter by category slug
level string Optional Filter by level: beginner, intermediate, advanced
instructor_id string Optional Filter by instructor user ID
search string Optional Search by title or description

Example Response

{
  "data": [
    {
      "id": "crs_4mNp7qRsT",
      "title": "Complete Web Development Bootcamp",
      "slug": "web-dev-bootcamp-2024",
      "description": "Master full-stack web development from scratch.",
      "category": "Development",
      "level": "beginner",
      "instructor": {
        "id": "usr_8hRt4vLwMn",
        "name": "Michael Chen"
      },
      "thumbnail_url": "https://cdn.learnflow.com/courses/crs_4mNp7qRsT/thumb.jpg",
      "duration_hours": 42,
      "total_lessons": 186,
      "enrolled_count": 1243,
      "average_rating": 4.9,
      "is_published": true,
      "created_at": "2024-01-10T00:00:00Z",
      "updated_at": "2024-03-10T00:00:00Z"
    }
  ],
  "pagination": {
    "current_page": 1,
    "per_page": 20,
    "total_pages": 5,
    "total_count": 87
  }
}

Enroll User in Course

POST /v2/enrollments

Enrolls a user in a specific course. Returns enrollment details and the user's initial progress snapshot.

Request Body

ParameterTypeRequiredDescription
user_id string Required The ID of the user to enroll
course_id string Required The ID of the course to enroll in
completion_redirect string Optional URL to redirect user after course completion

Example Response

{
  "data": {
    "id": "enr_9kLm2nPqR",
    "user_id": "usr_2xKj9mNpQr",
    "course_id": "crs_4mNp7qRsT",
    "status": "active",
    "enrolled_at": "2024-03-14T16:35:00Z",
    "last_accessed_at": null,
    "completed_at": null,
    "progress": {
      "current_lesson": 1,
      "total_lessons": 186,
      "percent_complete": 0,
      "time_spent_minutes": 0
    }
  },
  "request_id": "req_ghi789jkl012"
}

When a user is enrolled, a enrollment.created webhook event is triggered automatically. You can configure webhook endpoints to receive real-time notifications.

Get User Progress

GET /v2/users/{user_id}/progress

Returns detailed progress information for a specific user, including per-course progress, completed lessons, and time spent.

Path Parameters

ParameterTypeRequiredDescription
user_id string Required The user's ID (e.g., usr_2xKj9mNpQr)

Example Response

{
  "data": {
    "user_id": "usr_2xKj9mNpQr",
    "user_name": "Sarah Johnson",
    "total_enrolled": 5,
    "total_completed": 2,
    "total_time_spent_minutes": 3420,
    "courses": [
      {
        "course_id": "crs_4mNp7qRsT",
        "course_title": "Complete Web Development Bootcamp",
        "status": "in_progress",
        "current_lesson": 47,
        "total_lessons": 186,
        "percent_complete": 25.3,
        "last_accessed_at": "2024-03-14T14:22:00Z",
        "time_spent_minutes": 1580
      },
      {
        "course_id": "crs_7wXy1zAbC",
        "course_title": "Python for Data Science",
        "status": "completed",
        "current_lesson": 120,
        "total_lessons": 120,
        "percent_complete": 100,
        "completed_at": "2024-02-28T18:00:00Z",
        "time_spent_minutes": 1200,
        "certificate_id": "cert_3dEf6gHiJ"
      }
    ]
  }
}

Get Certificates

GET /v2/certificates

Lists all certificates issued in your organization. Optionally filter by user ID.

Query Parameters

ParameterTypeRequiredDescription
user_id string Optional Filter certificates by user ID
course_id string Optional Filter by course ID
issued_after date Optional Filter certificates issued after this date (ISO 8601)

Example Response

{
  "data": [
    {
      "id": "cert_3dEf6gHiJ",
      "user_id": "usr_2xKj9mNpQr",
      "user_name": "Sarah Johnson",
      "course_id": "crs_7wXy1zAbC",
      "course_title": "Python for Data Science",
      "issued_at": "2024-02-28T18:00:00Z",
      "certificate_url": "https://learnflow.com/certificates/cert_3dEf6gHiJ",
      "verification_url": "https://learnflow.com/verify/cert_3dEf6gHiJ",
      "credential_id": "lf:cert:3dEf6gHiJ",
      "download_urls": {
        "pdf": "https://cdn.learnflow.com/certs/cert_3dEf6gHiJ.pdf",
        "png": "https://cdn.learnflow.com/certs/cert_3dEf6gHiJ.png",
        "svg": "https://cdn.learnflow.com/certs/cert_3dEf6gHiJ.svg"
      }
    }
  ]
}

Manage Webhook Endpoints

POST /v2/webhooks

Register a new webhook endpoint to receive real-time event notifications.

Request Body

ParameterTypeRequiredDescription
url string Required The HTTPS URL to receive webhook events
events string[] Required Array of event types to subscribe to (see Webhooks section)
secret string Optional Custom signing secret. If omitted, one is auto-generated.
description string Optional Human-readable description of this endpoint

Integration Hub

Connect LearnFlow with your existing tools and platforms. Our integration hub provides pre-built connectors for popular services, as well as flexible APIs for custom integrations.

Slack

Send course completions, progress alerts, and enrollment notifications directly to Slack channels.

Native OAuth 2.0

Zapier

Connect LearnFlow to 5,000+ apps. Automate workflows without writing code.

Native 5,000+ apps

LMS (SCORM / xAPI)

Import and export course content using SCORM 1.2/2004 and xAPI (Tin Can) standards.

Native SCORM 2004 xAPI

SSO / SAML 2.0

Enable Single Sign-On with your identity provider. Supports Okta, Azure AD, OneLogin, and more.

Enterprise SAML 2.0 OIDC

Google Workspace

Sync calendars, integrate with Google Classroom, and enable Google Sign-In for students.

Native Calendar

Microsoft Teams

Embed LearnFlow content in Teams, send notifications, and enable Microsoft SSO.

Native Teams Tab

HRIS / HR Systems

Bi-directional sync with BambooHR, Workday, and Gusto for employee onboarding and training tracking.

Webhook Bi-directional

Analytics & BI

Export data to Snowflake, BigQuery, Tableau, or Power BI for advanced analytics.

API Data Export

Official SDKs

Use our official SDKs to interact with the LearnFlow API in your preferred programming language. All SDKs are open-source and available on GitHub.

Python

Python 3.7+

pip install learnflow

Node.js

Node 14+

npm install learnflow

Go

Go 1.19+

go get github.com/learnflow/go

Java

Java 11+

implementation 'com.learnflow:sdk:2.4.1'

Ruby

Ruby 2.7+

gem install learnflow-ruby

PHP

PHP 8.0+

composer require learnflow/learnflow-php

SDK Example (Python)

import learnflow

# Initialize the client
learnflow.api_key = "sk_live_your_api_key"

# List users
users = learnflow.User.list(
    page=1,
    per_page=50,
    role="student",
    status="active"
)

# Create a user
new_user = learnflow.User.create(
    email="new.user@example.com",
    name="New User",
    role="student",
    metadata={"department": "Engineering"}
)
print(f"Created user: {new_user.id}")

# Enroll user in a course
enrollment = learnflow.Enrollment.create(
    user_id=new_user.id,
    course_id="crs_4mNp7qRsT"
)
print(f"Enrollment status: {enrollment.status}")

# Get user progress
progress = learnflow.User.progress(user_id=new_user.id)
print(f"Total time spent: {progress.total_time_spent_minutes} minutes")

Postman Collection

Import our Postman collection to quickly test all API endpoints with pre-configured environments for both sandbox and live.

Run in Postman Download Collection (JSON)

OpenAPI Specification

The complete OpenAPI 3.0 specification is available for download or online viewing. Use it to generate client code in any language or to explore the API interactively.

OpenAPI YAML OpenAPI JSON Interactive API Console

Webhooks

Webhooks allow you to receive real-time notifications when events occur in your LearnFlow account. Configure webhook endpoints to listen for specific events and take automatic actions in your own systems.

Available Events

r>
Event NameDescriptionTrigger
user.created A new user account was created On user registration or API creation
user.updated User profile or settings were updated On any user profile change
enrollment.created User enrolled in a new course On new enrollment
enrollment.completed User completed a course When all lessons are finished
enrollment.progress_updated User's course progress changed When a lesson is completed
certificate.issued A certificate was issued to a user On course completion
course.published A course was published or republished When instructor publishes course
payment.completed A payment was successfully processed On successful payment

Webhook Payload

All webhook events are delivered as POST requests to your configured URL. The payload includes the event type, timestamp, and event-specific data.

{
  "id": "evt_1NtQ7mKpR2",
  "type": "enrollment.completed",
  "created_at": "2024-03-14T16:35:00Z",
  "data": {
    "enrollment_id": "enr_9kLm2nPqR",
    "user_id": "usr_2xKj9mNpQr",
    "user_name": "Sarah Johnson",
    "course_id": "crs_4mNp7qRsT",
    "course_title": "Complete Web Development Bootcamp",
    "completed_at": "2024-03-14T16:35:00Z",
    "certificate_id": "cert_8kLm2nPqR",
    "total_time_minutes": 2520,
    "average_quiz_score": 92.5
  },
  "metadata": {
    "webhook_id": "wh_3xYz5aBcD",
    "attempt": 1
  }
}

Verifying Webhook Signatures

LearnFlow signs all webhook payloads using HMAC-SHA256. Verify the signature using the X-LearnFlow-Signature header and your webhook secret.

// Node.js example for verifying webhook signatures
const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(payload, 'utf8')
    .digest('hex');

  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from('whsec_' + expectedSignature)
  );
}

// In your webhook handler:
app.post('/webhook', (req, res) => {
  const signature = req.headers['x-learnflow-signature'];
  const payload = JSON.stringify(req.body);

  if (!verifyWebhook(payload, signature, WEBHOOK_SECRET)) {
    return res.status(401).send('Invalid signature');
  }

  // Process the webhook event
  handleEvent(req.body);
  res.status(200).json({ received: true });
});

Webhook Retry Policy: LearnFlow automatically retries failed webhook deliveries up to 5 times with exponential backoff. If all retries fail, the webhook endpoint is disabled and you'll receive an email notification.

API Changelog

We track all changes to the API for transparency. Current version: v2.4.1 (March 2024).

v2.4.1 — March 14, 2024 Latest
  • Added metadata field to User creation endpoint
  • Fixed pagination offset calculation in Courses list
  • Improved webhook delivery reliability
v2.4.0 — February 28, 2024
  • New Certificates API endpoint
  • OAuth 2.0 with PKCE support
  • Go SDK release (v2.0)
v2.3.0 — January 15, 2024
  • User Progress endpoint with per-course details
  • Updated rate limit headers format

FAQ

How do I get API access?
API access is included with all Professional and Enterprise plans. Navigate to Settings → Developer → API Keys to generate your API key. Free/Starter accounts have limited read-only access.
Can I use the API in a production environment?
Yes! Our API is designed for production use. We offer a 99.9% uptime SLA for Enterprise customers. Always use our sandbox environment for testing before deploying to production.
How do webhook retries work?
Webhooks are retried up to 5 times with exponential backoff (1 minute, 5 minutes, 15 minutes, 1 hour, 4 hours). Your endpoint must respond with a 2xx status code. Non-2xx responses trigger a retry.
Do you have bulk/batch endpoints?
Currently, we support bulk enrollment via the POST /v2/enrollments/batch endpoint (Enterprise only), which allows enrolling up to 100 users in a single request. Bulk user creation is also supported via our CSV import tool or the batch API.

Support

Need help with the API? We're here to assist.

Developer Community

Join our Discord server to ask questions and share ideas.

Join Discord →

Email Support

Reach out to our API support team for personalized help.

api-support@learnflow.com →

Documentation

Explore guides, tutorials, and reference docs.

View Docs →

API Status: All systems are operational. View our real-time status page for detailed uptime information: status.learnflow.com