Create a permission

How to create a permission via API

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

Request

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

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.can_create

boolean

Required

attributes.can_read

boolean

Required

attributes.can_update

boolean

Required

attributes.can_destroy

boolean

Required

attributes.subject

string

Required

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.role

object

Required

Example

The following request creates a new permission:

curl -g -X POST \
  'https://provisioning.commercelayer.io/api/permissions' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer {{your_access_token}}' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "permissions",
    "attributes": {
      "can_create": false,
      "can_read": false,
      "can_update": false,
      "can_destroy": false,
      "subject": ""
    },
    "relationships": {
      "role": {
        "data": {
          "type": "roles",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'

Last updated