Skip to main content
The PlanResources API generates a query plan that describes the conditions under which a principal can perform specific actions on a resource kind. This is particularly useful for implementing filtered list views where you need to show only the resources a user has access to.

Endpoint

rpc PlanResources(PlanResourcesRequest) returns (PlanResourcesResponse)

Request Parameters

requestId
string
Optional application-specific ID useful for correlating logs for analysis.Example: "c2db17b8-4f9f-4fb1-acfd-9162a02be42b"
includeMeta
boolean
Opt to receive request processing metadata in the response.
principal
object
required
A person or application attempting to perform the actions on the set of resources.
resource
object
required
The resource kind to generate the query plan for.
action
string
Deprecated: Use actions instead. Action to be applied to each resource in the list.Example: "view"
actions
string[]
List of actions to generate the query plan for. Mutually exclusive with the singular action field. Must contain at least one action and all actions must be unique.Example: ["view", "edit"]
auxData
object
Structured auxiliary data useful for evaluating the request.

Response Fields

requestId
string
Request ID provided in the request.Example: "c2db17b8-4f9f-4fb1-acfd-9162a02be42b"
action
string
Deprecated: The action from the request.
actions
string[]
Actions from the request.Example: ["view", "edit"]
resourceKind
string
Resource kind.Example: "album:object"
policyVersion
string
The policy version.Example: "default"
filter
object
Filter that describes the conditions for accessing resources.
meta
object
Optional metadata about the request evaluation process.
validationErrors
object[]
List of validation errors (if schema validation is enabled).
cerbosCallId
string
Audit log call ID associated with this request.

Example

cat <<EOF | curl --silent "http://localhost:3592/api/plan/resources?pretty" -d @-
{
  "requestId": "test02",
  "includeMeta": true,
  "principal": {
    "id": "alicia",
    "roles": ["user"],
    "attr": {
      "department": "marketing"
    }
  },
  "resource": {
    "kind": "album:object"
  },
  "action": "view"
}
EOF

Use Cases

Filtered List Views

The most common use case is implementing filtered list views where you need to show only the resources a user can access:
{
  "principal": {
    "id": "user123",
    "roles": ["user"]
  },
  "resource": {
    "kind": "document"
  },
  "action": "view"
}
The response can be used with query plan adapters to generate database queries:
  • KIND_ALWAYS_ALLOWED: Return all documents
  • KIND_ALWAYS_DENIED: Return no documents
  • KIND_CONDITIONAL: Use the condition to filter the query (e.g., WHERE owner = 'user123')

Multiple Actions

Generate a query plan for multiple actions at once:
{
  "principal": {
    "id": "user123",
    "roles": ["user"]
  },
  "resource": {
    "kind": "document"
  },
  "actions": ["view", "edit", "delete"]
}
This returns a single filter that applies to all specified actions.

With Known Resource Attributes

If you have some resource attributes known at query time, include them to get more specific query plans:
{
  "principal": {
    "id": "user123",
    "roles": ["user"]
  },
  "resource": {
    "kind": "document",
    "attr": {
      "status": "published"
    }
  },
  "action": "view"
}

Query Plan Adapters

The filter returned by PlanResources can be converted to database-specific queries using query plan adapters: These adapters automatically translate the filter conditions into the appropriate query format for your database.