Skip to main content
Version: Next

Administration REST API


The main distribution includes the plugin-admin-api plugin preinstalled. It provides a REST API that allows to change the server settings while it is running, etc.

This is very useful when running acceptance tests, as you can change the current mock simply with a HTTP request in the before method of your tests, for example.

A client for the administration api is also distributed as a separated package: @mocks-server/admin-api-client.


  • plugins.adminApi.path (String): Path for the administration REST API. Default is /admin. You should change it only in case there is any conflict with the API you are mocking.

API resources

Available API resources are:

  • GET /admin/about Returns "plugin-admin-api" information.
    • Response body example: { "version": "1.2.0" }
  • GET /admin/mocks Returns mocks.
  • GET /admin/mocks/:id Returns a specific mock.
  • GET /admin/routes Returns routes collection.
  • GET /admin/routes/:id Returns a specific route.
  • GET /admin/routes-variants Returns routes variants collection.
  • GET /admin/routes-variants/:id Returns a specific route variant.
  • GET /admin/mock-custom-routes-variants Returns an array of currently custom routes variants ids.
  • POST /admin/mock-custom-routes-variants Defines a route variant to be used by current mock.
    • Request body example: { "id": "users:error" }
  • DELETE /admin/mock-custom-routes-variants Restore routes variants to those defined in current mock.
  • GET /admin/settings Returns current server settings.
    • Response body example: { "server": { "delay": 0 }, "mocks": { "selected": "foo-mock" } }
  • PATCH /admin/settings Changes current server settings.
    • Request body example: { "server": { "delay": 3000 } }
  • GET /admin/alerts Returns current alerts.
  • GET /admin/alerts/:id Returns a specific alert. The alert id is equivalent to the alert context (read the developing plugins chapter for further info about alerts).