# Update a membership stage

`PATCH https://api.cademi.com.br/api/v3/automations/diamond/{diamond_id}/memberships/{membership_id}`

Operation ID: `diamonds.memberships.update` · API v3

Moves a lead to a later stage of the Diamond.

Leads only move forward: a target stage at or before the current stage is rejected with the `state_conflict` error code, including a repeat of a transition that already happened. A successful transition sends the communication for the new stage once.

`reason` is required and is included in the `diamond_membership.stage_changed` event.

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

Required permissions: `diamonds.manage_memberships`.

## Parameters

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

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `reason` | string | yes |  |
| `target_stage_id` | string | yes |  |

## Responses

### 200

Returns the membership at its new stage.

Body: `data`: Membership.

Fields of Membership:

| Field | Type | Required | Description |
|---|---|---|---|
| `created_at` | string (date-time) | yes |  |
| `diamond_id` | string | yes | Public ID of the Diamond, with the dmd_ prefix. |
| `enrollment_id` | string or null | yes | Public ID of the enrollment that grants access to the Diamond's internal delivery, with the enr_ prefix. |
| `id` | string | yes | Public ID, with the mbr_ prefix. |
| `last_run` | object or null | yes |  |
| `object` | string, one of `membership` | yes |  |
| `pending` | object | yes |  |
| `progress` | object | yes |  |
| `revision` | string | yes |  |
| `stage_id` | string | yes | Current stage of the lead. |
| `stage_position` | integer | yes |  |
| `updated_at` | string (date-time) | yes |  |
| `user_id` | string | yes | Public ID of the user, with the usr_ prefix. |

### 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 membership was not found in this Diamond or is not accessible with the current credentials.

Body: Error.

### 409

The target stage is not after the current stage, or Diamond automations are not enabled for the current account.

Body: Error.

### 412

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