# Update an enrollment

`PATCH https://api.cademi.com.br/api/v3/users/{user_id}/enrollments/{enrollment_id}`

Operation ID: `users.enrollments.update` · API v3

Updates the status or scheduled end of an enrollment, or restores a revoked enrollment.

Setting `status` to `revoked` or `deleted` to `false` requires the `enrollments.delete` permission in addition to `enrollments.update`. Only manually granted enrollments can be revoked or restored; enrollments originating from a sale or subscription return `state_conflict`.

`ends_at` must be an ISO 8601 date-time with a time zone offset. Send `null` to remove the scheduled end.

To avoid overwriting a newer version, send the `ETag` returned by the retrieve operation in the `If-Match` header.

Required permissions: `enrollments.update`, `enrollments.delete`, `enrollments.delete`.

## Parameters

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

## Request body

Content type: `application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `deleted` | boolean | no |  |
| `ends_at` | string or null (date-time) | no |  |
| `status` | string, one of `active`, `suspended`, `revoked` | no |  |

## Responses

### 200

Returns the updated enrollment.

Body: `data`: Enrollment.

Fields of Enrollment:

| Field | Type | Required | Description |
|---|---|---|---|
| `created_at` | string (date-time) | no |  |
| `deleted` | boolean | yes |  |
| `delivery_id` | string | yes |  |
| `ends_at` | string or null (date-time) | no |  |
| `id` | string | yes |  |
| `object` | string, one of `enrollment` | yes |  |
| `origin` | object | yes |  |
| `product_ids` | array of string | yes |  |
| `revision` | string | yes |  |
| `status` | string, one of `active`, `suspended`, `revoked` | yes |  |
| `subscription_ends_at` | string or null (date-time) | no |  |
| `updated_at` | string (date-time) | no |  |
| `user_id` | string | 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 enrollment was not found, does not belong to the user, or is not accessible with the current credentials.

Body: Error.

### 409

The enrollment originates from a sale or subscription and cannot be revoked or restored.

Body: Error.

### 412

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