Update a course
This endpoint allows updating the full definition of a course in the catalog, including its list of trainings.
PUT /api/v2/businesses/{businessId}/courses/{courseId}
The courseId is the external identifier of the course to be updated.
Below is a detailed explanation of each of the fields that can make up the request body, with some being mandatory for the request to be successful.
|
Mandatory fields are marked with an asterisk (*). |
Request body
| JSON Analysis |
|---|
Details
|
Request example
Once the analysis of the different fields has been done, an example of the request is shown:
PUT /api/v2/businesses/BUSINESSID/courses/CRS-CAJ
{
"name": "Cash register",
"description": "Payment methods, POS operation, cash count and refunds",
"abbreviation": "CAJ",
"color": "#F7C2E5",
"expiresAfter": "P1Y",
"requirementIds": [
"CRS-VAC"
],
"unlockCatalogLocationIds": [
"000001"
],
"trainings": [
{
"id": "TRN-CAJ-NOR",
"name": "Cash register rules and payment methods",
"day": 1,
"order": 1,
"duration": "PT1H",
"needsTrainer": false,
"needsValidation": false
},
{
"id": "TRN-CAJ-TPV",
"name": "POS operation",
"day": 1,
"order": 2,
"duration": "PT4H",
"needsTrainer": true,
"needsValidation": false,
"coverCatalogLocationId": "000001"
},
{
"id": "TRN-CAJ-ARQ",
"name": "Cash count and reconciliation",
"day": 2,
"order": 1,
"duration": "PT1H",
"needsTrainer": true,
"needsValidation": true
}
]
}
If the request is correct, the response will be a 200 OK with the resulting course, with the same structure returned by Get course information.
Considerations
The request replaces the whole definition of the course: fields that are not sent are left empty or with their default value. The id in the body is ignored and the course keeps the identifier given in the URL.
Trainings are identified by their id:
-
Trainings with an existing
idare updated. -
New trainings, or trainings without
id, are created. -
Existing trainings that are not included in the request are removed from the course.
Course versioning
Some changes modify the structure of the course: adding or removing trainings, changing the day or order of any of them, or changing the tasks in unlockCatalogLocationIds.
If the course is already assigned to any employee and the change is structural, Orquest keeps the previous definition for the existing assignments and applies the new definition only to assignments created from that moment on. The course keeps its external identifier and the API always returns the current version.
Courses that have this course as a requirement and training paths that include it automatically switch to the updated current version.
|
A course cannot be a requirement of itself, either directly or indirectly through other courses. |
Error codes
In addition to the common errors, this endpoint can return the following codes:
| Code | Message | Description |
|---|---|---|
|
Course not found: <courseId> |
The |
Catalog location not found: <locationId> |
One of the tasks in |
|
|
Name cannot be longer than 50 characters |
The |
Description cannot be longer than 500 characters |
The |
|
Abbreviation cannot be longer than 3 characters |
The |
|
For input string: <color> under radix 16 |
The |
|
training name is required |
A training has no |
|
training day is required / training day must be greater than 0 |
A training has no |
|
training order is required |
A training has no |
|
training duration is required / Duration cannot be longer than 1 day |
A training has no |
|
Duplicated training outerId in course trainings |
Several trainings have the same |
|
Requirement loop detected for course with id […] |
The given requirements create a loop, for example, because the course is a requirement of itself. |
Useful links
What is a course?
What is a training path?