{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/permitio/json-schema/permitio-resource-read-schema.json",
  "title": "ResourceRead",
  "x-generated": "2026-11-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/permitio-openapi.json#/components/schemas/ResourceRead",
  "properties": {
    "key": {
      "type": "string",
      "title": "Key",
      "description": "A URL-friendly name of the resource (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the resource."
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id",
      "description": "Unique id of the resource"
    },
    "organization_id": {
      "type": "string",
      "format": "uuid",
      "title": "Organization Id",
      "description": "Unique id of the organization that the resource belongs to."
    },
    "project_id": {
      "type": "string",
      "format": "uuid",
      "title": "Project Id",
      "description": "Unique id of the project that the resource belongs to."
    },
    "environment_id": {
      "type": "string",
      "format": "uuid",
      "title": "Environment Id",
      "description": "Unique id of the environment that the resource belongs to."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "Date and time when the resource was created (ISO_8601 format)."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At",
      "description": "Date and time when the resource was last updated/modified (ISO_8601 format)."
    },
    "name": {
      "type": "string",
      "title": "Name",
      "description": "The name of the resource"
    },
    "urn": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Urn",
      "description": "The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Description",
      "description": "An optional longer description of what this resource respresents in your system"
    },
    "actions": {
      "additionalProperties": {
        "$ref": "#/$defs/ActionBlockRead"
      },
      "type": "object",
      "title": "Actions",
      "description": "\n        A actions definition block, typically contained within a resource type definition block.\n        The actions represents the ways you can interact with a protected resource.\n        ",
      "default": {}
    },
    "type_attributes": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Type Attributes",
      "description": "optional dictionary of key-value pairs that can be used to store arbitrary metadata about this resource. This metadata can be used to filter resource using query parameters with attr_ prefix"
    },
    "attributes": {
      "additionalProperties": {
        "$ref": "#/$defs/AttributeBlockRead"
      },
      "type": "object",
      "title": "Attributes",
      "description": "Attributes that each resource of this type defines, and can be used in your ABAC policies."
    },
    "roles": {
      "patternProperties": {
        "^[A-Za-z0-9\\-_]+$": {
          "$ref": "#/$defs/ResourceRoleRead"
        }
      },
      "type": "object",
      "title": "Roles",
      "description": "Roles defined on this resource. The key is the role name, and the value contains the role properties such as granted permissions, etc."
    },
    "relations": {
      "additionalProperties": {
        "$ref": "#/$defs/RelationBlockRead"
      },
      "type": "object",
      "title": "Relations",
      "description": "\n        A relations definition block, typically contained within a resource type definition block.\n        The relations represents the ways you can interact with a protected resource.\n        ",
      "default": {}
    },
    "v1compat_path": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "V1Compat Path",
      "hidden_from_schema": true
    },
    "v1compat_type": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "V1Compat Type",
      "hidden_from_schema": true
    },
    "v1compat_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "V1Compat Name",
      "hidden_from_schema": true
    },
    "action_groups": {
      "additionalProperties": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "type": "object",
      "title": "Action Groups",
      "default": {}
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "key",
    "id",
    "organization_id",
    "project_id",
    "environment_id",
    "created_at",
    "updated_at",
    "name"
  ],
  "$defs": {
    "ActionBlockRead": {
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name",
          "description": "a more descriptive name for the action"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description",
          "description": "optional description string explaining what this action represents in your system"
        },
        "attributes": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Attributes"
        },
        "v1compat_path": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "V1Compat Path",
          "hidden_from_schema": true
        },
        "v1compat_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "V1Compat Name",
          "hidden_from_schema": true
        },
        "id": {
          "type": "string",
          "format": "uuid",
          "title": "Id",
          "description": "Unique id of the action"
        },
        "key": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Key",
          "description": "action key"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id"
      ],
      "title": "ActionBlockRead"
    },
    "AttributeBlockRead": {
      "properties": {
        "type": {
          "$ref": "#/$defs/AttributeType",
          "description": "The type of the attribute, we currently support: `bool`, `number` (ints, floats), `time` (a timestamp), `string`, and `json`."
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description",
          "description": "optional description string explaining what data this attribute will store"
        },
        "id": {
          "type": "string",
          "format": "uuid",
          "title": "Id",
          "description": "Unique id of the attribute"
        },
        "key": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Key",
          "description": "action key"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "type",
        "id"
      ],
      "title": "AttributeBlockRead"
    },
    "AttributeType": {
      "type": "string",
      "enum": [
        "bool",
        "number",
        "string",
        "time",
        "array",
        "json",
        "object",
        "object_array"
      ],
      "title": "AttributeType",
      "description": "supported attribute primitives"
    },
    "DerivedRoleBlockRead": {
      "properties": {
        "when": {
          "$ref": "#/$defs/permit_backend__schemas__schema_derived_role_rule__DerivationSettings",
          "description": "the settings of the derived role",
          "default": {
            "no_direct_roles_on_object": false
          }
        },
        "id": {
          "type": "string",
          "format": "uuid",
          "title": "Id",
          "description": "The unique id of the derived_role"
        },
        "users_with_role": {
          "items": {
            "$ref": "#/$defs/DerivedRoleRuleRead"
          },
          "type": "array",
          "title": "Users With Role",
          "description": "the rules of the derived role",
          "default": []
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id"
      ],
      "title": "DerivedRoleBlockRead"
    },
    "DerivedRoleRuleRead": {
      "properties": {
        "role_id": {
          "type": "string",
          "format": "uuid",
          "title": "Role Id",
          "description": "the role id that needs to exist on the related resource (from the relation)"
        },
        "resource_id": {
          "type": "string",
          "format": "uuid",
          "title": "Resource Id",
          "description": "the resource id that needs to exist on the related role (from the relation)"
        },
        "relation_id": {
          "type": "string",
          "format": "uuid",
          "title": "Relation Id",
          "description": "the relation id that needs to exist between the resource and the related resource"
        },
        "role": {
          "type": "string",
          "title": "Role",
          "description": "the role key that needs to exist on the related resource (from the relation)"
        },
        "on_resource": {
          "type": "string",
          "title": "On Resource",
          "description": "the resource key that needs to exist on the related role (from the relation)"
        },
        "linked_by_relation": {
          "type": "string",
          "title": "Linked By Relation",
          "description": "the relation key that needs to exist between the resource and the related resource"
        },
        "when": {
          "$ref": "#/$defs/permit_backend__schemas__schema_derived_role_rule__DerivationSettings",
          "description": "the settings of the derived role rule",
          "default": {
            "no_direct_roles_on_object": false
          }
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "role_id",
        "resource_id",
        "relation_id",
        "role",
        "on_resource",
        "linked_by_relation"
      ],
      "title": "DerivedRoleRuleRead"
    },
    "RelationBlockRead": {
      "properties": {
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description",
          "description": "An optional longer description of what this relation represents in your system"
        },
        "resource_id": {
          "type": "string",
          "format": "uuid",
          "title": "Resource Id",
          "description": "Unique id of the relation"
        },
        "relation_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Relation Name",
          "description": "a more descriptive name for the relation",
          "hidden_from_schema": true
        },
        "resource": {
          "type": "string",
          "title": "Resource",
          "description": "The resource key"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "resource_id",
        "resource"
      ],
      "title": "RelationBlockRead"
    },
    "ResourceRoleRead": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name",
          "description": "The name of the role"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description",
          "description": "optional description string explaining what this role represents, or what permissions are granted to it."
        },
        "permissions": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Permissions",
          "description": "list of action keys and action group keys that define what actions this resource role is permitted to do"
        },
        "attributes": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Attributes",
          "description": "optional dictionary of key-value pairs that can be used to store arbitrary metadata about this role. This metadata can be used to filter role using query parameters with attr_ prefix, currently supports only 'equals' operator"
        },
        "extends": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Extends",
          "description": "list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list.",
          "default": []
        },
        "granted_to": {
          "anyOf": [
            {
              "$ref": "#/$defs/DerivedRoleBlockRead"
            },
            {
              "type": "null"
            }
          ],
          "description": "Derived role that inherit will be applied on this role"
        },
        "key": {
          "type": "string",
          "title": "Key",
          "description": "A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role."
        },
        "id": {
          "type": "string",
          "format": "uuid",
          "title": "Id",
          "description": "Unique id of the role"
        },
        "organization_id": {
          "type": "string",
          "format": "uuid",
          "title": "Organization Id",
          "description": "Unique id of the organization that the role belongs to."
        },
        "project_id": {
          "type": "string",
          "format": "uuid",
          "title": "Project Id",
          "description": "Unique id of the project that the role belongs to."
        },
        "environment_id": {
          "type": "string",
          "format": "uuid",
          "title": "Environment Id",
          "description": "Unique id of the environment that the role belongs to."
        },
        "resource_id": {
          "type": "string",
          "format": "uuid",
          "title": "Resource Id",
          "description": "Unique id of the resource that the role belongs to."
        },
        "resource": {
          "type": "string",
          "title": "Resource",
          "description": "The unique resource key that the role belongs to."
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "title": "Created At",
          "description": "Date and time when the role was created (ISO_8601 format)."
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "title": "Updated At",
          "description": "Date and time when the role was last updated/modified (ISO_8601 format)."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "key",
        "id",
        "organization_id",
        "project_id",
        "environment_id",
        "resource_id",
        "resource",
        "created_at",
        "updated_at"
      ],
      "title": "ResourceRoleRead"
    },
    "permit_backend__schemas__schema_derived_role_rule__DerivationSettings": {
      "properties": {
        "no_direct_roles_on_object": {
          "type": "boolean",
          "title": "No Direct Roles On Object",
          "description": "If true, the derived role or the specific rule will not apply if the resource has any direct role",
          "default": false
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "DerivationSettings",
      "description": "Settings for a derived role or a derived role rule"
    }
  }
}