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
- Overview
- Base URL and Headers
- List Users
- Show User
- Update User
- Archive User
- Unarchive User
- Delete User
- Trainings by Instructor
- Trainings by Student
- Exams by Student
- Get User Cart or Wishlist
- Get User Orders
- List Instructors
- Get Instructor by ID
- Exams by Instructor
- Quizzes by Instructor
- Set Instructor Default Revenue
- Download Order Invoice
- Export Owners CSV
- Owner Emails (JSON)
- Internal Reused Methods
- 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)
2. Base URL and Headers
Base API URL: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
- 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
- setting
role_id = 2makes the public profile visible - setting another role hides the public profile
public_profile_verificationis only applied when the authenticated user is admin or super-admin
6. Archive User
Archives a user by fillingarchived_at.
Success Response
7. Unarchive User
Restores an archived user by clearingarchived_at.
Success Response
8. Delete User
Deletes an already archived user.Success Response
- 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= wishlist2= cart3= order
Example Request
Success Response
13. Get User Orders
Returns the user’s orders wheretype = 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 inroutes/api.php:
quizzes_by_instructor() method in the controller class.
Example Request
Current Practical Result
In local/debug mode, a typical server error is:- this route is declared, but it is not currently implemented
18. Set Instructor Default Revenue
Updatesdefault_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 (ordertype = 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
labelis the training / exam title (there is no separatetitlecolumn).emails_comma_separatedjoins the addresses with a comma and a space (,);totalis 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_examscount 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 bydownloadOrderInvoice().getThemeForCompany(int $companyId)Brief role: loads company name and platform logo used by invoice generation.
23. Known Implementation Notes
DELETE /api/user/{id}/deleteperforms a soft delete even though the response message saysforce deleted.archiveusesarchived_at, while delete uses Laraveldeleted_at.show()removes public profile fields whenhide_public_profile = true.- update uses
POST /api/user/{id}, notPUTorPATCH. /api/instructors/{instructor_id}/quizzesis declared but not implemented.