POST /api/v1/programs/{programId}/courses/reorder
Sets the order of the courses in a program. You send the complete ordered list, not a move.
That is deliberate: a complete list describes a final state, so two calls racing each other converge instead of fighting, and validation becomes set-based — the ids you send must be exactly the ids of that program, which refuses a foreign id by construction rather than by a check somebody could forget.
| Role in the organization | This endpoint |
|---|---|
OWNER | Allowed |
ADMIN | Allowed |
MEMBER | Refused |
| Requirement | Rule for this endpoint |
|---|---|
| Business role | None — the order is composed by whoever may change the program |
| Resource scope | Program of the school attached to the API key |
| Resource state | An archived program refuses every write, and answers 403 |
| Parameter | Type | Required | Description |
|---|---|---|---|
programId | UUID | yes | Program visible from the key's school |
| Header | Required | Description |
|---|---|---|
x-api-key | yes | API key created for this school |
Idempotency-Key | yes | Stable key for this ordering |
X-Correlation-Id | no | Caller correlation id, returned or generated |
| Field | Type | Required | Nullable | Description |
|---|---|---|---|---|
orderedCourseIds | array of UUID | yes | no | 1 to 500 ids, no duplicates, exactly the courses of this program |
{
"orderedCourseIds": [
"9f2c0a1e-0000-4000-8000-000000000000",
"9f2c0a1e-0000-4000-8000-000000000001"
]
}curl -X POST "$COHORTE_API_BASE_URL/api/v1/programs/$PROGRAM_ID/courses/reorder" \
-H "x-api-key: $COHORTE_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H 'Content-Type: application/json' \
-d '{"orderedCourseIds":["'"$FIRST"'","'"$SECOND"'"]}'200 OK — the courses, in their new order.400 Bad Request — missing Idempotency-Key, invalid JSON, duplicates, an empty list, more than 500 ids, or a set that is not exactly the courses of the program.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 — the program is unknown or belongs to another school.{
"success": true,
"data": [
{
"id": "3b8e2d41-7a6c-4f1e-8b25-9c0d1e2f3a4b",
"programId": "9f2c0a1e-4b7d-4c1a-9e3f-2a6b8c0d1e2f",
"name": "Week 1 — Your first agent",
"slug": "week-1-your-first-agent",
"image": "https://files.example.com/covers/week-1.png",
"position": 1,
"status": "active",
With Idempotency-Key, retries of the identical target and payload do not write another mutation, audit or event. A different intention under that key returns 409. Results describe the currently authorized resource state.