Skip to main content
Users API
This file documents the endpoints related to user management, user listings, user detail updates, and the utility routes exposed through the user API.

Table of Contents

  1. Overview
  2. Base URL and Headers
  3. List Users
  4. Show User
  5. Update User
  6. Archive User
  7. Unarchive User
  8. Delete User
  9. Trainings by Instructor
  10. Trainings by Student
  11. Exams by Student
  12. Get User Cart or Wishlist
  13. Get User Orders
  14. List Instructors
  15. Get Instructor by ID
  16. Exams by Instructor
  17. Quizzes by Instructor
  18. Set Instructor Default Revenue
  19. Download Order Invoice
  20. Export Owners CSV
  21. Owner Emails (JSON)
  22. Internal Reused Methods
  23. Known Implementation Notes

1. Overview

This file covers:
  • user CRUD-style management routes
  • archive / restore / delete flow
  • student ownership routes
  • instructor listing routes that are still exposed through the user API
  • invoice export
  • owner CSV export
  • owner emails as JSON (by training / exam id or slug)
These routes are inside the authenticated protected route group.

2. Base URL and Headers

Base API URL:
Suggested Postman variables:
Headers:

3. List Users

Returns paginated users for one company.

Query Parameters

Example Request

Success Response


4. Show User

Returns one user by ID.

Example Request

Success Response

Note:
  • if hide_public_profile = true, the controller removes public profile fields from the response

5. Update User

Updates user core fields, blocking state, password, and instructor public profile data.

Request JSON

Success Response

Conflict Example

Important notes:
  • setting role_id = 2 makes the public profile visible
  • setting another role hides the public profile
  • public_profile_verification is only applied when the authenticated user is admin or super-admin

6. Archive User

Archives a user by filling archived_at.

Success Response


7. Unarchive User

Restores an archived user by clearing archived_at.

Success Response


8. Delete User

Deletes an already archived user.

Success Response

Important note:
  • despite the message text, this is a soft delete through Laravel deleted_at

9. Trainings by Instructor

Returns paginated trainings belonging to one instructor.

Example Request

Success Response


10. Trainings by Student

Returns the paid public trainings owned by a student.

Example Request

Success Response


11. Exams by Student

Returns the standalone exams owned by a student through paid orders.

Example Request

Success Response


12. Get User Cart or Wishlist

Returns the latest order shell for the given type. Order type values used by the project:
  • 1 = wishlist
  • 2 = cart
  • 3 = order

Example Request

Success Response


13. Get User Orders

Returns the user’s orders where type = 3.

Example Request

Success Response


14. List Instructors

Returns paginated instructors for one company.

Query Parameters

Example Request

Success Response

catalog_counts (page 1 only, when company_id is sent). The size of each student Marketplace catalog of the company: trainings (public trainings), exams (published standalone exams) and instructors (users with role 2). They are counted without the request’s own filters (search, categories, price, …), leave archived and deleted rows out, and are cached per company for 5 minutes; the cache is cleared as soon as a training, exam or instructor is created, published / unpublished, archived, deleted or restored (app/Services/MarketplaceCountsService.php, MarketplaceCountsObserver). The same object comes on page 1 of GET /preview-trainings, GET /preview-exams and GET /instructors, so the app fills the three Marketplace tab counts from whichever catalog loads first, with no extra request. Pages 2 and later do not carry it.

15. Get Instructor by ID

Returns one instructor from the authenticated user’s company.

Example Request

Success Response


16. Exams by Instructor

Returns the standalone exams created by the instructor.

Example Request

Success Response


17. Quizzes by Instructor

This route exists in routes/api.php:
But there is currently no matching quizzes_by_instructor() method in the controller class.

Example Request

Current Practical Result

In local/debug mode, a typical server error is:
Important note:
  • this route is declared, but it is not currently implemented

18. Set Instructor Default Revenue

Updates default_revenue_percentage for an instructor.

Request JSON

Success Response

Error Example


19. Download Order Invoice

Downloads the authenticated user’s invoice PDF for a paid order.

Example Request

Success Behavior

  • returns a PDF stream
  • content type is application/pdf

Error Example for Unpaid Order


20. Export Owners CSV

Exports user ownership for one training or one exam.

Request JSON for Training

Request JSON for Exam

Validation Error Example

Success Behavior

  • successful response is a CSV file download
  • need the same list as JSON, or by slug instead of id? See 21. Owner Emails (JSON) — both endpoints share the same ownership query in UsersController::ownersQuery()
  • CSV columns are:

21. Owner Emails (JSON)

Returns, as JSON, the emails of every user who owns one training or one standalone exam — the same ownership rule as the CSV export above (order type = 3, status Paid Online 5 or Paid Offline 4, order item access_revoked = false), restricted to your company. Each user is listed once even with several paid orders, archived and soft-deleted users are skipped, and the list is ordered by user id. Made for the “who bought this?” question: copy emails_comma_separated straight into the recipients field of a mail client.

Query Parameters

Exactly one of the four selectors is required.

Example Requests

Success Response — training

Success Response — exam

  • label is the training / exam title (there is no separate title column).
  • emails_comma_separated joins the addresses with a comma and a space (, ); total is the number of distinct emails.
  • No role filter is applied: like the CSV export, any user with a paid, non-revoked order is listed (students assigned for free through POST /order/assign_trainings_to_students / POST /order/assign_exams count as Paid Offline owners).

Error Responses

404 also covers archived and soft-deleted trainings / exams (they are hidden by the model scopes), and a quiz that belongs to a training or chapter (not sellable, so it has no owners).

22. Internal Reused Methods

These methods are part of the same controller flow but do not have their own route:
  • buildInvoicePdfViewData(Order $order) Brief role: builds the final invoice payload used by downloadOrderInvoice().
  • getThemeForCompany(int $companyId) Brief role: loads company name and platform logo used by invoice generation.

23. Known Implementation Notes

  • DELETE /api/user/{id}/delete performs a soft delete even though the response message says force deleted.
  • archive uses archived_at, while delete uses Laravel deleted_at.
  • show() removes public profile fields when hide_public_profile = true.
  • update uses POST /api/user/{id}, not PUT or PATCH.
  • /api/instructors/{instructor_id}/quizzes is declared but not implemented.