# Memberships

At the moment of [signup](https://dashboard.commercelayer.io/sign_up), when you create your first [organization](https://docs.commercelayer.io/provisioning/api-reference/organizations), a membership with an `admin` role is automatically generated for the account owner. Admins can then invite one or more users to join the organization by [creating a new membership](https://docs.commercelayer.io/provisioning/api-reference/memberships/create) associated with the user's email address.

New members can also be assigned a [role](https://docs.commercelayer.io/provisioning/api-reference/roles), a [membership profile](https://docs.commercelayer.io/provisioning/api-reference/membership_profiles), and one or more application memberships by associating each of them with the membership. The new member(s) will receive the invitation by email and will be prompted to create an account if they don’t already have one or to sign in to the Dashboard if they do. Memberships are created in a `pending` status, which becomes `active` as soon as the member accepts the invitation. If that doesn't happen, the invitation can be resent by calling [a dedicated endpoint](#resending-an-invitation). If the invited users already exist (i.e. they already have an account), the related memberships will be directly created as `active`.

{% hint style="warning" %}
Members that haven't an `admin` role cannot create membership and are allowed to delete only their own. Admins can delete other users' memberships. Membership creation can also be limited due to your [subscription plan type](https://docs.commercelayer.io/provisioning/organizations#subscription-information).
{% endhint %}

Some basic member information (e.g. the user's email, first and last name) is directly available when [fetching](https://docs.commercelayer.io/provisioning/api-reference/memberships/retrieve) the related membership. The members who are owners of the associated organization will have the `owner` flag set to `true`.

{% hint style="info" %}
The `owner` attribute is **read-only**. To transfer the ownership to another member of the organization you need to [call a dedicated endpoint](https://docs.commercelayer.io/provisioning/organizations#transferring-the-ownership). Owners cannot delete their own membership without transferring it first.
{% endhint %}

## Granting access to the test environment

You can allow selected members to try some Dashboard apps with test data by setting the `test_enabled` attribute to `true` at the membership level. This way members will be able to work in the test environment for the Dashboard applications to which they have been granted access in test mode via application membership (a *live/test* toggle will be shown on the Dashboard).

{% hint style="info" %}
The `test_enabled` attribute can also be set at the [membership profile](https://docs.commercelayer.io/provisioning/membership_profiles#granting-access-to-the-test-environment) level. In case of conflicts, the settings of the membership profile have precedence over the ones of the single memberships.
{% endhint %}

{% hint style="warning" %}
At the moment this feature isn't available for [custom apps](https://docs.commercelayer.io/provisioning/api_credentials#creating-a-custom-dashboard-app) or [webapps](https://docs.commercelayer.io/provisioning/api_credentials#webapp).
{% endhint %}

## Resending an invitation

To resend an invitation to the user email associated with a (still) pending membership, send a `POST` request to the `/api/memberships/:id/resend` endpoint, where `:id` is the ID of the membership in question, with an empty body payload.

### Example

{% tabs %}
{% tab title="Request" %}
The following request resends an invitation for the membership identified by the "xYZkjABcde" ID:

```sh
curl -g -X POST \
  'https://provisioning.commercelayer.io/api/memberships/xYZkjABcde/resend' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer {{your_access_token}}' \
  -H 'Content-Type: application/vnd.api+json' \
  -d ''
```

{% endtab %}

{% tab title="Response" %}
On success, the API responds with a `202 Accepted` status code.
{% endtab %}
{% endtabs %}
