# Update a lesson

`PATCH https://api.cademi.com.br/api/v3/products/{product_id}/lessons/{lesson_id}`

Operation ID: `lessons.update` · API v3

Updates only the fields included in the request.

Changing `status` requires the `lessons.publish` permission. Moving the lesson to another product with `target_product_id` requires the `lessons.update` permission on the destination product; lessons that are connected to a source lesson, or that are the source of connected lessons, cannot be moved. Setting `deleted` to `false` restores a lesson from the trash. The exam set in `exam_id` must belong to the same product.

Replicated lessons accept only `status`; any other field is rejected with `replica_readonly`. Lessons cannot be moved into replicated products.

Send the lesson's current `ETag` in the `If-Match` header to avoid overwriting a newer version.

Required permissions: `lessons.update`, `lessons.publish`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `product_id` | path | string | yes |  |
| `lesson_id` | path | string | yes |  |
| `If-Match` | header | string | no |  |

## Request body

Content type: `application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `deleted` | boolean | no |  |
| `exam_id` | string or null | no | Public ID of the exam displayed by this lesson. Set to null to remove the exam from the lesson. |
| `image` | string or null | no |  |
| `module_id` | string or null | no |  |
| `name` | string | no |  |
| `pinned` | boolean | no |  |
| `position` | integer | no |  |
| `settings` | object | no |  |
| `status` | string, one of `published`, `draft` | no |  |
| `summary` | string or null | no |  |
| `target_product_id` | string | no |  |

## Responses

### 200

Returns the updated lesson.

Body: `data`: Lesson.

Fields of Lesson:

| Field | Type | Required | Description |
|---|---|---|---|
| `connection` | object | yes |  |
| `created_at` | string (date-time) | yes |  |
| `deleted` | boolean | yes |  |
| `exam_id` | string or null | yes | Public ID of the exam displayed in this lesson, or null when the lesson displays no exam. |
| `format` | string, one of `standard`, `quiz`, `live_youtube`, `live_vimeo` | yes |  |
| `id` | string | yes | Public ID, with the les_ prefix. |
| `image` | string or null | yes |  |
| `module_id` | string or null | yes | Public ID of the module that contains the lesson, or null in blog-format products. |
| `name` | string | yes |  |
| `object` | string, one of `lesson` | yes |  |
| `pinned` | boolean | yes |  |
| `position` | integer | yes |  |
| `product_id` | string | yes | Public ID, with the prd_ prefix. |
| `published_at` | string or null (date-time) | no |  |
| `revision` | string | yes |  |
| `settings` | object | yes | Lesson settings. Contains only supported keys; an empty object when no settings have been defined. |
| `status` | string, one of `published`, `draft` | yes |  |
| `summary` | string or null | yes |  |
| `updated_at` | string (date-time) | yes |  |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 404

The lesson or the destination product was not found or is not accessible with the current credentials.

Body: Error.

### 409

The lesson cannot be moved to another product because it is connected to a source lesson or is the source of connected lessons.

Body: Error.

### 412

The lesson has changed since the revision supplied in If-Match.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

Full schema: https://cademi.dev/openapi/v3.json
