Skip to main content
Export trainings as JSON, bulk-download all trainings as a ZIP, import trainings from JSON files, and back up a training together with its chapters, lessons, and chapter quizzes. Use these endpoints to move trainings between environments, snapshot them for compliance, or seed a new company catalog.
Heads-up: chapters, lessons, and quizzes are not included in a standard training export or import. Only the Back up a training endpoint bundles chapters, lessons, and chapter quizzes next to the training JSON.

Table of contents

  • Base URL & Headers
  • The training export schema
  • Export a single training
  • Export all trainings (ZIP)
  • Import trainings from JSON
  • Back up a training
  • Import behavior at a glance
  • Postman setup

Base URL & Headers

All endpoints run behind auth:sanctum, the “user is not blocked” check, and the per-company policy middleware.

The training export schema

Every per-training JSON produced by the export and bulk export endpoints follows this shape:
categories holds the labels of the training’s categories: one label since 01/11/2026 (a training has one category, see Trainings → Assign categories), still as an array. Files exported earlier can list several.

Export a single training

Downloads one training as a .json file. Chapters, lessons, and quizzes are not included.

Query parameters

Example request

In Postman, click Send and Download to save the file. The filename follows the pattern {slug}-{YYYY-MM-DD-HH-mm}.json.

Responses

200 OK — file body follows the training export schema. 404 Not Found
403 Forbidden
422 Unprocessable Entity
500 Internal Server Error

Export all trainings (ZIP)

Downloads a ZIP archive containing one JSON file per training for the given company.

Query parameters

Example request

ZIP layout

Each JSON file follows the training export schema.

Responses

404 Not Found
500 Internal Server Error — ZIP creation failed
500 Internal Server Error — generic failure

Import trainings from JSON

Creates one or more trainings from uploaded .json files. Accepts either a single file or an array.
⚠️ Import behavior is intentionally conservative:
  • Instructor is always forced to the fallback system user (id 2). The original instructor_id in the file is ignored.
  • Media — image_id and video_id are always set to null.
  • Visibility — is_public is always false after import.
  • Slug is normalized, truncated to 13 characters, and suffixed with a random 4-character string on collision.
  • Category — only the first label of categories is kept (one category per training since 01/11/2026).
  • Chapters / lessons / quizzes are not imported. Use the chapter/lesson import flow separately.

Form-data fields

Per-file JSON validation

Each uploaded file is validated before insertion:
  • revenue_percentage — required, numeric, between 0 and 100.
  • label — optional (defaults to "Untitled Training").
  • slug — optional (generated from label when missing).
  • level — optional (defaults to Beginner).
  • duration, price — optional (default 0).
  • discounted_price, views_count — optional.
  • categories — optional array of labels. Only the first label is used (one category per training since 01/11/2026): it is matched by label in the target company and created when missing. The other labels are ignored and never created, so a file exported before 01/11/2026 with several categories keeps its first one.
  • tags — optional array of labels. Missing ones are auto-created for the target company.

Example file payload

intro-to-pmp.json

Postman setup (Body → form-data)

Multi-file upload:
Single-file upload:
Remove any explicit Content-Type header in Postman so the client adds the correct multipart/form-data; boundary=... itself.

Responses

200 OK — all files succeeded
200 OK — partial success
Partial failures still return HTTP 200. Always inspect the failed_trainings array.
400 Bad Request — nothing uploaded
422 Unprocessable Entity — bad file type or missing company

Back up a training

Downloads a ZIP archive with the training JSON plus all its chapters (each with its lessons and all its chapter quizzes). The training’s final quiz is not part of the backup — export it with the quiz export.

Query parameters

Example request

ZIP layout

The top-level training JSON uses the training export schema. Each chapters/*.json is the full chapter record, including its lessons and, since 19/10/2026, a quizzes array with every quiz of the chapter (published and draft, creation order) with questions, options, and option items, plus the deprecated quiz (= the first one). Same shape as the chapter export schema.

Example chapter file

chapter-1-2026-04-17-12-30.json
Each quiz object is shortened here; the file carries every column of the quiz row (plus its instructor and computed rating / sales fields). quiz is the deprecated copy of quizzes[0] (or null), kept for older readers; backups made before 19/10/2026 only have quiz.

Responses

404 Not Found
403 Forbidden
500 Internal Server Error

Import behavior at a glance


Postman setup

  1. Environment variables. Reuse the same environment as your main API collection:
    • base_url — e.g. http://localhost:8000
    • token — Sanctum token from POST /auth/login
  2. Collection-level headers.
    • Accept: application/json
    • Authorization: Bearer {{token}} Do not set a Content-Type header on the import request — Postman must build the multipart boundary itself.
  3. Downloading files. For export, export-all, and backup, click Send and Download so Postman writes the file to disk.
  4. Smoke-test flow.
    1. GET /trainings/export-import/export-all?company_id=1 — download ZIP
    2. Unzip and pick one file
    3. POST /trainings/export-import/import with that file
    4. GET /trainings?company_id=1 — confirm the new training appears
    5. GET /trainings/export-import/backup/{id}?company_id=1 — snapshot chapters too