POST /api/v1/courses/{courseId}/cover
Deposits an image, adds it to the school's media library, and returns its URL
and media id. It does not change the course.
Depositing a file and setting a cover are two gestures: you send the returned
url in Update a course when you are
ready. Writing it immediately would leave a cover on a change somebody then
abandons.
The body is multipart/form-data with one part named file. Accepted image
types are WebP, JPEG and PNG.
| Role in the organization | This endpoint |
|---|
OWNER | Allowed |
ADMIN | Allowed |
MEMBER | Refused |
| Requirement | Rule for this endpoint |
|---|
| Business role | None — the permission is that of the course itself |
| Resource scope | Course of the school attached to the API key |
| Resource state | Not applicable — the course is not written; the image joins the media library of the course's school |
The permission is checked before anything is written to storage: a refused
caller leaves no file behind.
| Parameter | Type | Required | Description |
|---|
courseId | UUID | yes | Course visible from the key's school |
| Header | Required | Description |
|---|
x-api-key | yes | API key created for this school |
Content-Type | yes | multipart/form-data |
X-Correlation-Id | no | Caller correlation id, returned or generated |
No Idempotency-Key, and that is not an oversight: a deposit is not a
domain command, it claims no key, and every call writes a new timestamped file.
Requiring the header would promise a replay guarantee the storage does not give.
Request body
| Part | Type | Required | Description |
|---|
file | file | yes | The image. WebP, JPEG or PNG |
curl -X POST "$COHORTE_API_BASE_URL/api/v1/courses/$COURSE_ID/cover" \
-H "x-api-key: $COHORTE_API_KEY" \
-F "file=@cover.png"
201 Created — the file is stored and listed in the school's media library.
400 Bad Request — no file part, an empty file, an unsupported type, or a file over the size limit.
401 Unauthorized — the key is missing, invalid, or no longer attached to a member.
403 Forbidden — the bearer is not OWNER or ADMIN of this school.
404 Not Found — the course is unknown or belongs to another school.
| Field | Type | Nullable | Description |
|---|
success | boolean | no | true for a successful request |
data.mediaId | UUID | no | Identifier of the image in the school's media library |
data.url | string | no | Public URL of the stored image |
data.name | string | no | Original file name |
data.size | integer | no | Size in bytes |
data.type | string | no | MIME type |
correlationId | UUID | no | Correlation id for support |
{
"success": true,
"data": {
"mediaId": "1c7e9a35-6b2d-4f8a-8e41-3c4d5e6f7a81",
"url": "https://files.example.com/covers/cover.png",
"name": "cover.png",
"size": 248312,
"type": "image/png"
},
"correlationId": "0f6b1d92-5c3e-4a8b-9d71-3e2f4a6b8c10"
}
- Upload the image here.
- Send the returned
url as image in PATCH /api/v1/courses/{courseId}.
The course is then linked to that media. An external image URL stays
allowed; it is simply not part of the media library.