{
  "id": "authz-5",
  "title": "KBAC: What can one subject do across many resources? A permission grid with AuthZEN evaluations (boxcar)",
  "description": "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",
  "tags": [
    "KBAC Policy",
    "authZEN",
    "Evaluations",
    "Boxcarring",
    "Batch Decision",
    "Cross-Action",
    "Discovery"
  ],
  "api": "KBAC",
  "language": "Json",
  "lastUpdated": "2026-07-14",
  "openApiEndpoints": [
    "/configs/v1/authorization-policies",
    "/access/v1/evaluations"
  ],
  "relatedGuides": [
    "/guides/guide-dynamic-authz",
    "/guides/guide-authzen"
  ],
  "commonErrors": [
    {
      "code": "400",
      "message": "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."
    },
    {
      "code": "200",
      "message": "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."
    }
  ],
  "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.\n\nHow the evaluations endpoint works:\n- Top-level subject / action / resource act as defaults.\n- Each entry in the evaluations array can override any of them; missing fields inherit the defaults.\n- The response is an evaluations array with one { decision: true|false } per request, in the same order.\n\nHow it relates to the search endpoints:\n- /search/action - \"for THIS subject + THIS resource, which actions are allowed?\"\n- /search/resource - \"for THIS subject + THIS action, which resources are allowed?\"\n- /search/subject - \"for THIS resource + THIS action, which subjects are allowed?\"\n- /evaluations - \"for THIS subject, decide each of these concrete (resource, action) cells at once.\"\n\nUse /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).\n\nPolicy 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.",
  "usecase": "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.\n\nDefault subject: Karel\nCandidate cells:\n- (Car kitt, CAN_DRIVE)\n- (Bus harmonika, CAN_RIDE)\n- (Car kitt, CAN_WASH)\n\nPolicies in scope:\n- Person can perform CAN_DRIVE on a Car if a DRIVES relationship exists.\n- Person can CAN_RIDE a Bus if they hold a Ticket for it (Person -HAS-> Ticket -FOR-> Bus).\n- (No CAN_WASH policy defined.)\n\nKarel 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.\n\nRender only the menu item whose decision is true (CAN_RIDE the bus); leave the others hidden or grayed out.",
  "requirements": "Prerequisites:\n- ServiceAccount credentials: For creating the policies.\n- AppAgent credentials: For calling /access/v1/evaluations (X-IK-ClientKey).\n- Graph data including Person, Car, Bus, and Ticket nodes, with DRIVES relationships and a Person -HAS-> Ticket -FOR-> Bus path.\n- At least one policy per (resource, action) cell you want to evaluate.\n\nRequired API access:\n- POST /configs/v1/authorization-policies (one per action)\n- POST /access/v1/evaluations",
  "steps": "Step 1: Capture Graph Data\n- Action: POST Person, Car, Bus, Ticket nodes; DRIVES relationships and the Person -HAS-> Ticket -FOR-> Bus path.\n- Result: Karel -HAS-> Ticket(listek) -FOR-> Bus(harmonika); no DRIVES from Karel.\n\nStep 2: Create Per-Action Policies\n- Action: POST one policy for CAN_DRIVE on Car, one for CAN_RIDE on Bus. Leave CAN_WASH undefined intentionally.\n- Result: Policy IDs returned.\n\nStep 3: Call /access/v1/evaluations\n- Authentication: AppAgent credential.\n- Action: POST a default subject (Karel) plus an evaluations array of concrete (resource, action) cells.\n- Result: An evaluations array with one decision per cell, in order. Keep the cells where decision is true.",
  "graph": {
    "caption": "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.",
    "nodes": [
      {
        "external_id": "alice",
        "type": "Person",
        "is_identity": true,
        "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,
        "properties": []
      },
      {
        "external_id": "airbook-xyz",
        "type": "Laptop",
        "is_identity": false,
        "properties": []
      }
    ],
    "relationships": [
      {
        "source": "knightrider",
        "target": "kitt",
        "type": "DRIVES",
        "properties": []
      },
      {
        "source": "satchmo",
        "target": "cadillacv16",
        "type": "DRIVES",
        "properties": []
      },
      {
        "source": "karel",
        "target": "listek",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "listek",
        "target": "harmonika",
        "type": "FOR",
        "properties": []
      },
      {
        "source": "karel",
        "target": "airbook-xyz",
        "type": "OWNS",
        "properties": []
      },
      {
        "source": "alice",
        "target": "airbook-xyz",
        "type": "OWNS",
        "properties": []
      },
      {
        "source": "knightrider",
        "target": "kitt",
        "type": "OWNS",
        "properties": []
      },
      {
        "source": "alice",
        "target": "cadillacv16",
        "type": "DRIVES",
        "properties": []
      }
    ]
  },
  "code": [
    {
      "step": "Step 1",
      "description": "Capture nodes used in this example. Re-use the authZEN dataset.",
      "filename": "POST https://eu.api.indykite.com/capture/v1/nodes/",
      "language": "Json",
      "ingest": {
        "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
          }
        ]
      }
    },
    {
      "description": "Capture DRIVES relationships plus the Person -HAS-> Ticket -FOR-> Bus path (karel HAS listek, listek FOR harmonika).",
      "filename": "POST https://eu.api.indykite.com/capture/v1/relationships/",
      "language": "Json",
      "ingest": {
        "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": "Step 2",
      "description": "CAN_DRIVE policy (Person -[DRIVES]-> Car).",
      "filename": "policy_drive.json",
      "language": "Json",
      "ingest": {
        "meta": {
          "policy_version": "2.0-kbac"
        },
        "subject": {
          "type": "Person"
        },
        "actions": [
          "CAN_DRIVE"
        ],
        "resource": {
          "type": "Car"
        },
        "condition": {
          "cypher": "MATCH (subject:Person)-[:DRIVES]->(resource:Car)"
        }
      }
    },
    {
      "description": "Request to create the CAN_DRIVE policy.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/authorization-policies",
      "language": "Json",
      "ingest": {
        "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": []
      }
    },
    {
      "description": "CAN_RIDE policy (Person -HAS-> Ticket -FOR-> Bus).",
      "filename": "policy_ride.json",
      "language": "Json",
      "ingest": {
        "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)"
        }
      }
    },
    {
      "description": "Request to create the CAN_RIDE policy.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/authorization-policies",
      "language": "Json",
      "ingest": {
        "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": "Step 3",
      "description": "Boxcar evaluations: a default subject (Karel) plus three concrete (resource, action) cells to decide at once.",
      "filename": "POST https://eu.api.indykite.com/access/v1/evaluations",
      "language": "Json",
      "ingest": {
        "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"
            }
          }
        ]
      }
    },
    {
      "description": "Response - one decision per cell, in request order: [CAN_DRIVE kitt = false, CAN_RIDE harmonika = true, CAN_WASH kitt = false].",
      "filename": "Response 200",
      "language": "Json",
      "ingest": {
        "evaluations": [
          {
            "decision": false
          },
          {
            "decision": true
          },
          {
            "decision": false
          }
        ]
      }
    },
    {
      "description": "Same call in Python.",
      "filename": "evaluations.py",
      "language": "Python",
      "code": "\nimport http.client\nimport json\n\nconn = http.client.HTTPSConnection(\"eu.api.indykite.com\")\n\npayload = json.dumps({\n  \"subject\": {\"type\": \"Person\", \"id\": \"karel\"},\n  \"evaluations\": [\n    {\"resource\": {\"type\": \"Car\", \"id\": \"kitt\"}, \"action\": {\"name\": \"CAN_DRIVE\"}},\n    {\"resource\": {\"type\": \"Bus\", \"id\": \"harmonika\"}, \"action\": {\"name\": \"CAN_RIDE\"}},\n    {\"resource\": {\"type\": \"Car\", \"id\": \"kitt\"}, \"action\": {\"name\": \"CAN_WASH\"}}\n  ]\n})\n\nheaders = {\n  'Content-Type': \"application/json\",\n  'X-IK-ClientKey': \"\"\n}\n\nconn.request(\"POST\", \"/access/v1/evaluations\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n"
    }
  ],
  "links": {
    "html": "/resources/authz-5",
    "markdown": "/resources/authz-5.md",
    "openApi": "https://openapi.indykite.com/"
  }
}