Create a membership

How to create a membership via API

To create a new membership, send a POST request to the /api/memberships endpoint, passing the resource arguments in the request body.

Request

POST https://provisioning.commercelayer.io/api/memberships

Arguments

Body Parameter
Type
Required

type

string

Required

attributes.user_email

string

Required

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.organization

object

Required

relationships.role

object

Required

relationships.application_memberships

array

Optional

Example

The following request creates a new membership:

curl -g -X POST \
  'https://provisioning.commercelayer.io/api/memberships' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer {{your_access_token}}' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "memberships",
    "attributes": {
      "user_email": "commercelayer@commercelayer.io"
    },
    "relationships": {
      "organization": {
        "data": {
          "type": "organizations",
          "id": "ABCRtyUpBa"
        }
      },
      "role": {
        "data": {
          "type": "roles",
          "id": "BCDRtyUpBa"
        }
      }
    }
  }
}'

Last updated