# KBAC: What can one subject do across many resources? A permission grid with AuthZEN evaluations (boxcar)

> Use the authZEN /access/v1/evaluations endpoint to check, in a single call, whether one subject is allowed across a grid of (resource, action) cells. The response returns one decision per cell, in order; the client keeps the cells whose decision is true.

**Category:** KBAC  
**API:** KBAC  
**Tags:** KBAC Policy, authZEN, Evaluations, Boxcarring, Batch Decision, Cross-Action, Discovery
**Last Updated:** 2026-07-14
**OpenAPI Endpoints:** /configs/v1/authorization-policies, /access/v1/evaluations
**Related Guides:** /guides/guide-dynamic-authz, /guides/guide-authzen

## Summary

This example demonstrates the authZEN /access/v1/evaluations (boxcarring) endpoint to discover what one subject can do across several (resource, action) cells in a single round-trip. Use it for grid checks, and the search endpoints for type-level discovery.

How the evaluations endpoint works:
- Top-level subject / action / resource act as defaults.
- Each entry in the evaluations array can override any of them; missing fields inherit the defaults.
- The response is an evaluations array with one { decision: true|false } per request, in the same order.

How it relates to the search endpoints:
- /search/action - "for THIS subject + THIS resource, which actions are allowed?"
- /search/resource - "for THIS subject + THIS action, which resources are allowed?"
- /search/subject - "for THIS resource + THIS action, which subjects are allowed?"
- /evaluations - "for THIS subject, decide each of these concrete (resource, action) cells at once."

Use /evaluations when you already know the concrete resources to check. For type-level discovery ("which cars can the subject drive?") use /search/resource (see authz-1 and authz-4).

Policy version note: the policies in this example use "policy_version": "2.0-kbac". The same policy JSON is also accepted with "policy_version": "3.0-kbac" (identical schema, raw-Cypher semantics; do not reference $subject_id or external properties). Only 3.0-kbac additionally accepts USE graph.byName() routing and CALL { } subqueries for composite / data-residency IKGs - see resources authz-7 and authz-8.

## Use Case

Scenario: A self-service portal renders a side menu. Each item maps to a concrete (resource, action) cell. Before rendering, the portal asks IndyKite which items are available to the signed-in user in one boxcar call.

Default subject: Karel
Candidate cells:
- (Car kitt, CAN_DRIVE)
- (Bus harmonika, CAN_RIDE)
- (Car kitt, CAN_WASH)

Policies in scope:
- Person can perform CAN_DRIVE on a Car if a DRIVES relationship exists.
- Person can CAN_RIDE a Bus if they hold a Ticket for it (Person -HAS-> Ticket -FOR-> Bus).
- (No CAN_WASH policy defined.)

Karel holds a Ticket (listek) that is FOR the Harmonika bus, but does not drive kitt and no CAN_WASH policy applies. The evaluations response is therefore [false, true, false] - one decision per cell, in order.

Render only the menu item whose decision is true (CAN_RIDE the bus); leave the others hidden or grayed out.

## Requirements

Prerequisites:
- ServiceAccount credentials: For creating the policies.
- AppAgent credentials: For calling /access/v1/evaluations (X-IK-ClientKey).
- Graph data including Person, Car, Bus, and Ticket nodes, with DRIVES relationships and a Person -HAS-> Ticket -FOR-> Bus path.
- At least one policy per (resource, action) cell you want to evaluate.

Required API access:
- POST /configs/v1/authorization-policies (one per action)
- POST /access/v1/evaluations

## Steps

Step 1: Capture Graph Data
- Action: POST Person, Car, Bus, Ticket nodes; DRIVES relationships and the Person -HAS-> Ticket -FOR-> Bus path.
- Result: Karel -HAS-> Ticket(listek) -FOR-> Bus(harmonika); no DRIVES from Karel.

Step 2: Create Per-Action Policies
- Action: POST one policy for CAN_DRIVE on Car, one for CAN_RIDE on Bus. Leave CAN_WASH undefined intentionally.
- Result: Policy IDs returned.

Step 3: Call /access/v1/evaluations
- Authentication: AppAgent credential.
- Action: POST a default subject (Karel) plus an evaluations array of concrete (resource, action) cells.
- Result: An evaluations array with one decision per cell, in order. Keep the cells where decision is true.

## Graph

The graph the example runs on: 9 nodes (4 Person, 2 Car, 1 Bus, 1 Ticket, 1 Laptop) and 8 relationships (DRIVES, HAS, FOR, OWNS). Hover a node for its properties, click it to highlight its neighbourhood.

- Person `alice` (identity): email=alice@email.com, given_name=Alice, last_name=Smith
- Person `knightrider` (identity): email=knightrider@demo.com, name=Michael Knight
- Person `satchmo` (identity): email=satchmo@demo.com, name=Louis Armstrong
- Person `karel` (identity): email=karel@demo.com, name=Karel Plihal
- Car `kitt`: manufacturer=pontiac, model=Firebird
- Car `cadillacv16`: manufacturer=Cadillac, model=V-16
- Bus `harmonika`: manufacturer=Ikarus, model=280
- Ticket `listek`
- Laptop `airbook-xyz`
- `knightrider` -[DRIVES]-> `kitt`
- `satchmo` -[DRIVES]-> `cadillacv16`
- `karel` -[HAS]-> `listek`
- `listek` -[FOR]-> `harmonika`
- `karel` -[OWNS]-> `airbook-xyz`
- `alice` -[OWNS]-> `airbook-xyz`
- `knightrider` -[OWNS]-> `kitt`
- `alice` -[DRIVES]-> `cadillacv16`

## Code Examples

### Step 1

Capture nodes used in this example. Re-use the authZEN dataset.

**POST https://eu.api.indykite.com/capture/v1/nodes/**

```json
{
  "nodes": [
    {
      "external_id": "alice",
      "is_identity": true,
      "type": "Person",
      "properties": [
        {
          "type": "email",
          "value": "alice@email.com"
        },
        {
          "type": "given_name",
          "value": "Alice"
        },
        {
          "type": "last_name",
          "value": "Smith"
        }
      ]
    },
    {
      "external_id": "knightrider",
      "type": "Person",
      "is_identity": true,
      "properties": [
        {
          "type": "email",
          "value": "knightrider@demo.com"
        },
        {
          "type": "name",
          "value": "Michael Knight"
        }
      ]
    },
    {
      "external_id": "satchmo",
      "type": "Person",
      "is_identity": true,
      "properties": [
        {
          "type": "email",
          "value": "satchmo@demo.com"
        },
        {
          "type": "name",
          "value": "Louis Armstrong"
        }
      ]
    },
    {
      "external_id": "karel",
      "type": "Person",
      "is_identity": true,
      "properties": [
        {
          "type": "email",
          "value": "karel@demo.com"
        },
        {
          "type": "name",
          "value": "Karel Plihal"
        }
      ]
    },
    {
      "external_id": "kitt",
      "type": "Car",
      "is_identity": false,
      "properties": [
        {
          "type": "manufacturer",
          "value": "pontiac"
        },
        {
          "type": "model",
          "value": "Firebird"
        }
      ]
    },
    {
      "external_id": "cadillacv16",
      "type": "Car",
      "is_identity": false,
      "properties": [
        {
          "type": "manufacturer",
          "value": "Cadillac"
        },
        {
          "type": "model",
          "value": "V-16"
        }
      ]
    },
    {
      "external_id": "harmonika",
      "type": "Bus",
      "is_identity": false,
      "properties": [
        {
          "type": "manufacturer",
          "value": "Ikarus"
        },
        {
          "type": "model",
          "value": "280"
        }
      ]
    },
    {
      "external_id": "listek",
      "type": "Ticket",
      "is_identity": false
    },
    {
      "external_id": "airbook-xyz",
      "type": "Laptop",
      "is_identity": false
    }
  ]
}
```


Capture DRIVES relationships plus the Person -HAS-> Ticket -FOR-> Bus path (karel HAS listek, listek FOR harmonika).

**POST https://eu.api.indykite.com/capture/v1/relationships/**

```json
{
  "relationships": [
    {
      "source": {
        "external_id": "knightrider",
        "type": "Person"
      },
      "target": {
        "external_id": "kitt",
        "type": "Car"
      },
      "type": "DRIVES"
    },
    {
      "source": {
        "external_id": "satchmo",
        "type": "Person"
      },
      "target": {
        "external_id": "cadillacv16",
        "type": "Car"
      },
      "type": "DRIVES"
    },
    {
      "source": {
        "external_id": "karel",
        "type": "Person"
      },
      "target": {
        "external_id": "listek",
        "type": "Ticket"
      },
      "type": "HAS"
    },
    {
      "source": {
        "external_id": "listek",
        "type": "Ticket"
      },
      "target": {
        "external_id": "harmonika",
        "type": "Bus"
      },
      "type": "FOR"
    },
    {
      "source": {
        "external_id": "karel",
        "type": "Person"
      },
      "target": {
        "external_id": "airbook-xyz",
        "type": "Laptop"
      },
      "type": "OWNS"
    },
    {
      "source": {
        "external_id": "alice",
        "type": "Person"
      },
      "target": {
        "external_id": "airbook-xyz",
        "type": "Laptop"
      },
      "type": "OWNS"
    },
    {
      "source": {
        "external_id": "knightrider",
        "type": "Person"
      },
      "target": {
        "external_id": "kitt",
        "type": "Car"
      },
      "type": "OWNS"
    },
    {
      "source": {
        "external_id": "alice",
        "type": "Person"
      },
      "target": {
        "external_id": "cadillacv16",
        "type": "Car"
      },
      "type": "DRIVES"
    }
  ]
}
```

### Step 2

CAN_DRIVE policy (Person -[DRIVES]-> Car).

**policy_drive.json**

```json
{
  "meta": {
    "policy_version": "2.0-kbac"
  },
  "subject": {
    "type": "Person"
  },
  "actions": [
    "CAN_DRIVE"
  ],
  "resource": {
    "type": "Car"
  },
  "condition": {
    "cypher": "MATCH (subject:Person)-[:DRIVES]->(resource:Car)"
  }
}
```


Request to create the CAN_DRIVE policy.

**POST https://eu.api.indykite.com/configs/v1/authorization-policies**

```json
{
  "project_id": "your_project_gid",
  "description": "description of policy",
  "display_name": "policy name",
  "name": "policy-name",
  "policy": "{\"meta\":{\"policy_version\":\"2.0-kbac\"},\"subject\":{\"type\":\"Person\"},\"actions\":[\"CAN_DRIVE\"],\"resource\":{\"type\":\"Car\"},\"condition\":{\"cypher\":\"MATCH (subject:Person)-[:DRIVES]->(resource:Car)\"}}",
  "status": "ACTIVE",
  "tags": []
}
```


CAN_RIDE policy (Person -HAS-> Ticket -FOR-> Bus).

**policy_ride.json**

```json
{
  "meta": {
    "policy_version": "2.0-kbac"
  },
  "subject": {
    "type": "Person"
  },
  "actions": [
    "CAN_RIDE"
  ],
  "resource": {
    "type": "Bus"
  },
  "condition": {
    "cypher": "MATCH (subject:Person)-[:HAS]->(ticket:Ticket)-[:FOR]->(resource:Bus)"
  }
}
```


Request to create the CAN_RIDE policy.

**POST https://eu.api.indykite.com/configs/v1/authorization-policies**

```json
{
  "project_id": "your_project_gid",
  "description": "Authorize CAN_RIDE on Bus when the subject holds a Ticket for it (Person -HAS-> Ticket -FOR-> Bus).",
  "display_name": "policy - person can ride a bus",
  "name": "policy-person-can-ride-a-bus",
  "policy": "{\"meta\":{\"policy_version\":\"2.0-kbac\"},\"subject\":{\"type\":\"Person\"},\"actions\":[\"CAN_RIDE\"],\"resource\":{\"type\":\"Bus\"},\"condition\":{\"cypher\":\"MATCH (subject:Person)-[:HAS]->(ticket:Ticket)-[:FOR]->(resource:Bus)\"}}",
  "status": "ACTIVE",
  "tags": []
}
```

### Step 3

Boxcar evaluations: a default subject (Karel) plus three concrete (resource, action) cells to decide at once.

**POST https://eu.api.indykite.com/access/v1/evaluations**

```json
{
  "subject": {
    "type": "Person",
    "id": "karel"
  },
  "evaluations": [
    {
      "resource": {
        "type": "Car",
        "id": "kitt"
      },
      "action": {
        "name": "CAN_DRIVE"
      }
    },
    {
      "resource": {
        "type": "Bus",
        "id": "harmonika"
      },
      "action": {
        "name": "CAN_RIDE"
      }
    },
    {
      "resource": {
        "type": "Car",
        "id": "kitt"
      },
      "action": {
        "name": "CAN_WASH"
      }
    }
  ]
}
```


Response - one decision per cell, in request order: [CAN_DRIVE kitt = false, CAN_RIDE harmonika = true, CAN_WASH kitt = false].

**Response 200**

```json
{
  "evaluations": [
    {
      "decision": false
    },
    {
      "decision": true
    },
    {
      "decision": false
    }
  ]
}
```


Same call in Python.

**evaluations.py**

```python

import http.client
import json

conn = http.client.HTTPSConnection("eu.api.indykite.com")

payload = json.dumps({
  "subject": {"type": "Person", "id": "karel"},
  "evaluations": [
    {"resource": {"type": "Car", "id": "kitt"}, "action": {"name": "CAN_DRIVE"}},
    {"resource": {"type": "Bus", "id": "harmonika"}, "action": {"name": "CAN_RIDE"}},
    {"resource": {"type": "Car", "id": "kitt"}, "action": {"name": "CAN_WASH"}}
  ]
})

headers = {
  'Content-Type': "application/json",
  'X-IK-ClientKey': ""
}

conn.request("POST", "/access/v1/evaluations", payload, headers)

res = conn.getresponse()
data = res.read()

```

## Common Errors

### 400: evaluations must be a non-empty array

**Solution:** Send at least one entry in evaluations. Each entry resolves resource and action from the top-level defaults unless it overrides them.

### 200: every decision is false unexpectedly

**Solution:** Confirm a policy exists for each (resource, action) cell and the subject has the required graph relationship (e.g. the Ticket -FOR-> Bus path for CAN_RIDE). Decisions are returned in the same order as the request.

---

Source: https://developer.indykite.com/resources/authz-5