Set up Moodle web services and call its REST API

domain: moodle.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. As a Moodle administrator, enable web services at Site Administration > Advanced Features > Enable web services, then enable the REST protocol at Site Administration > Plugins > Web Services > Manage Protocols.
  2. Create a dedicated service at Site Administration > Plugins > Web Services > External Services; add the specific API functions your integration needs (e.g., core_user_get_users, core_enrol_get_enrolled_users) to that service.
  3. Create or designate a Moodle user with the appropriate capabilities, then generate a token for that user at Site Administration > Plugins > Web Services > Manage Tokens, associating it with your external service.
  4. Call the REST endpoint using HTTPS: GET or POST to https://yourmoodle.example.com/webservice/rest/server.php?wstoken=your_token&wsfunction=function_name&moodlewsrestformat=json plus any function-specific parameters.
  5. Parse the JSON response; Moodle wraps successful responses directly in the returned object, but errors return an object with an exception key and message field — always check for the exception key before processing the result.
  6. For bulk operations (e.g., enrolling many users), batch calls where the function supports array parameters rather than making one HTTP call per user to avoid hitting server timeout or rate limits.

Known gotchas

Related routes

Call the Moodle Web Services REST API to create a course, enroll users, and upload a SCORM package using the file upload and mod_scorm_add_instance functions
moodle.org · 6 steps · unrated
Enrol a user in a Moodle course via REST web service (enrol_manual_enrol_users)
docs.moodle.org · 6 steps · unrated
expose and call Moodle's core_competency web service functions to manage a learning plan
docs.moodle.org · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans