LearnWorlds Users API

Manage school users (students / members) and their profiles.

OpenAPI Specification

learnworlds-users-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: LearnWorlds Courses Users API
  description: 'The LearnWorlds API (v2) is a REST API for programmatically managing an online school on the LearnWorlds course / LMS platform. It exposes school entities - users, courses, enrollments, subscriptions, payments, course progress, tags, bundles, certificates, and webhooks - over HTTPS. The API is served per-school from https://{school}.learnworlds.com/admin/api/v2 and is authenticated with OAuth2 (client credentials): a bearer access token is obtained from the school''s token endpoint and every request also carries the Lw-Client header identifying the client (school) application. API and Webhook access is a plan-gated feature (Learning Center and High Volume & Corporate plans). Version 1 of the API is deprecated. Exact request/response schemas and the full endpoint catalog live in the official reference at learnworlds.dev; the paths modeled here are grounded in the public documentation, help center, and the official API wrapper, and should be reconciled against the live reference.'
  version: '2.0'
  contact:
    name: LearnWorlds
    url: https://www.learnworlds.dev
  license:
    name: Proprietary
    url: https://www.learnworlds.com/terms-of-service/
servers:
- url: https://{school}.learnworlds.com/admin/api/v2
  description: Per-school API base URL
  variables:
    school:
      default: yourschool
      description: The subdomain / school identifier of your LearnWorlds academy.
security:
- oauth2ClientCredentials: []
  lwClient: []
tags:
- name: Users
  description: Manage school users (students / members) and their profiles.
paths:
  /users:
    get:
      operationId: listUsers
      tags:
      - Users
      summary: List users
      description: Lists the school's users. Supports pagination and filtering.
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/ItemsPerPage'
      responses:
        '200':
          description: A paginated list of users.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: createUser
      tags:
      - Users
      summary: Create a user
      description: Creates a new user (student) in the school.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserInput'
      responses:
        '201':
          description: The created user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/ValidationError'
  /users/{id}:
    parameters:
    - $ref: '#/components/parameters/UserId'
    get:
      operationId: getUser
      tags:
      - Users
      summary: Get a user
      description: Retrieves a single user by ID or email.
      responses:
        '200':
          description: The requested user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      operationId: updateUser
      tags:
      - Users
      summary: Update a user
      description: Updates an existing user's profile fields.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserInput'
      responses:
        '200':
          description: The updated user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
              message:
                type: string
    User:
      allOf:
      - $ref: '#/components/schemas/UserInput'
      - type: object
        properties:
          id:
            type: string
          created:
            type: integer
            description: Unix timestamp of user creation.
          is_admin:
            type: boolean
          tags:
            type: array
            items:
              type: string
    Pagination:
      type: object
      properties:
        page:
          type: integer
        total_items:
          type: integer
        items_per_page:
          type: integer
        total_pages:
          type: integer
    UserList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/User'
        meta:
          $ref: '#/components/schemas/Pagination'
    UserInput:
      type: object
      required:
      - email
      properties:
        email:
          type: string
          format: email
        username:
          type: string
        password:
          type: string
        first_name:
          type: string
        last_name:
          type: string
        tags:
          type: array
          items:
            type: string
        fields:
          type: object
          additionalProperties: true
  parameters:
    UserId:
      name: id
      in: path
      required: true
      description: The user identifier (LearnWorlds user id or email).
      schema:
        type: string
    ItemsPerPage:
      name: items_per_page
      in: query
      required: false
      description: The number of items to return per page.
      schema:
        type: integer
        default: 50
    Page:
      name: page
      in: query
      required: false
      description: The page number to retrieve.
      schema:
        type: integer
        default: 1
  responses:
    ValidationError:
      description: The request payload failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid access token or Lw-Client header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The requested resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    oauth2ClientCredentials:
      type: oauth2
      description: 'OAuth2 client credentials flow. Exchange your client_id and client_secret for a bearer access token at the school token endpoint, then pass it as Authorization: Bearer ACCESS_TOKEN.'
      flows:
        clientCredentials:
          tokenUrl: https://yourschool.learnworlds.com/admin/api/oauth2/access_token
          scopes: {}
    lwClient:
      type: apiKey
      in: header
      name: Lw-Client
      description: Client identifier header sent on every request alongside the bearer token. Its value is your API client_id.