Create a course
This endpoint allows creating a course in the business catalog, together with all its trainings.
POST /api/v2/businesses/{businessId}/courses
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:
POST /api/v2/businesses/BUSINESSID/courses
{
"id": "CRS-CAJ",
"name": "Cash register",
"abbreviation": "CAJ",
"color": "#F7C2E5",
"description": "Payment methods, POS operation and cash count",
"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": "PT3H",
"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 201 Created with the information of the created course.
Considerations
The request is atomic: the course and all its trainings are created together or nothing is created.
All the identifiers in the request are external identifiers and must exist in the business for the request to be valid.
If the id of the course or of any of its trainings is not provided, Orquest generates an identifier automatically and returns it in the response.
|
The request is not idempotent: if it is repeated with the same |
Error codes
In addition to the common errors, this endpoint can return the following codes:
| Code | Message | Description |
|---|---|---|
|
Course not found: <courseId> |
One of the courses in |
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 |
|
|
The request conflicts with data already stored |
A course with the given |