Roles

Roles are grants of permissions within OpenTransact which can be attached to specific users, sessions, API keys, or applications in order to manage their access to resources and processes within OpenTransact.

Data Types

RoleResponse

KeyValue
typeroles
idUUID
Attributes
nameString
permissionsArray of Permission objects
metadataMetadata
created-atTimestamp
updated-atTimestamp
Relationships
ownerApplicationRelationship
subjectProfileRelationship

RoleResponse Example

{
  "data": {
    "id": "4c72784e-fb2a-4858-8067-95b6e36d54c0",
    "type": "roles",
    "attributes": {
      "name": "ProfileSelfAdmin",
      "permissions": [{
        "Resource": "profiles:self",
        "Action": [ "*:*" ]
      }],
      "metadata": {},
      "created-at": "2024-05-01T12:00:00Z",
      "updated-at": "2024-05-01T12:00:00Z"
    },
    "relationships": {
      "owner": {
        "data": {
          "type": "applications",
          "id": "4c72784e-fb2a-4858-8067-95b6e36d54c0"
        }
      }
    }
  }
}

RoleRequest

KeyValue
typeroles
Attributes
nameString
permissionsArray of Permission objects
metadataMetadata
Relationships
subjectProfileRelationship

RoleRequest Example

{
  "data": {
    "type": "roles",
    "attributes": {
      "name": "ProfileSelfAdmin",
      "permissions": [{
        "Resource": "profiles:self",
        "Action": [ "*:*" ]
      }],
      "metadata": {}
    },
    "relationships": {
      "subject": {
        "data": {
          "type": "profiles",
          "id": "4c72784e-fb2a-4858-8067-95b6e36d54c0"
        }
      }
    } 
  }
}

POST/v1/roles

Create a Role

This endpoint creates a new Role in OpenTransact.

This endpoint accepts a RoleRequest object and returns a RoleResponse object.

Request

POST
/v1/roles
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
            }
            
          }
        }
      }
    }'

Response

{
  "data": {
    "id": "4c72784e-fb2a-4858-8067-95b6e36d54c0",
    "type": "roles",
    "attributes": {
      "name": "ProfileSelfAdmin",
      "permissions": [{
        "Resource": "profiles:self",
        "Action": [ "*:*" ] 
      }],
      "metadata": {},
      "created-at": "2024-05-01T12:00:00Z",
      "updated-at": "2024-05-01T12:00:00Z"
    },
    "relationships": {
      "owner": {
        "data": {
          "type": "applications",
          "id": "4c72784e-fb2a-4858-8067-95b6e36d54c0"
        }
      }
    }
  }
}

Was this page helpful?