# Update a product

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

Operation ID: `products.update` · API v3

Updates a product. Only the fields included in the request are changed. Setting `deleted` to `false` restores the product from the trash.

Changing `status` also requires the `products.publish` permission. Changing `showcase_id` or `position` also requires the `showcases.update` permission on the target showcase.

Replicated products accept only `status`; any other field returns the `replica_readonly` error code.

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

Required permissions: `products.update`, `products.publish`, `showcases.update`, `showcases.update`.

## Parameters

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

## Request body

Content type: `application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `definitions` | object | no |  |
| `deleted` | boolean | no |  |
| `display` | object | no |  |
| `external_id` | string or null | no |  |
| `image` | string or null | no |  |
| `name` | string | no |  |
| `position` | integer | no |  |
| `showcase_id` | string | no |  |
| `status` | string, one of `published`, `draft`, `unlisted`, `hidden` | no |  |

## Responses

### 200

Returns the updated product.

Body: `data`: Product.

Fields of Product:

| Field | Type | Required | Description |
|---|---|---|---|
| `created_at` | string (date-time) | yes |  |
| `definitions` | object | yes | Product definitions. Only aliasproductid is supported; an empty object unless the product uses the alias format. |
| `deleted` | boolean | yes |  |
| `display` | object | yes | Display options. Only hidemodulebar and show_progress are supported; an empty object when no options have been defined. |
| `external_id` | string or null | no |  |
| `format` | string, one of `course`, `flix`, `blog`, `link`, `alias` | yes |  |
| `id` | string | yes | Public ID, with the prd_ prefix. |
| `image` | string or null | yes |  |
| `lessons_count` | integer | yes |  |
| `modules_count` | integer | yes |  |
| `name` | string | yes |  |
| `object` | string, one of `product` | yes |  |
| `offer` | object | no | Offer details of the product. Included only when the credentials have the products.read_offer permission. |
| `position` | integer | yes |  |
| `revision` | string | yes |  |
| `showcase_id` | string | yes | Public ID, with the shw_ prefix. |
| `status` | string, one of `published`, `draft`, `unlisted`, `hidden` | 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 product, or a resource referenced in the request, was not found or is not accessible with the current credentials.

Body: Error.

### 409

Another product in the account already uses this external_id.

Body: Error.

### 412

The product 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
