# Create a membership

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

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

Adds a user to the Diamond as a lead, starting at the `lead` stage. A new membership also grants the user access to the Diamond's internal delivery and schedules the communication for the `lead` stage.

If the user is already a member of this Diamond, the existing membership is returned and no communication is sent again. A user can belong to only one Diamond at a time.

In addition to `diamonds.manage_memberships`, this operation requires the `enrollments.create` permission.

Required permissions: `diamonds.manage_memberships`, `enrollments.create`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `diamond_id` | path | string | yes |  |
| `Idempotency-Key` | header | string | yes |  |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `user_id` | string | yes |  |

## Responses

### 200

The user is already a member of this Diamond. Returns the existing membership.

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. |

### 201

Returns the newly created membership.

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

Body: Error.

### 409

The user already belongs to another Diamond (stateconflict with the alreadyin_diamond reason), or Diamond automations are not enabled for the current account.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

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