{
  "id": "authz-9",
  "title": "KBAC: List the Active Authorization Policies of a Project with GET /access/v1/policies",
  "description": "Read the active KBAC policies of the calling application agent's project at runtime. GET /access/v1/policies returns each policy exactly as stored, inlined as a JSON object, together with its tags; the optional subject_type query parameter narrows the list to the policies written for one subject type. Requires the ReadAuthZConfigs API permission on the agent.",
  "category": "KBAC",
  "tags": [
    "KBAC Policy",
    "authZEN",
    "Policy Listing",
    "ReadAuthZConfigs",
    "API Permissions",
    "Policy Tags"
  ],
  "api": "KBAC",
  "language": "Python",
  "lastUpdated": "2026-09-17",
  "openApiEndpoints": [
    "/configs/v1/authorization-policies",
    "/configs/v1/application-agents",
    "/access/v1/policies"
  ],
  "relatedGuides": [
    "/guides/guide-authzen",
    "/guides/guide-dynamic-authz",
    "/guides/guide-environment"
  ],
  "commonErrors": [
    {
      "code": "401",
      "message": "insufficient API access level for appAgent",
      "solution": "The agent lacks the ReadAuthZConfigs API permission. Authorization alone does not grant policy reads. Add ReadAuthZConfigs to the agent's api_permissions via the Config API or the Hub, then retry with the same credential."
    },
    {
      "code": "422",
      "message": "Unprocessable Entity",
      "solution": "subject_type must be a valid node type: 2-64 characters, a node label such as Person or _Application. Check the errors array in the response for the offending field."
    },
    {
      "code": "200",
      "message": "results is empty unexpectedly",
      "solution": "Only ACTIVE KBAC policies of the calling agent's project are listed. Check the policy status, that the credential belongs to the right project, that subject_type matches the policy's subject.type exactly (case-sensitive), and remember that ContX IQ (1.0-ciq, 2.0-ciq) policies are never included."
    }
  ],
  "summary": "This example demonstrates the policy listing endpoint of the AuthZEN REST API.\n\nEndpoint: GET /access/v1/policies\nHeader: X-IK-ClientKey with an AppAgent credential whose agent holds the ReadAuthZConfigs API permission. No user token is involved.\n\nQuery parameter:\n- subject_type (optional): keep only the policies whose subject.type equals this node type (2-64 characters, a valid node label). Omitted: every policy is returned. A subject type no policy uses is not an error - the result list is simply empty.\n\nResponse:\n- results[]: one entry per policy.\n- results[].policy: the policy definition as it was stored - the policy string sent to POST /configs/v1/authorization-policies, parsed into a JSON object. meta, subject, actions, resource, and condition (with an optional filter) appear exactly as authored.\n- results[].tags: the policy's tags, the values matched by context.policy_tags on evaluation. Always an array, [] when the policy has none.\n\nWhat is listed:\n- KBAC policies (2.0-kbac and 3.0-kbac) with status ACTIVE - the same set the decision endpoints evaluate. Inactive policies are not returned.\n- Only the project of the calling agent. Policy IDs, names, and timestamps are not part of the response; use the Config API for management.\n- ContX IQ policies (1.0-ciq and 2.0-ciq) are not included.\n\nPermissions:\n- ReadAuthZConfigs gates this endpoint and nothing else. It is separate from Authorization: an agent with Authorization alone gets 401 \"insufficient API access level for appAgent\" here, and an agent with ReadAuthZConfigs alone can read the rules but not evaluate them.\n- ReadAuthZConfigs replaces the retired IKGRead value in the api_permissions list. It is not granted to existing agents automatically - add it explicitly. A request that still sends IKGRead is accepted and the value is silently dropped.",
  "usecase": "Scenario: An admin console renders \"which rules apply to people right now?\" and a client picks policy_tags for its evaluations from the tags that actually exist, without shipping Service Account credentials to either of them.\n\nPolicies in the project:\n- Person CAN_DRIVE a Car when a DRIVES relationship exists (no tags).\n- Person CAN_RIDE a Bus when they hold a Ticket FOR it (no tags).\n- _Application CAN_READ any Car (tag \"fleet\").\n\nThree calls:\n1. GET /access/v1/policies -> all three policies, each with its inlined definition and tags.\n2. GET /access/v1/policies?subject_type=Person -> the two Person policies.\n3. GET /access/v1/policies?subject_type=Robot -> {\"results\": []}.\n\nAn agent that holds only the Authorization permission is refused with 401 on every one of them.",
  "requirements": "Prerequisites:\n- ServiceAccount credentials: For creating the policies and the application agent.\n- AppAgent credentials: For calling /access/v1/policies (X-IK-ClientKey). The agent must hold ReadAuthZConfigs.\n- At least one ACTIVE KBAC policy in the project.\n\nRequired API access:\n- POST /configs/v1/authorization-policies\n- POST /configs/v1/application-agents (or PUT /configs/v1/application-agents/{id} to add the permission to an existing agent)\n- GET /access/v1/policies",
  "steps": "Step 1: Create the Policies\n- Authentication: ServiceAccount credential.\n- Action: POST three KBAC policies - CAN_DRIVE and CAN_RIDE for Person, CAN_READ for _Application with the tag \"fleet\".\n- Result: Three ACTIVE policies in the project.\n\nStep 2: Grant ReadAuthZConfigs to the Agent\n- Authentication: ServiceAccount credential.\n- Action: Create the application agent with ReadAuthZConfigs in api_permissions (or PUT the permission onto an existing agent), then generate its credential.\n- Result: An AppAgent credential allowed to list policies.\n\nStep 3: List Every Active Policy\n- Authentication: AppAgent credential (X-IK-ClientKey).\n- Action: GET /access/v1/policies.\n- Result: results[] with three entries; each policy is a JSON object, each tags an array.\n\nStep 4: Filter by Subject Type\n- Action: GET /access/v1/policies?subject_type=Person.\n- Result: Only the two Person policies.\n\nStep 5: Filter by an Unused Subject Type\n- Action: GET /access/v1/policies?subject_type=Robot.\n- Result: 200 with an empty results array.",
  "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": "CAN_DRIVE policy for Person subjects (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. The policy field is the stringified policy; the listing endpoint later returns it parsed back into an object.",
      "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 for Person subjects (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)-[:HAS]->(ticket:Ticket)-[:FOR]->(resource)"
        }
      }
    },
    {
      "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": "description of policy",
        "display_name": "policy name",
        "name": "policy-name",
        "policy": "{\"meta\":{\"policy_version\":\"2.0-kbac\"},\"subject\":{\"type\":\"Person\"},\"actions\":[\"CAN_RIDE\"],\"resource\":{\"type\":\"Bus\"},\"condition\":{\"cypher\":\"MATCH (subject)-[:HAS]->(ticket:Ticket)-[:FOR]->(resource)\"}}",
        "status": "ACTIVE",
        "tags": []
      }
    },
    {
      "description": "CAN_READ policy for _Application subjects: any application of the project may read any Car.",
      "filename": "policy_app_read.json",
      "language": "Json",
      "ingest": {
        "meta": {
          "policy_version": "2.0-kbac"
        },
        "subject": {
          "type": "_Application"
        },
        "actions": [
          "CAN_READ"
        ],
        "resource": {
          "type": "Car"
        },
        "condition": {
          "cypher": "MATCH (subject) MATCH (resource:Car)"
        }
      }
    },
    {
      "description": "Request to create the CAN_READ policy, tagged \"fleet\". The tag is what the listing returns under tags and what context.policy_tags selects on evaluation.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/authorization-policies",
      "language": "Json",
      "ingest": {
        "project_id": "your_project_gid",
        "description": "Any application of the project can read every car",
        "display_name": "application can read a car",
        "name": "application-can-read-a-car",
        "policy": "{\"meta\":{\"policy_version\":\"2.0-kbac\"},\"subject\":{\"type\":\"_Application\"},\"actions\":[\"CAN_READ\"],\"resource\":{\"type\":\"Car\"},\"condition\":{\"cypher\":\"MATCH (subject) MATCH (resource:Car)\"}}",
        "status": "ACTIVE",
        "tags": [
          "fleet"
        ]
      }
    },
    {
      "step": "Step 2",
      "description": "Application agent that can both decide (Authorization) and read the rules (ReadAuthZConfigs). To add the permission to an existing agent, PUT the full api_permissions list to /configs/v1/application-agents/{id}.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/application-agents",
      "language": "Json",
      "ingest": {
        "api_permissions": [
          "Authorization",
          "ReadAuthZConfigs"
        ],
        "application_id": "gid-of-application",
        "description": "Makes AuthZEN decisions and can read the project's active policies",
        "display_name": "Policy-aware agent",
        "name": "policy-aware-agent"
      }
    },
    {
      "step": "Step 3",
      "description": "GET with X-IK-ClientKey only. Every ACTIVE KBAC policy of the agent's project comes back as stored, with its tags. Response shown.",
      "filename": "GET https://eu.api.indykite.com/access/v1/policies",
      "language": "Json",
      "ingest": {
        "results": [
          {
            "policy": {
              "meta": {
                "policy_version": "2.0-kbac"
              },
              "subject": {
                "type": "Person"
              },
              "actions": [
                "CAN_DRIVE"
              ],
              "resource": {
                "type": "Car"
              },
              "condition": {
                "cypher": "MATCH (subject:Person)-[:DRIVES]->(resource:Car)"
              }
            },
            "tags": []
          },
          {
            "policy": {
              "meta": {
                "policy_version": "2.0-kbac"
              },
              "subject": {
                "type": "Person"
              },
              "actions": [
                "CAN_RIDE"
              ],
              "resource": {
                "type": "Bus"
              },
              "condition": {
                "cypher": "MATCH (subject)-[:HAS]->(ticket:Ticket)-[:FOR]->(resource)"
              }
            },
            "tags": []
          },
          {
            "policy": {
              "meta": {
                "policy_version": "2.0-kbac"
              },
              "subject": {
                "type": "_Application"
              },
              "actions": [
                "CAN_READ"
              ],
              "resource": {
                "type": "Car"
              },
              "condition": {
                "cypher": "MATCH (subject) MATCH (resource:Car)"
              }
            },
            "tags": [
              "fleet"
            ]
          }
        ]
      }
    },
    {
      "description": "Both calls in Python: the full listing, then the Person-only listing.",
      "filename": "list_policies.py",
      "language": "Python",
      "code": "\nimport http.client\nimport json\nimport urllib.parse\n\nconn = http.client.HTTPSConnection(\"eu.api.indykite.com\")\n\nheaders = {\n    'X-IK-ClientKey': \"\"\n}\n\n# All active KBAC policies of the agent's project\nconn.request(\"GET\", \"/access/v1/policies\", headers=headers)\nres = conn.getresponse()\npolicies = json.loads(res.read())[\"results\"]\n\n# Only the policies written for Person subjects\nquery = urllib.parse.urlencode({\"subject_type\": \"Person\"})\nconn.request(\"GET\", \"/access/v1/policies?\" + query, headers=headers)\nres = conn.getresponse()\nperson_policies = json.loads(res.read())[\"results\"]\n\nfor entry in person_policies:\n    policy = entry[\"policy\"]          # the policy JSON exactly as it was stored\n    print(policy[\"subject\"][\"type\"], policy[\"actions\"], policy[\"resource\"][\"type\"], entry[\"tags\"])\n"
    },
    {
      "step": "Step 4",
      "description": "subject_type=Person keeps only the policies written for Person subjects; the _Application policy is left out. Response shown.",
      "filename": "GET https://eu.api.indykite.com/access/v1/policies?subject_type=Person",
      "language": "Json",
      "ingest": {
        "results": [
          {
            "policy": {
              "meta": {
                "policy_version": "2.0-kbac"
              },
              "subject": {
                "type": "Person"
              },
              "actions": [
                "CAN_DRIVE"
              ],
              "resource": {
                "type": "Car"
              },
              "condition": {
                "cypher": "MATCH (subject:Person)-[:DRIVES]->(resource:Car)"
              }
            },
            "tags": []
          },
          {
            "policy": {
              "meta": {
                "policy_version": "2.0-kbac"
              },
              "subject": {
                "type": "Person"
              },
              "actions": [
                "CAN_RIDE"
              ],
              "resource": {
                "type": "Bus"
              },
              "condition": {
                "cypher": "MATCH (subject)-[:HAS]->(ticket:Ticket)-[:FOR]->(resource)"
              }
            },
            "tags": []
          }
        ]
      }
    },
    {
      "step": "Step 5",
      "description": "A subject type no policy uses matches nothing: status 200 with an empty results array, not an error.",
      "filename": "GET https://eu.api.indykite.com/access/v1/policies?subject_type=Robot",
      "language": "Json",
      "ingest": {
        "results": []
      }
    },
    {
      "description": "The same call from an agent that holds Authorization but not ReadAuthZConfigs.",
      "filename": "Response 401",
      "language": "Json",
      "ingest": {
        "message": "insufficient API access level for appAgent"
      }
    }
  ],
  "links": {
    "html": "/resources/authz-9",
    "markdown": "/resources/authz-9.md",
    "openApi": "https://openapi.indykite.com/"
  }
}