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
attributes.reference_origin
relationships.organization
relationships.application_memberships
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"
}
}
}
}
}'
On success, the API responds with a 201 Created
status code, returning the created resource object:
{
"data": {
"id": "xYZkjABcde",
"type": "memberships",
"links": {
"self": "https://provisioning.commercelayer.io/api/memberships/xYZkjABcde"
},
"attributes": {
"user_email": "commercelayer@commercelayer.io",
"user_first_name": "John",
"user_last_name": "Doe",
"status": "pending",
"owner": true,
"created_at": "2018-01-01T12:00:00.000Z",
"updated_at": "2018-01-01T12:00:00.000Z",
"reference": "ANY-EXTERNAL-REFEFERNCE",
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
"metadata": {
"foo": "bar"
}
},
"relationships": {
"organization": {
"links": {
"self": "https://provisioning.commercelayer.io/api/memberships/xYZkjABcde/relationships/organization",
"related": "https://provisioning.commercelayer.io/api/memberships/xYZkjABcde/organization"
}
},
"role": {
"links": {
"self": "https://provisioning.commercelayer.io/api/memberships/xYZkjABcde/relationships/role",
"related": "https://provisioning.commercelayer.io/api/memberships/xYZkjABcde/role"
}
},
"application_memberships": {
"links": {
"self": "https://provisioning.commercelayer.io/api/memberships/xYZkjABcde/relationships/application_memberships",
"related": "https://provisioning.commercelayer.io/api/memberships/xYZkjABcde/application_memberships"
}
},
"versions": {
"links": {
"self": "https://provisioning.commercelayer.io/api/memberships/xYZkjABcde/relationships/versions",
"related": "https://provisioning.commercelayer.io/api/memberships/xYZkjABcde/versions"
}
}
}
}
}
Last updated