PATCH /api/v1/programs/{programId}/lessons/by-external-id/{externalId}
Updates the lesson of the program whose identifier is externalId (case is
ignored). It follows the rules of
Update a lesson exactly: a field you
omit is left alone, null or [] erases it, and the status does not change
here.
externalId in the body is the lesson's new identifier; the one in the
path only finds the lesson.
| Role in the organization | This endpoint |
|---|---|
OWNER | Allowed |
ADMIN | Allowed |
MEMBER | Refused |
| Requirement | Rule for this endpoint |
|---|---|
| Business role | None — writing content is the same gesture as composing the structure |
| Resource scope | A lesson of a program of the school attached to the API key |
| Resource state | An archived program or course answers 403 |
| Parameter | Type | Required | Description |
|---|---|---|---|
programId | UUID | yes | Program that holds the lesson |
externalId | string | yes | The lesson's current identifier |
| Header | Required | Description |
|---|---|---|
x-api-key | yes | API key created for this school |
Idempotency-Key | yes | Stable key for this change |
X-Correlation-Id | no | Caller correlation id, returned or generated |
The fields of Update a lesson:
title, content, videoUrl, externalId, audience, level,
prerequisites, videoMinutes, taskRef.
{"audience": ["freelance"], "videoMinutes": 6, "taskRef": null}curl -X PATCH "$COHORTE_API_BASE_URL/api/v1/programs/$PROGRAM_ID/lessons/by-external-id/LIV-04" \
-H "x-api-key: $COHORTE_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H 'Content-Type: application/json' \
-d '{"level":"deep_dive","prerequisites":["LIV-01","LIV-02"]}'200 OK — the lesson, as it now stands (same shape as Update a lesson).400 Bad Request — missing Idempotency-Key, invalid JSON, or a field outside its rules (for example audience combining all with another value, or the lesson listed as its own prerequisite).401 Unauthorized — the key is missing, invalid, or no longer attached to a member.403 Forbidden — the bearer is not OWNER or ADMIN, or the program is archived.404 Not Found — no lesson of this program carries the identifier, or the program belongs to another school.409 Conflict — the new externalId is already used by another lesson of the program.