Create a role

How to create a role via API

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

Request

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

Arguments

Body Parameter
Type
Required

type

string

Required

attributes.name

string

Required

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.organization

object

Required

Example

The following request creates a new role:

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

Last updated