Create a Role

A Role is a collection of permissions which can be granted to an entity accessing the system.

NOTE: This endpoint currently only accepts permissions indicated in the example code for profile self administration which is the most common use case for Client Tokens. When the functionality is expanded we will provide detailed documentation for the formatting and validity of permission statements.

Accepts a RoleRequest object.

Returns a RoleResponse object.

Example (Ruby)

require 'uri'
require 'net/http'

url = URI("https://api.opentransact.com/v1/roles")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["authorization"] = "Bearer #{API_KEY}"
request["content-type"] = 'application/vnd.api+json'
request.body = {
	"data":{
		"type": "roles",
		"attributes": {
			"name": "ProfileSelfAdmin",
      "permissions": [{
        "Resource": "profiles:self",
				"Action": [ "*:*" ]
      }],
			"metadata": {}
		},
		"relationships": {
			"owner": {
				"data": {
					"type": "applications",
					"id": $APPLICATION_ID
				}
				
			}
		}
	}
}.to_json

response = http.request(request)
puts response.read_body

Example (cURL)

curl --request POST \
  --url https://api.opentransact.com/v1/roles \
  --header 'authorization: Bearer $API_KEY' \
  --header 'content-type: application/vnd.api+json' \
  --data '{
	"data":{
		"type": "roles",
		"attributes": {
			"name": "ProfileSelfAdmin",
      "permissions": [{
        "Resource": "profiles:self",
				"Action": [ "*:*" ]
      }],
			"metadata": {}
		},
		"relationships": {
			"owner": {
				"data": {
					"type": "applications",
					"id": $APPLICATION_ID
				}
				
			}
		}
	}
}'