# Update a module

`PATCH https://api.cademi.com.br/api/v3/products/{product_id}/modules/{module_id}`

Operation ID: `modules.update` · API v3

Updates a module. Only the fields included in the request are changed.

Changing `status` requires the `modules.publish` permission. Setting `target_product_id` moves the module to another product and requires the `modules.update` permission on that product; if the target product is not accessible with the current credentials, the API returns `404 Not Found`. Setting `deleted` to `false` restores a module from the trash.

Replicated modules accept only `status`. Requests that include any other field return the `replica_readonly` error code.

Send the `ETag` from the retrieve operation in the `If-Match` header to avoid overwriting a newer version.

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

## Parameters

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

## Request body

Content type: `application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `deleted` | boolean | no |  |
| `image` | string or null | no |  |
| `name` | string | no |  |
| `parent_id` | string or null | no |  |
| `position` | integer | no |  |
| `settings` | object | no |  |
| `status` | string, one of `published`, `draft` | no |  |
| `target_product_id` | string | no |  |

## Responses

### 200

Returns the updated module.

Body: `data`: Module.

Fields of Module:

| Field | Type | Required | Description |
|---|---|---|---|
| `created_at` | string (date-time) | yes |  |
| `deleted` | boolean | yes |  |
| `id` | string | yes | Public ID, with the mod_ prefix. |
| `image` | string or null | yes |  |
| `kind` | string, one of `group`, `module` | yes |  |
| `lessons_count` | integer | yes |  |
| `name` | string | yes |  |
| `object` | string, one of `module` | yes |  |
| `parent_id` | string or null | yes |  |
| `position` | integer | yes |  |
| `product_id` | string | yes | Public ID, with the prd_ prefix. |
| `revision` | string | yes |  |
| `settings` | object | yes | Module settings. Only type is supported; an empty object when no settings have been defined. |
| `status` | string, one of `published`, `draft` | 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 module or the target product was not found or is not accessible with the current credentials.

Body: Error.

### 412

The module has changed since the supplied revision was retrieved.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

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