Skip to main content

Resource Type

Resource Types define types of resources in your applications that can have permissions. You can think of them as classes in object-orientated programming.

Resource Types are used to configure the Permissions system to define, which kinds of resources exist in your application, which permissions can be assigned to them and how they are (hierarchical) related to each other. There is no need to define all classes or models from your application as resource types. You should only define resource types for resources that can have permissions.

A Resource Type always has a parent resource type. This is used to structure resource types in a hierarchy. The root-level is always tenant.

Common examples for resource types are:

  • Folder
  • File
  • Product

Manage resource types

The Resource Type API is used to manage resource types for the whole system

  • /config/resource-types

Create a resource type

curl -i --location "https://api.spaceblocks.cloud/public/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/permissions/config/resource-types" \
--request POST \
--header "Content-Type: application/json" \
--header "Authentication: Bearer <YOUR_ACCESS_TOKEN>" \
--header "apiKey: <YOUR_API_KEY>"
--data '{
"name": "<RESOURCE_TYPE_NAME>",
"id": "<RESOURCE_TYPE_SLUG>",
"parent": {
"id": "<PARENT_RESOURCE_TYPE_ID>"
}
}'