{
  "id": "tutorial-music-dataset",
  "title": "Build IndyKite end-to-end with the music dataset",
  "description": "Download the music-dataset Postman collection and follow the chapters to set up an IndyKite environment, ingest a music graph, and wire up KBAC and ContX IQ policies, queries, and executes.",
  "category": "ContX IQ",
  "order": 25,
  "image": "/assets/images/categories/card-sandbox.svg",
  "summary": "Follow the chapters in order to import the music collection, create the IndyKite environment, ingest 16k+ nodes and 31k+ relationships, then author and execute KBAC and ContX IQ policies and queries against the music graph.",
  "body": "<div class=\"notion\" style=\"border:1px solid #d4d4d4; border-radius:8px; padding:1rem 1.25rem; margin:0 0 1.25rem 0; background:#f9fafb;\">\n  <p class=\"notion\" style=\"margin:0 0 .5rem 0;\"><strong>Download the Postman collection - useful whether or not you used the Sandbox:</strong></p>\n  <ul class=\"bulleted-list\" style=\"margin:0 0 .5rem 0;\">\n    <li style=\"list-style-type:disc\"><strong>If you didn't spin up your environment from the Sandbox</strong> - the collection bootstraps everything from scratch over REST: project, application, application agent + credentials, Token Introspect, MCP server, the full music IKG (16k+ nodes, 31k+ relationships), all KBAC policies, and all ContX IQ policies + Knowledge Queries.</li>\n    <li style=\"list-style-type:disc\"><strong>If you did spin it up from the Sandbox</strong> - the collection is still your reference and workbench. Every request documents the exact REST shape of how the environment is wired, and it ships ready-to-run requests to update graph data via Capture, execute Knowledge Queries through ContX IQ, and make AuthZEN evaluations against your live environment.</li>\n  </ul>\n  <p class=\"notion\" style=\"margin:0;\"><a href=\"/assets/downloads/music-dataset.postman_collection.json\" download=\"music-dataset.postman_collection.json\" class=\"fancy-link\">music-dataset.postman_collection.json</a> (Postman Collection format v2.1.0, ~18 MB - includes the inline music dataset).</p>\n  <p class=\"notion\" style=\"margin:.5rem 0 0 0;\">The <strong>Music app</strong> - the collection plus all the data behind it (nodes, relationships, policies, queries, and executes needed to recreate the whole environment) - can be cloned from <a href=\"https://github.com/indykite/developer-hub/tree/master/music\" class=\"fancy-link\" target=\"_blank\">github.com/indykite/developer-hub/music</a> - it's also a runnable Flask web app that can click through this whole tutorial for you (see \"The Music app\" section below). The Person-subject flows are tuned for one end user, <strong>Millicent Contextsworth</strong> - the <code class=\"notion\">ciq exec</code> requests carry her example <code class=\"notion\">input_params</code>. You can retarget them to any other Person by changing those <code class=\"notion\">input_params</code> in the execute requests. You'll mint her user token (via <a href=\"https://toolbelt.indykite.com/\" class=\"fancy-link\">toolbelt.indykite.com</a>) in Chapter 10.</p>\n  <p class=\"notion\" style=\"margin:.5rem 0 0 0;\">Import it into Postman, Bruno, Insomnia, or Newman - any client that parses the Postman Collection v2.1.0 format. The \"Variables\" tab lists every value the requests use; the only ones you must set yourself are <code class=\"notion\">your_sa_token</code>, <code class=\"notion\">your_agent_token</code>, <code class=\"notion\">your_user_token</code>, and <code class=\"notion\">organization_gid</code>. Everything else is auto-captured by the bundled post-response script.</p>\n  <p class=\"notion\" style=\"margin:.5rem 0 0 0;\"><strong>Where to find each:</strong></p>\n  <ul class=\"bulleted-list\" style=\"margin:0;\">\n    <li style=\"list-style-type:disc\"><code class=\"notion\">organization_gid</code> - in the IndyKite Hub under <code class=\"notion\">/settings</code>.</li>\n    <li style=\"list-style-type:disc\"><code class=\"notion\">your_sa_token</code> - in the credentials file you downloaded at Sandbox registration, or in the Hub under <code class=\"notion\">/service-accounts</code>.</li>\n    <li style=\"list-style-type:disc\"><code class=\"notion\">your_agent_token</code> - in the credentials file from Sandbox registration if you reuse that Sandbox env (the token only works for that env); if you create a new env, it's generated when you run the Postman collection / follow this tutorial.</li>\n    <li style=\"list-style-type:disc\"><code class=\"notion\">your_user_token</code> - covered later in this tutorial.</li>\n  </ul>\n</div>\n\n<p class=\"notion\">This tutorial walks through that collection. Every chapter maps to a folder of requests inside it - run the requests in order and the collection variables fill themselves in via the bundled capture script.</p>\n\n<h3 class=\"\">What you will have at the end</h3>\n<ol type=\"1\" class=\"numbered-list\" start=\"1\">\n<li>An IndyKite <strong>Project</strong>, <strong>Application</strong>, <strong>Application Agent</strong>, and credentials provisioned via the Config API.</li>\n<li>A <strong>Token Introspect</strong> configuration that links your external IdP (Auth0) tokens to <code class=\"notion\">Person</code> nodes in the IKG.</li>\n<li>An <strong>MCP Server</strong> configuration so AI agents can call IndyKite over MCP.</li>\n<li>A music <strong>IKG</strong> populated with the 6 node types and 13 relationship types listed below.</li>\n<li><strong>10 KBAC policies</strong> covering venue performance, entry, flash mobs, track-loudness checks, playlist sharing, family access, and DJ rights, plus <strong>10 single AuthZEN evaluations</strong> and a <strong>boxcar batch</strong>.</li>\n<li><strong>24 ContX IQ policies</strong> with <strong>44 Knowledge Queries</strong> (read / write / delete variants) and <strong>44 paired CIQ executes</strong> that exercise every query against the music graph.</li>\n</ol>\n\n<h3 class=\"\">The music dataset at a glance</h3>\n<p class=\"notion\">After Chapter 5 (data ingestion) your IKG holds:</p>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>Node type</strong></td>\n<td class=\"simple-table-header-color\"><strong>Count</strong></td>\n<td class=\"simple-table-header-color\"><strong>Sample external_id</strong></td>\n</tr>\n<tr><td class=\"\">Artist</td><td class=\"\">94</td><td class=\"\"><code class=\"notion\">artist-1</code> (38 Special)</td></tr>\n<tr><td class=\"\">Album</td><td class=\"\">1k+</td><td class=\"\"><code class=\"notion\">album-1</code></td></tr>\n<tr><td class=\"\">Track</td><td class=\"\">14k+</td><td class=\"\"><code class=\"notion\">track-1</code></td></tr>\n<tr><td class=\"\">Playlist</td><td class=\"\">20</td><td class=\"\"><code class=\"notion\">playlist-1</code></td></tr>\n<tr><td class=\"\">Person</td><td class=\"\">86 (12 with <code class=\"notion\">auth0|...</code> external_ids)</td><td class=\"\"><code class=\"notion\">person-1</code> / <code class=\"notion\">auth0|69c3ee8cb9ed562744ff9326</code></td></tr>\n<tr><td class=\"\">Venue</td><td class=\"\">24</td><td class=\"\"><code class=\"notion\">venue-1</code> (Shower-Concert-Hall)</td></tr>\n</tbody>\n</table>\n\n<p class=\"notion\">Relationships: <code class=\"notion\">CREATED</code>, <code class=\"notion\">PART_OF</code>, <code class=\"notion\">RELEASED</code>, <code class=\"notion\">LIKES</code>, <code class=\"notion\">FOLLOWS</code>, <code class=\"notion\">SUBSCRIBED_TO</code>, <code class=\"notion\">MARRIED_TO</code>, <code class=\"notion\">PARENT_OF</code>, <code class=\"notion\">PARTNERS</code>, <code class=\"notion\">CO_PARENTS</code>, <code class=\"notion\">WILL_ATTEND</code>, <code class=\"notion\">APPROVED_FOR</code>, <code class=\"notion\">PLAYED_AT</code>.</p>\n\n<h3 class=\"\">Who this tutorial is for</h3>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\">Developers evaluating IndyKite who want a runnable, self-contained walkthrough that touches every product surface (Capture, KBAC/AuthZEN, ContX IQ, Token Introspect, MCP).</li>\n<li style=\"list-style-type:disc\">Platform engineers preparing a demo environment for stakeholders.</li>\n<li style=\"list-style-type:disc\">AI agents using the collection as a runbook - every chapter names the exact request items and the variables they read/write.</li>\n</ul>\n\n<h3 class=\"\">Prerequisites</h3>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\">An IndyKite Hub account (EU or US). See the <a href=\"/guides/guide-environment\" class=\"fancy-link\">Environment guide</a>.</li>\n<li style=\"list-style-type:disc\">A ServiceAccount credential at the Organization level (provides the <code class=\"notion\">{{your_sa_token}}</code> Bearer used on Config API requests).</li>\n<li style=\"list-style-type:disc\">Postman, Bruno, Insomnia, or Newman - any client that parses the Postman Collection format v2.1.0. Import the JSON file linked at the top of this page.</li>\n<li style=\"list-style-type:disc\">An end-user access token from your IdP (e.g. Auth0) for Chapter 10 - the Person-subject CIQ executes send it as <code class=\"notion\">Authorization: Bearer {{your_user_token}}</code>.</li>\n</ul>\n\n<h3 class=\"\">How to use the collection alongside this tutorial</h3>\n<ol type=\"1\" class=\"numbered-list\" start=\"1\">\n<li><strong>Download &amp; import</strong> the collection (link at the top of this page) into Postman. The collection's \"Variables\" tab shows every variable you might need.</li>\n<li>Set <code class=\"notion\">your_sa_token</code> and <code class=\"notion\">organization_gid</code> manually. Everything else is auto-captured by the collection's post-response script as you run create requests.</li>\n<li>Run requests <strong>in document order</strong>. The capture script writes each created resource's <code class=\"notion\">id</code> into the matching variable (<code class=\"notion\">project_gid</code>, <code class=\"notion\">application_gid</code>, <code class=\"notion\">app_agent_gid</code>, <code class=\"notion\">policy_gid</code>, <code class=\"notion\">query_gid</code>, ...) so the next request can use it.</li>\n<li>The chapters below explain each section. Skip ahead if you only care about one product, but the variable chain only works left-to-right.</li>\n</ol>\n\n<h3 class=\"\">The Music app: a clickable alternative to the collection</h3>\n<p class=\"notion\">If you'd rather click through the setup than fire REST requests one by one, the <strong>Music app</strong> (<a href=\"https://github.com/indykite/developer-hub/tree/master/music\" class=\"fancy-link\" target=\"_blank\">github.com/indykite/developer-hub/music</a>) wraps the entire collection in a small Flask web app. Every request in the collection has a matching form page, and each successful create saves its resulting ID into a local <code class=\"notion\">.env</code> file so the next step can use it - the same variable chain as the Postman capture script, just persisted on disk.</p>\n\n<p class=\"notion\"><strong>Run it locally:</strong></p>\n<ol type=\"1\" class=\"numbered-list\" start=\"1\">\n<li>Clone the repo and <code class=\"notion\">cd music</code>.</li>\n<li>Create a <code class=\"notion\">.env</code> file with the only values you type in yourself: <code class=\"notion\">SA_TOKEN</code> (from the Hub under <code class=\"notion\">/service-accounts</code>), <code class=\"notion\">URL_ENDPOINTS</code> (<code class=\"notion\">https://eu.api.indykite.com</code> or <code class=\"notion\">https://us.api.indykite.com</code>), <code class=\"notion\">ORGANIZATION_ID</code> (Organization &gt; Settings), and optionally <code class=\"notion\">USER_TOKEN</code> (an Auth0 ID token - only needed for the Person-subject CIQ executes and <code class=\"notion\">/chat/</code>). Everything else (<code class=\"notion\">PROJECT_ID</code>, <code class=\"notion\">APP_TOKEN</code>, all the <code class=\"notion\">*_ID</code> keys, ...) is saved automatically as you go.</li>\n<li>Install pipenv, then run <code class=\"notion\">pipenv install</code>, <code class=\"notion\">pipenv shell</code>, and <code class=\"notion\">flask run</code>; open the local URL (e.g. <code class=\"notion\">http://127.0.0.1:5000</code>).</li>\n</ol>\n\n<p class=\"notion\"><strong>Getting Started steps 1-5.</strong> The five cards on the landing page mirror Chapters 2-4 of this tutorial - each needs the values saved by the previous steps and saves its own result to <code class=\"notion\">.env</code>:</p>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>#</strong></td>\n<td class=\"simple-table-header-color\"><strong>Step</strong></td>\n<td class=\"simple-table-header-color\"><strong>Page</strong></td>\n<td class=\"simple-table-header-color\"><strong>Saves to <code class=\"notion\">.env</code></strong></td>\n</tr>\n<tr><td class=\"\">1</td><td class=\"\">Create Project</td><td class=\"\"><code class=\"notion\">/api_project/create</code></td><td class=\"\"><code class=\"notion\">PROJECT_ID</code></td></tr>\n<tr><td class=\"\">2</td><td class=\"\">Create Application</td><td class=\"\"><code class=\"notion\">/api_application/create</code></td><td class=\"\"><code class=\"notion\">APPLICATION_ID</code></td></tr>\n<tr><td class=\"\">3</td><td class=\"\">Create App Agent</td><td class=\"\"><code class=\"notion\">/api_app_agent/create</code></td><td class=\"\"><code class=\"notion\">APP_AGENT_ID</code>, <code class=\"notion\">APP_TOKEN</code></td></tr>\n<tr><td class=\"\">4</td><td class=\"\">Token Introspect</td><td class=\"\"><code class=\"notion\">/api_token_introspect/create</code></td><td class=\"\"><code class=\"notion\">TOKEN_INTROSPECT_ID</code></td></tr>\n<tr><td class=\"\">5</td><td class=\"\">MCP Server</td><td class=\"\"><code class=\"notion\">/api_mcp_server/create</code></td><td class=\"\"><code class=\"notion\">MCP_SERVER_ID</code></td></tr>\n</tbody>\n</table>\n\n<p class=\"notion\"><strong>One-click provisioning.</strong> Once steps 1-5 exist, <strong>Provision Everything</strong> (<code class=\"notion\">/api_provision/run</code>) replays every remaining create button in click order: both captures (nodes and relationships, Chapter 5), the 10 KBAC policies (Chapter 6), then each CIQ policy followed by its Knowledge Queries (Chapters 8-9) - 93 steps, saving the same IDs to <code class=\"notion\">.env</code> as clicking by hand. It's safe to re-run: steps whose ID is already saved are skipped. AuthZEN evaluations and CIQ executes are <em>not</em> included - they are reads, not creations - so Chapters 7 and 10 remain yours to run, either page by page or via the app's <code class=\"notion\">/chat/</code> story mode, which runs every CIQ execute in dependency-safe order (creates before reads, deletes last).</p>\n\n<p class=\"notion\"><strong>Backfill <code class=\"notion\">.env</code> - when the sandbox already exists.</strong> If your music environment was created <em>outside</em> the app - an automated Hub sandbox, this tutorial's Postman collection, or scripts - the app's forms won't know any of the IDs. <strong>Backfill .env</strong> (<code class=\"notion\">/api_provision/backfill</code>) recovers every derived ID by looking the configs up <strong>by name</strong> and saves them to <code class=\"notion\">.env</code>, so the forms work against that existing sandbox. It is read-only: nothing is created or modified on the platform.</p>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\">Needs only <code class=\"notion\">URL_ENDPOINTS</code>, <code class=\"notion\">SA_TOKEN</code>, and <code class=\"notion\">PROJECT_ID</code> in <code class=\"notion\">.env</code>.</li>\n<li style=\"list-style-type:disc\">Recognizes both the app's fixed config names and the console sandbox's random-suffixed names (<code class=\"notion\">&lt;name&gt;-123456-0</code>, <code class=\"notion\">app-123456</code>, ...).</li>\n<li style=\"list-style-type:disc\">Tokens (<code class=\"notion\">APP_TOKEN</code>, <code class=\"notion\">USER_TOKEN</code>) cannot be recovered - credential secrets are only shown at creation - so set those manually.</li>\n<li style=\"list-style-type:disc\">Hub console sandboxes include an MCP server, so <code class=\"notion\">MCP_SERVER_ID</code> is recovered along with the rest. If backfill reports any config as <em>missing</em>, create it afterwards with the matching Getting Started step.</li>\n</ul>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 1 introduces the music graph itself - what each node type means and which relationships connect them - so the policies and queries in later chapters land on a familiar shape.</p>",
  "chapterCount": 10,
  "chapters": [
    {
      "chapter": 1,
      "title": "The music graph: nodes, relationships, and scenarios",
      "description": "Walk through the music dataset's six node types and thirteen relationship types so the rest of the tutorial lands on a familiar shape.",
      "body": "<h2 class=\"\">Chapter 1: The music graph</h2>\n\n<p class=\"notion\">Every policy and query in this tutorial runs against the same Identity Knowledge Graph (IKG). Understanding the graph first makes the rest of the chapters self-evident.</p>\n\n<h3 class=\"\">Why a graph?</h3>\n<p class=\"notion\">From the <a href=\"/guides/guide-graph-database\" class=\"fancy-link\">graph database guide</a>: identity and authorization are inherently relational. \"Can <em>this</em> person play <em>that</em> track at <em>this</em> venue\" is a path query, not a row lookup. The IKG stores entities as nodes and the connections between them as relationships, so KBAC and ContX IQ can reason over those paths directly.</p>\n\n<h3 class=\"\">Node types</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>Type</strong></td>\n<td class=\"simple-table-header-color\"><strong>What it represents</strong></td>\n<td class=\"simple-table-header-color\"><strong>Key properties used by policies / queries</strong></td>\n</tr>\n<tr><td class=\"\"><code class=\"notion\">Person</code></td><td class=\"\">User of the music app. 12 use real <code class=\"notion\">auth0|...</code> external_ids (so a real IdP-issued bearer's <code class=\"notion\">sub</code> claim resolves to a graph node); the other 74 use <code class=\"notion\">person-N</code>. Two auth0 users are seeded with engagement relationships as recommended test subjects: <strong>Cornelius</strong> (<code class=\"notion\">auth0|69c3ee8cb9ed562744ff9326</code>) covers music-engagement queries; <strong>Marmaduke</strong> (<code class=\"notion\">auth0|69c4129b0ba356c7db9f91ab</code>) covers parent-side queries. Full table in Chapter 5.</td><td class=\"\"><code class=\"notion\">firstname</code>, <code class=\"notion\">lastname</code>, <code class=\"notion\">city</code>, <code class=\"notion\">music_mood</code>, <code class=\"notion\">karaoke_confidence</code>, <code class=\"notion\">dance_skill</code>, <code class=\"notion\">profession</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Artist</code></td><td class=\"\">Musician or group.</td><td class=\"\"><code class=\"notion\">name</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Album</code></td><td class=\"\">Released by an Artist; contains Tracks.</td><td class=\"\"><code class=\"notion\">title</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Track</code></td><td class=\"\">Individual song with audio characteristics used in policies (e.g. loudness gates).</td><td class=\"\"><code class=\"notion\">title</code>, <code class=\"notion\">duration</code>, <code class=\"notion\">danceability</code>, <code class=\"notion\">energy</code>, <code class=\"notion\">loudness</code>, <code class=\"notion\">popularity</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Playlist</code></td><td class=\"\">User-created or system playlist. Has venue approvals and subscriber relationships.</td><td class=\"\"><code class=\"notion\">name</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Venue</code></td><td class=\"\">Place where tracks are played. Carries thresholds policies compare against.</td><td class=\"\"><code class=\"notion\">name</code>, <code class=\"notion\">min_confidence</code>, <code class=\"notion\">min_danceability</code>, <code class=\"notion\">max_loudness</code>, <code class=\"notion\">max_energy</code></td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">Relationships</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>Relationship</strong></td>\n<td class=\"simple-table-header-color\"><strong>From → To</strong></td>\n<td class=\"simple-table-header-color\"><strong>Used by</strong></td>\n</tr>\n<tr><td class=\"\"><code class=\"notion\">CREATED</code></td><td class=\"\">Artist → Track, Person → Playlist</td><td class=\"\">Catalog ownership / playlist authorship</td></tr>\n<tr><td class=\"\"><code class=\"notion\">PART_OF</code></td><td class=\"\">Track → Album</td><td class=\"\">Catalog hierarchy</td></tr>\n<tr><td class=\"\"><code class=\"notion\">RELEASED</code></td><td class=\"\">Artist → Album</td><td class=\"\">Catalog ownership</td></tr>\n<tr><td class=\"\"><code class=\"notion\">LIKES</code></td><td class=\"\">Person → Track</td><td class=\"\">Same-taste matching, popular-tracks queries</td></tr>\n<tr><td class=\"\"><code class=\"notion\">FOLLOWS</code></td><td class=\"\">Person → Artist</td><td class=\"\">Same-artist-followers query</td></tr>\n<tr><td class=\"\"><code class=\"notion\">SUBSCRIBED_TO</code></td><td class=\"\">Person → Playlist</td><td class=\"\">Subscription read / share KBAC</td></tr>\n<tr><td class=\"\"><code class=\"notion\">MARRIED_TO</code> / <code class=\"notion\">PARTNERS</code> / <code class=\"notion\">PARENT_OF</code> / <code class=\"notion\">CO_PARENTS</code></td><td class=\"\">Person ↔ Person</td><td class=\"\">Family-playlist KBAC, children-likes CIQ</td></tr>\n<tr><td class=\"\"><code class=\"notion\">WILL_ATTEND</code></td><td class=\"\">Person → Venue</td><td class=\"\">Concert / venue-attendees / DJ KBAC</td></tr>\n<tr><td class=\"\"><code class=\"notion\">APPROVED_FOR</code></td><td class=\"\">Playlist → Venue</td><td class=\"\">Playlist-venue-approval KBAC</td></tr>\n<tr><td class=\"\"><code class=\"notion\">PLAYED_AT</code></td><td class=\"\">Track → Venue</td><td class=\"\">Venue-playable-tracks CIQ, track-loudness KBAC</td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">The scenarios you'll author</h3>\n<p class=\"notion\">Three families of authorization questions are answered in later chapters:</p>\n<ol type=\"1\" class=\"numbered-list\" start=\"1\">\n<li><strong>KBAC / AuthZEN</strong> (Chapters 6 - 7): yes/no decisions like \"can <em>person-52</em> PERFORM at <em>venue-1</em>?\" or \"can <em>track-7431</em> PLAY at <em>venue-4</em>?\"</li>\n<li><strong>ContX IQ - Application as subject</strong> (Chapter 8 onwards): system-level reads/writes like \"list playable tracks for venue X\" run by the <code class=\"notion\">_Application</code> identity.</li>\n<li><strong>ContX IQ - Person as subject</strong> (Chapter 8 onwards): user-scoped reads/writes like \"my profile\", \"my playlists\", \"people with the same taste as me\", scoped by <code class=\"notion\">subject.external_id = $token.sub</code> (i.e. anchored to the bearer token's verified <code class=\"notion\">sub</code> claim - no client-supplied identity).</li>\n</ol>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 2 sets up the IndyKite environment that owns this graph - Project, Application, Application Agent, and credentials.</p>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-1",
        "markdown": "/tutorials/tutorial-music-dataset/1.md"
      }
    },
    {
      "chapter": 2,
      "title": "Set up the IndyKite environment",
      "description": "Create Project, Application, Application Agent, and credentials with the four Config API requests in the music collection.",
      "body": "<h2 class=\"\">Chapter 2: Set up the IndyKite environment</h2>\n\n<p class=\"notion\">From the <a href=\"/guides/guide-environment\" class=\"fancy-link\">Environment guide</a>: before you can use any IndyKite capability you need an <strong>Organization → Project → Application → Application Agent</strong> hierarchy. The collection's first four requests build that chain. Each one is auto-captured into a collection variable consumed by the next.</p>\n\n<h3 class=\"\">Hierarchy refresher</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr><td class=\"simple-table-header-color\"><strong>Level</strong></td><td class=\"simple-table-header-color\"><strong>Why it exists</strong></td></tr>\n<tr><td class=\"\"><strong>Organization</strong></td><td class=\"\">Top-level account, holds Service Accounts and Projects.</td></tr>\n<tr><td class=\"\"><strong>Project</strong></td><td class=\"\">Isolated environment with its own IKG.</td></tr>\n<tr><td class=\"\"><strong>Application</strong></td><td class=\"\">Logical grouping inside a Project. Creates an <code class=\"notion\">_Application</code> node so the application can act as a subject.</td></tr>\n<tr><td class=\"\"><strong>Application Agent</strong></td><td class=\"\">API authentication identity. Its credentials are sent as <code class=\"notion\">X-IK-ClientKey</code>.</td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">Variables you set yourself</h3>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\"><code class=\"notion\">your_sa_token</code> - the ServiceAccount JWT, sent as <code class=\"notion\">Authorization: Bearer ...</code> on every request in this chapter.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">organization_gid</code> - your Organization's <code class=\"notion\">gid:...</code> identifier.</li>\n</ul>\n\n<h3 class=\"\">Run these requests in order</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>#</strong></td>\n<td class=\"simple-table-header-color\"><strong>Request name</strong></td>\n<td class=\"simple-table-header-color\"><strong>Endpoint</strong></td>\n<td class=\"simple-table-header-color\"><strong>Captures into</strong></td>\n</tr>\n<tr><td class=\"\">1</td><td class=\"\"><code class=\"notion\">create project</code></td><td class=\"\"><code class=\"notion\">POST /configs/v1/projects</code></td><td class=\"\"><code class=\"notion\">project_gid</code></td></tr>\n<tr><td class=\"\">2</td><td class=\"\"><code class=\"notion\">create application</code></td><td class=\"\"><code class=\"notion\">POST /configs/v1/applications</code></td><td class=\"\"><code class=\"notion\">application_gid</code></td></tr>\n<tr><td class=\"\">3</td><td class=\"\"><code class=\"notion\">create application agent</code></td><td class=\"\"><code class=\"notion\">POST /configs/v1/application-agents</code></td><td class=\"\"><code class=\"notion\">app_agent_gid</code></td></tr>\n<tr><td class=\"\">4</td><td class=\"\"><code class=\"notion\">create application agent credentials</code></td><td class=\"\"><code class=\"notion\">POST /configs/v1/application-agent-credentials</code></td><td class=\"\">(see below)</td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">Request bodies</h3>\n\n<p class=\"notion\"><strong>1. Create the Project.</strong> Auth: <code class=\"notion\">Authorization: Bearer {{your_sa_token}}</code>.</p>\n<pre class=\"code\"><code class=\"language-JSON\">POST /configs/v1/projects\n{\n  \"organization_id\": \"{{organization_gid}}\",\n  \"name\": \"eu-project\",\n  \"display_name\": \"EU Project\",\n  \"region\": \"europe-west1\",\n  \"ikg_size\": \"2GB\"\n}</code></pre>\n\n<p class=\"notion\"><strong>2. Create the Application</strong> inside that project.</p>\n<pre class=\"code\"><code class=\"language-JSON\">POST /configs/v1/applications\n{\n  \"project_id\": \"{{project_gid}}\",\n  \"name\": \"app-name\",\n  \"display_name\": \"Application name\",\n  \"description\": \"Application description\"\n}</code></pre>\n\n<p class=\"notion\"><strong>3. Create the Application Agent.</strong> The <code class=\"notion\">api_permissions</code> array is what makes this agent able to call Capture, ContX IQ, AuthZEN, etc. Drop any you don't need; a call to an API the agent is not granted fails with <code class=\"notion\">401</code>. The chapters that follow only use <code class=\"notion\">Authorization</code>, <code class=\"notion\">Capture</code>, and <code class=\"notion\">ContXIQ</code>; the payload below grants all six so the same credential also works for the optional examples on the resources pages:</p>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\"><code class=\"notion\">Authorization</code> - the AuthZEN endpoints under <code class=\"notion\">/access/v1/</code>: <code class=\"notion\">evaluation</code>, <code class=\"notion\">evaluations</code>, and the <code class=\"notion\">search/action</code>, <code class=\"notion\">search/resource</code>, <code class=\"notion\">search/subject</code> discovery calls.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">Capture</code> - the Capture API under <code class=\"notion\">/capture/v1/</code>: upsert and delete nodes, relationships, properties, and metadata.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">ContXIQ</code> - <code class=\"notion\">POST /contx-iq/v1/execute</code> to run Knowledge Queries, and <code class=\"notion\">GET /contx-iq/v1/whoami</code> to see which IKG node a user token resolves to.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">EntityMatching</code> - the EntityMatching API under <code class=\"notion\">/entity-matching/v1/</code> for identity resolution pipelines.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">ReadAuthZConfigs</code> - <code class=\"notion\">GET /access/v1/policies</code>, a read-only listing of the project's active KBAC policies as stored, with their tags. Separate from <code class=\"notion\">Authorization</code>: deciding does not imply reading the rules, and vice versa.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">ReadDataSchema</code> - <code class=\"notion\">GET /data-schema/v1/</code>, the observed node, relationship, and property schema of the IKG (handy before writing Cypher).</li>\n</ul>\n<pre class=\"code\"><code class=\"language-JSON\">POST /configs/v1/application-agents\n{\n  \"application_id\": \"{{application_gid}}\",\n  \"name\": \"app-agent-name\",\n  \"display_name\": \"App Agent name\",\n  \"description\": \"App Agent description\",\n  \"api_permissions\": [\n    \"Authorization\",\n    \"Capture\",\n    \"ContXIQ\",\n    \"EntityMatching\",\n    \"ReadAuthZConfigs\",\n    \"ReadDataSchema\"\n  ]\n}</code></pre>\n\n<p class=\"notion\"><strong>4. Generate credentials</strong> for that agent. The response is the credential JSON you'll mine for <code class=\"notion\">your_agent_token</code>.</p>\n<pre class=\"code\"><code class=\"language-JSON\">POST /configs/v1/application-agent-credentials\n{\n  \"application_agent_id\": \"{{app_agent_gid}}\",\n  \"display_name\": \"AppAgent Credentials name\",\n  \"expire_time\": \"2027-04-28T12:34:56Z\"\n}</code></pre>\n\n<h3 class=\"\">A note on credentials (step 4)</h3>\n<p class=\"notion\">From the <a href=\"/guides/guide-credentials\" class=\"fancy-link\">Credentials guide</a>: the response of the credentials endpoint contains a downloadable JSON. Inside that JSON is the value used as <code class=\"notion\">X-IK-ClientKey</code>. The collection's auto-capture script logs a hint when this request fires - you must <strong>copy the X-IK-ClientKey value into <code class=\"notion\">your_agent_token</code> manually</strong>. Save the credentials file securely; it cannot be retrieved again.</p>\n\n<h3 class=\"\">BYODB alternative</h3>\n<p class=\"notion\">The collection also includes <code class=\"notion\">create project BYODB</code> for users who want to bring their own Neo4j database. Set <code class=\"notion\">db_name</code>, <code class=\"notion\">db_password</code>, and <code class=\"notion\">db_host</code> in the Variables tab before running it. Most users should use the managed-IKG <code class=\"notion\">create project</code> path instead.</p>\n\n<h3 class=\"\">Sanity check</h3>\n<p class=\"notion\">After running these four requests, your collection variables tab should show non-empty values for <code class=\"notion\">project_gid</code>, <code class=\"notion\">application_gid</code>, <code class=\"notion\">app_agent_gid</code>, and <code class=\"notion\">your_agent_token</code> (the last one filled in manually from the credential JSON).</p>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 3 wires Token Introspect into your environment so external IdP tokens can be validated against the IKG.</p>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-2",
        "markdown": "/tutorials/tutorial-music-dataset/2.md"
      }
    },
    {
      "chapter": 3,
      "title": "Configure Token Introspect for end-user identity",
      "description": "Link external IdP access tokens (Auth0) to Person nodes in the IKG so user-context CIQ executes resolve to a real graph subject.",
      "body": "<h2 class=\"\">Chapter 3: Configure Token Introspect</h2>\n\n<p class=\"notion\">From the <a href=\"/guides/guide-token-introspect\" class=\"fancy-link\">Token Introspect guide</a>: Token Introspect tells IndyKite how to validate an external access token (issued by your IdP) and which claim should be used to find the matching <code class=\"notion\">Person</code> node. Without it, Person-subject CIQ executes have no way to know which graph node \"the caller\" refers to.</p>\n\n<h3 class=\"\">Why this matters for the music collection</h3>\n<p class=\"notion\">In Chapter 5 you will ingest 12 <code class=\"notion\">Person</code> nodes whose <code class=\"notion\">external_id</code> values are real Auth0 subjects (e.g. <code class=\"notion\">auth0|69c3ee8cb9ed562744ff9326</code>). The Person-subject CIQ executes you'll run in Chapter 10 send those tokens as <code class=\"notion\">Authorization: Bearer {{your_user_token}}</code>. Token Introspect is what makes the platform resolve the bearer token's <code class=\"notion\">sub</code> claim to the matching <code class=\"notion\">Person</code> node.</p>\n\n<h3 class=\"\">Run this request</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>Request</strong></td>\n<td class=\"simple-table-header-color\"><strong>Endpoint</strong></td>\n<td class=\"simple-table-header-color\"><strong>Captures into</strong></td>\n</tr>\n<tr><td class=\"\"><code class=\"notion\">create token introspect</code></td><td class=\"\"><code class=\"notion\">POST /configs/v1/token-introspects</code></td><td class=\"\"><code class=\"notion\">token_introspect_gid</code></td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">Auth: ServiceAccount</h3>\n<p class=\"notion\">Like all <code class=\"notion\">/configs/v1/*</code> requests, this one uses <code class=\"notion\">{{your_sa_token}}</code> as <code class=\"notion\">Authorization: Bearer ...</code>. No agent token here - this is a configuration call.</p>\n\n<h3 class=\"\">Body</h3>\n<pre class=\"code\"><code class=\"language-JSON\">POST /configs/v1/token-introspects\n{\n  \"project_id\": \"{{project_gid}}\",\n  \"name\": \"auth0-person-introspect\",\n  \"display_name\": \"Auth0 Person Token Introspect\",\n  \"description\": \"Introspect Auth0 tokens and upsert Person nodes\",\n  \"jwt_matcher\": {\n    \"issuer\": \"https://1st.eu.auth0.com\",\n    \"audience\": \"N6VibJHjxIpKEvkBKSWU1xLxh6xnca55\"\n  },\n  \"ikg_node_type\": \"Person\",\n  \"claims_mapping\": {\n    \"email\": {\n      \"selector\": \"email\"\n    }\n  },\n  \"perform_upsert\": true\n}</code></pre>\n<p class=\"notion\">Three things to notice:</p>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\"><code class=\"notion\">jwt_matcher</code> declares which <code class=\"notion\">issuer</code> + <code class=\"notion\">audience</code> token to accept. The values shown here point to an Auth0 tenant IndyKite stood up specifically to exercise the platform - a test IdP whose user accounts back the 12 <code class=\"notion\">auth0|...</code> Person nodes you ingest in Chapter 5. Keep them as-is to follow this tutorial against that test IdP, or replace them with your own Auth0 tenant's <code class=\"notion\">issuer</code> and <code class=\"notion\">audience</code> to wire up your own users.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">ikg_node_type: \"Person\"</code> tells the platform that the token's <code class=\"notion\">sub</code> claim resolves to a <code class=\"notion\">Person</code> node. This is the binding our CIQ policies rely on via <code class=\"notion\">subject.external_id = $token.sub</code>.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">perform_upsert: true</code> means a <code class=\"notion\">Person</code> node is auto-created the first time an unknown token sub is seen - useful in development.</li>\n</ul>\n\n<p class=\"notion\">At execute time the Person-subject policies in Chapter 8 enforce <code class=\"notion\">subject.external_id = $token.sub</code>, where <code class=\"notion\">$token.sub</code> resolves to the verified <code class=\"notion\">sub</code> claim of the bearer token. No <code class=\"notion\">subject_external_id</code> input param is sent by the client - the platform reads the claim from the bearer that Token Introspect just validated, and the policy filter pins the cypher subject to the matching <code class=\"notion\">Person</code> node.</p>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 4 adds an MCP Server configuration so AI agents can call IndyKite over the Model Context Protocol.</p>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-3",
        "markdown": "/tutorials/tutorial-music-dataset/3.md"
      }
    },
    {
      "chapter": 4,
      "title": "Configure the MCP Server",
      "description": "Stand up an MCP Server configuration so AI agents can initialize sessions and execute IndyKite tools over HTTP.",
      "body": "<h2 class=\"\">Chapter 4: Configure the MCP Server (optional)</h2>\n\n<p class=\"notion\"><strong>Optional - skip to Chapter 5 if you don't need MCP yet.</strong> This chapter is only required if you want an AI agent to drive IndyKite over MCP. Every later chapter (ingest, KBAC/AuthZEN, ContX IQ) works fine without it - you can come back and add MCP later by running just the requests below.</p>\n\n<p class=\"notion\">From the <a href=\"/guides/guide-mcp\" class=\"fancy-link\">MCP guide</a>: the IndyKite MCP Server exposes IndyKite capabilities (Capture, ContX IQ, AuthZEN, Token Introspect) to <strong>Model Context Protocol</strong> clients. AI agents that speak MCP can initialize a session, list available tools, and execute them - all against your project's IKG.</p>\n\n<h3 class=\"\">Why include this in the tutorial</h3>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\">It's the bridge between the music graph you're about to build and any LLM-driven client (Claude, GPT, custom agents) that wants to query or update it.</li>\n<li style=\"list-style-type:disc\">The configuration call is short and depends only on values you've already captured (<code class=\"notion\">project_gid</code>, <code class=\"notion\">app_agent_gid</code>, <code class=\"notion\">token_introspect_gid</code>).</li>\n</ul>\n\n<h3 class=\"\">Run these requests</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>Request</strong></td>\n<td class=\"simple-table-header-color\"><strong>Endpoint</strong></td>\n<td class=\"simple-table-header-color\"><strong>Purpose</strong></td>\n</tr>\n<tr><td class=\"\"><code class=\"notion\">create mcp server config</code></td><td class=\"\"><code class=\"notion\">POST /configs/v1/mcp-servers</code></td><td class=\"\">Captures <code class=\"notion\">mcp_server_gid</code>.</td></tr>\n<tr><td class=\"\"><code class=\"notion\">read mcp server config</code></td><td class=\"\"><code class=\"notion\">GET /configs/v1/mcp-servers/{{mcp_server_gid}}</code></td><td class=\"\">Optional - inspect the active config.</td></tr>\n<tr><td class=\"\"><code class=\"notion\">delete mcp server config</code></td><td class=\"\"><code class=\"notion\">DELETE /configs/v1/mcp-servers/{{mcp_server_gid}}</code></td><td class=\"\">Optional - tear it down.</td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">Body shape</h3>\n<p class=\"notion\">The body wires the MCP Server to the agent identity that will execute tools (<code class=\"notion\">app_agent_id</code>) and to the Token Introspect config that resolves end-user tokens (<code class=\"notion\">token_introspect_id</code>). Scopes and an enabled flag complete the configuration.</p>\n\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"app_agent_id\": \"{{app_agent_gid}}\",\n  \"token_introspect_id\": \"{{token_introspect_gid}}\",\n  \"project_id\": \"{{project_gid}}\",\n  \"name\": \"mcp-server-test\",\n  \"display_name\": \"MCP Server test\",\n  \"description\": \"MCP Server configuration description\",\n  \"enabled\": true,\n  \"scopes_supported\": [\n    \"email\"\n  ]\n}</code></pre>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 5 ingests the music dataset itself - 16 thousand+ nodes and 31 thousand+ relationships - via two Capture API calls.</p>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-4",
        "markdown": "/tutorials/tutorial-music-dataset/4.md"
      }
    },
    {
      "chapter": 5,
      "title": "Ingest the music graph: nodes and relationships",
      "description": "Use the Capture API to load the entire music dataset - Artists, Albums, Tracks, Playlists, Persons, Venues, and 13 relationship types - in two requests.",
      "body": "<h2 class=\"\">Chapter 5: Ingest the music graph</h2>\n\n<p class=\"notion\">From the <a href=\"/guides/guide-environment\" class=\"fancy-link\">Environment guide</a>: the IKG is the foundation of every IndyKite product. Authorization decisions, ContX IQ queries, and contextual lookups all run against data captured here. The collection ships the music dataset inline so you can populate the graph in two requests.</p>\n\n<h3 class=\"\">Auth changes here</h3>\n<p class=\"notion\">Capture is data, not configuration. From this point on, requests use the <strong>Application Agent</strong> credential as <code class=\"notion\">X-IK-ClientKey: {{your_agent_token}}</code> instead of the ServiceAccount Bearer.</p>\n\n<h3 class=\"\">Run these two requests</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>Request</strong></td>\n<td class=\"simple-table-header-color\"><strong>Endpoint</strong></td>\n<td class=\"simple-table-header-color\"><strong>Payload size</strong></td>\n</tr>\n<tr><td class=\"\"><code class=\"notion\">upsert nodes</code></td><td class=\"\"><code class=\"notion\">POST /capture/v1/nodes/</code></td><td class=\"\">15k+ nodes across 6 types</td></tr>\n<tr><td class=\"\"><code class=\"notion\">upsert relationships</code></td><td class=\"\"><code class=\"notion\">POST /capture/v1/relationships</code></td><td class=\"\">31k+ relationships across 13 types</td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">What gets created</h3>\n<p class=\"notion\">Nodes by type:</p>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\">Artist: 94, Album: 1 247, Track: 14k+</li>\n<li style=\"list-style-type:disc\">Playlist: 20, Person: 86, Venue: 24</li>\n</ul>\n<p class=\"notion\">Relationships by type:</p>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\">Catalog: <code class=\"notion\">CREATED</code> (14k+), <code class=\"notion\">PART_OF</code> (14k+), <code class=\"notion\">RELEASED</code> (1k+)</li>\n<li style=\"list-style-type:disc\">Engagement: <code class=\"notion\">LIKES</code> (111), <code class=\"notion\">FOLLOWS</code> (42), <code class=\"notion\">SUBSCRIBED_TO</code> (30)</li>\n<li style=\"list-style-type:disc\">Family: <code class=\"notion\">MARRIED_TO</code> (15), <code class=\"notion\">PARENT_OF</code> (55), <code class=\"notion\">PARTNERS</code> (7), <code class=\"notion\">CO_PARENTS</code> (4)</li>\n<li style=\"list-style-type:disc\">Venue: <code class=\"notion\">WILL_ATTEND</code> (86), <code class=\"notion\">APPROVED_FOR</code> (318), <code class=\"notion\">PLAYED_AT</code> (314)</li>\n</ul>\n\n<h3 class=\"\">Body shape - upsert nodes</h3>\n<p class=\"notion\"><code class=\"notion\">POST /capture/v1/nodes/</code> with header <code class=\"notion\">X-IK-ClientKey: {{your_agent_token}}</code>. Each entry has an <code class=\"notion\">external_id</code>, a <code class=\"notion\">type</code> (label), and a list of typed properties. Sample slice (the full payload contains 15k+ nodes):</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"nodes\": [\n    {\n      \"external_id\": \"artist-2\",\n      \"type\": \"Artist\",\n      \"properties\": [\n        {\n          \"type\": \"name\",\n          \"value\": \"ABBA\"\n        }\n      ]\n    },\n    {\n      \"external_id\": \"venue-1\",\n      \"type\": \"Venue\",\n      \"properties\": [\n        {\n          \"type\": \"name\",\n          \"value\": \"Shower-Concert-Hall\"\n        },\n        {\n          \"type\": \"min_confidence\",\n          \"value\": 0.5\n        },\n        {\n          \"type\": \"max_loudness\",\n          \"value\": -3.0\n        }\n      ]\n    },\n    {\n      \"external_id\": \"auth0|69c3ee8cb9ed562744ff9326\",\n      \"type\": \"Person\",\n      \"properties\": [\n        {\n          \"type\": \"firstname\",\n          \"value\": \"Cornelius\"\n        },\n        {\n          \"type\": \"city\",\n          \"value\": \"Ctrl-Z Canyon\"\n        },\n        {\n          \"type\": \"music_mood\",\n          \"value\": \"Acoustic Sadness\"\n        },\n        {\n          \"type\": \"karaoke_confidence\",\n          \"value\": 0.4\n        },\n        {\n          \"type\": \"dance_skill\",\n          \"value\": 0.67\n        }\n      ]\n    }\n  ]\n}</code></pre>\n\n<h3 class=\"\">Body shape - upsert relationships</h3>\n<p class=\"notion\"><code class=\"notion\">POST /capture/v1/relationships</code> with the same <code class=\"notion\">X-IK-ClientKey</code> header. Each entry names a <code class=\"notion\">source</code>, a <code class=\"notion\">target</code>, and a <code class=\"notion\">type</code>. The platform is idempotent - running the same payload twice does not create duplicates. Sample slice (the full payload contains 31k+ relationships):</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"relationships\": [\n    {\n      \"source\": {\n        \"type\": \"Artist\",\n        \"external_id\": \"artist-1\"\n      },\n      \"target\": {\n        \"type\": \"Track\",\n        \"external_id\": \"track-1\"\n      },\n      \"type\": \"CREATED\"\n    },\n    {\n      \"source\": {\n        \"type\": \"Person\",\n        \"external_id\": \"person-52\"\n      },\n      \"target\": {\n        \"type\": \"Track\",\n        \"external_id\": \"track-9381\"\n      },\n      \"type\": \"LIKES\"\n    },\n    {\n      \"source\": {\n        \"type\": \"Person\",\n        \"external_id\": \"auth0|69c3ee8cb9ed562744ff9326\"\n      },\n      \"target\": {\n        \"type\": \"Venue\",\n        \"external_id\": \"venue-1\"\n      },\n      \"type\": \"WILL_ATTEND\"\n    }\n  ]\n}</code></pre>\n\n<h3 class=\"\">Recommended test users</h3>\n<p class=\"notion\">The 86 Person nodes use two id schemes: 74 synthetic users with <code class=\"notion\">person-N</code> external_ids (numbered 1-85 with a few gaps), and 12 real <code class=\"notion\">auth0|...</code> subjects for users meant to drive end-to-end CIQ executes with a Bearer access token. The dataset is seeded so the two recommended auth0 users below cover every Person-subject query that matters:</p>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>Auth0 sub</strong></td>\n<td class=\"simple-table-header-color\"><strong>Person</strong></td>\n<td class=\"simple-table-header-color\"><strong>Relationships</strong></td>\n<td class=\"simple-table-header-color\"><strong>Use to test</strong></td>\n</tr>\n<tr>\n<td class=\"\"><code class=\"notion\">auth0|69c3ee8cb9ed562744ff9326</code></td>\n<td class=\"\">Cornelius (age 14)</td>\n<td class=\"\">5 LIKES, 2 FOLLOWS, 2 SUBSCRIBED_TO, 5 WILL_ATTEND, 1 CREATED Playlist, plus PARENT_OF coming in</td>\n<td class=\"\">All \"own data\" queries (kq4-kq9), social/taste queries (kq14-kq20), venue queries (kq12, kq13, kq22), engagement (kq24).</td>\n</tr>\n<tr>\n<td class=\"\"><code class=\"notion\">auth0|69c4129b0ba356c7db9f91ab</code></td>\n<td class=\"\">Marmaduke (parent of person-15, person-16)</td>\n<td class=\"\">PARENT_OF -&gt; person-15 / person-16; each child has 3 LIKES.</td>\n<td class=\"\">Parent-side queries: kq11 (children-likes), kq10 (family-playlists).</td>\n</tr>\n</tbody>\n</table>\n<p class=\"notion\">Pick the auth0 sub that matches the query you're testing - the bearer's <code class=\"notion\">sub</code> claim is what the policy filter pins on (see Chapter 8). The other 10 auth0 users only have family relationships and will return empty for music-engagement queries.</p>\n\n<h3 class=\"\">Verifying the ingest</h3>\n<p class=\"notion\">A non-error 200 response on each request is sufficient for now. Chapters 6-10 will exercise the data via authorization and CIQ executes. If you need to ingest a single subset or update a property later, see the <a href=\"/resources\" class=\"fancy-link\">Capture resource examples</a>.</p>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 6 introduces KBAC policies - the yes/no authorization rules - using ten concrete music-app scenarios.</p>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-5",
        "markdown": "/tutorials/tutorial-music-dataset/5.md"
      }
    },
    {
      "chapter": 6,
      "title": "KBAC policies: define what's allowed",
      "description": "Author ten KBAC policies covering venue performance, entry, flash mobs, track loudness gates, playlist sharing, family playlists, and DJ rights.",
      "body": "<h2 class=\"\">Chapter 6: KBAC policies</h2>\n\n<p class=\"notion\">From the <a href=\"/guides/guide-dynamic-authz\" class=\"fancy-link\">Dynamic Authorization guide</a> and <a href=\"/guides/guide-authzen\" class=\"fancy-link\">AuthZEN guide</a>: <strong>Knowledge-Based Access Control (KBAC)</strong> is the rule layer. Each policy declares a <code class=\"notion\">subject</code>, an <code class=\"notion\">action</code>, a <code class=\"notion\">resource</code> shape (via the cypher MATCH), and the <code class=\"notion\">condition</code> the subject must satisfy. Chapter 7 turns these into yes/no decisions via the AuthZEN <code class=\"notion\">/access/v1/evaluation</code> endpoint.</p>\n\n<h3 class=\"\">The ten policies in the collection</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>Request</strong></td>\n<td class=\"simple-table-header-color\"><strong>Policy name</strong></td>\n<td class=\"simple-table-header-color\"><strong>Subject</strong></td>\n<td class=\"simple-table-header-color\"><strong>Action</strong></td>\n<td class=\"simple-table-header-color\"><strong>Resource</strong></td>\n<td class=\"simple-table-header-color\"><strong>Allows when…</strong></td>\n</tr>\n<tr><td class=\"\"><code class=\"notion\">kbac</code></td><td class=\"\">concert-performer</td><td class=\"\">Person</td><td class=\"\">PERFORM</td><td class=\"\">Venue</td><td class=\"\">subject is going to the venue and karaoke_confidence ≥ venue.min_confidence</td></tr>\n<tr><td class=\"\"><code class=\"notion\">kbac2</code></td><td class=\"\">venue-entry-by-membership</td><td class=\"\">Person</td><td class=\"\">ENTER</td><td class=\"\">Venue</td><td class=\"\">subject is going to the venue (any WILL_ATTEND)</td></tr>\n<tr><td class=\"\"><code class=\"notion\">kbac3</code></td><td class=\"\">flash-mob-recruitment</td><td class=\"\">Person</td><td class=\"\">JOIN</td><td class=\"\">Venue (Flash-Mob-Recruitment)</td><td class=\"\">subject's dance_skill ≥ venue.min_danceability</td></tr>\n<tr><td class=\"\"><code class=\"notion\">kbac4</code></td><td class=\"\">track-loudness-check</td><td class=\"\">Track</td><td class=\"\">PLAY</td><td class=\"\">Venue</td><td class=\"\">track is PLAYED_AT and loudness ≥ max_loudness</td></tr>\n<tr><td class=\"\"><code class=\"notion\">kbac5</code></td><td class=\"\">dmv-endless-suffering</td><td class=\"\">Track</td><td class=\"\">PLAY</td><td class=\"\">Venue (DMV-Waiting-Area)</td><td class=\"\">track.energy ≤ venue.max_energy</td></tr>\n<tr><td class=\"\"><code class=\"notion\">kbac6</code></td><td class=\"\">playlist-venue-approval</td><td class=\"\">Playlist</td><td class=\"\">FEATURE</td><td class=\"\">Venue</td><td class=\"\">playlist is APPROVED_FOR the venue</td></tr>\n<tr><td class=\"\"><code class=\"notion\">kbac7</code></td><td class=\"\">share-subscribed-playlist</td><td class=\"\">Person</td><td class=\"\">SHARE</td><td class=\"\">Playlist</td><td class=\"\">subject SUBSCRIBED_TO or CREATED the playlist</td></tr>\n<tr><td class=\"\"><code class=\"notion\">kbac8</code></td><td class=\"\">family-playlist-access</td><td class=\"\">Person</td><td class=\"\">VIEW</td><td class=\"\">Playlist</td><td class=\"\">a family member (MARRIED_TO / PARENT_OF / PARTNERS) CREATED the playlist</td></tr>\n<tr><td class=\"\"><code class=\"notion\">kbac9</code></td><td class=\"\">corporate-no-enthusiasm</td><td class=\"\">Track</td><td class=\"\">PLAY</td><td class=\"\">Venue (Corporate-Meeting-Room)</td><td class=\"\">track.energy ≤ venue.max_energy</td></tr>\n<tr><td class=\"\"><code class=\"notion\">kbac10</code></td><td class=\"\">dj-at-venue</td><td class=\"\">Person</td><td class=\"\">DJ</td><td class=\"\">Venue</td><td class=\"\">subject WILL_ATTEND and karaoke_confidence ≥ 0.8</td></tr>\n</tbody>\n</table>\n<p class=\"notion\">A <code class=\"notion\">2.0-kbac</code> policy needs a subject ingested with <code class=\"notion\">is_identity: true</code>, and in this dataset only the people are. So the four policies whose subject is a <code class=\"notion\">Track</code> or a <code class=\"notion\">Playlist</code> (kbac4, kbac5, kbac6, kbac9) are created like the others but answer <code class=\"notion\">false</code> for every evaluation; Chapter 7 evaluates the six <code class=\"notion\">Person</code> policies.</p>\n\n<h3 class=\"\">Anatomy of one KBAC policy</h3>\n<p class=\"notion\">Each <code class=\"notion\">kbacN</code> request posts to <code class=\"notion\">POST /configs/v1/authorization-policies</code> with a stringified policy body. Stripped of envelope, the shape is:</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"meta\": {\n    \"policy_version\": \"2.0-kbac\"\n  },\n  \"subject\": {\n    \"type\": \"Person\"\n  },\n  \"actions\": [\n    \"PERFORM\"\n  ],\n  \"condition\": {\n    \"cypher\": \"MATCH (subject:Person)-[:WILL_ATTEND]-&gt;(resource:Venue) MATCH (subject)-[:HAS]-&gt;(confidence:Property {type:'karaoke_confidence'}) MATCH (resource)-[:HAS]-&gt;(min_confidence:Property {type:'min_confidence'}) WHERE confidence.value &gt;= min_confidence.value\"\n  }\n}</code></pre>\n\n<p class=\"notion\">Four things to notice:</p>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\">The cypher binds <strong>two named nodes</strong>: <code class=\"notion\">subject</code> (matches the subject sent in the AuthZEN call) and <code class=\"notion\">resource</code> (matches the resource sent in the AuthZEN call).</li>\n<li style=\"list-style-type:disc\">The <strong>resource type</strong> is implied by the cypher (<code class=\"notion\">resource:Venue</code>), so the AuthZEN evaluation must send a Venue id.</li>\n<li style=\"list-style-type:disc\">The <strong>action</strong> array gates which AuthZEN calls this policy can answer (<code class=\"notion\">PERFORM</code> here).</li>\n<li style=\"list-style-type:disc\">A <strong>property</strong> is tested through its own node: match <code class=\"notion\">(node)-[:HAS]-&gt;(p:Property {type:'&lt;name&gt;'})</code> and compare <code class=\"notion\">p.value</code>. The <code class=\"notion\">node.property.&lt;name&gt;</code> path belongs to ContX IQ policies; in a KBAC condition it reads nothing, the policy is still saved, and every decision is <code class=\"notion\">false</code>.</li>\n</ul>\n\n<h3 class=\"\">Three more concrete examples</h3>\n\n<p class=\"notion\"><strong><code class=\"notion\">kbac4</code> - Track-loudness gate (Track subject):</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">POST /configs/v1/authorization-policies\n{\n  \"project_id\":   \"{{project_gid}}\",\n  \"name\":         \"track-loudness-check\",\n  \"display_name\": \"Track Loudness Venue Compatibility\",\n  \"policy\": \"{\n    \\\"meta\\\":      {\\\"policy_version\\\":\\\"2.0-kbac\\\"},\n    \\\"subject\\\":   {\\\"type\\\":\\\"Track\\\"},\n    \\\"actions\\\":   [\\\"PLAY\\\"],\n    \\\"resource\\\":  {\\\"type\\\":\\\"Venue\\\"},\n    \\\"condition\\\": {\\\"cypher\\\":\\\"MATCH (subject:Track)-[:PLAYED_AT]->(resource:Venue) MATCH (subject)-[:HAS]->(loudness:Property {type:'loudness'}) MATCH (resource)-[:HAS]->(max_loudness:Property {type:'max_loudness'}) WHERE loudness.value >= max_loudness.value\\\"}\n  }\",\n  \"status\": \"ACTIVE\"\n}</code></pre>\n\n<p class=\"notion\"><strong><code class=\"notion\">kbac6</code> - Playlist venue approval (Playlist subject, no WHERE):</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">policy: {\n  \"subject\":   {\"type\":\"Playlist\"},\n  \"actions\":   [\"FEATURE\"],\n  \"resource\":  {\"type\":\"Venue\"},\n  \"condition\": {\"cypher\":\"MATCH (subject:Playlist)-[:APPROVED_FOR]->(resource:Venue)\"}\n}</code></pre>\n\n<p class=\"notion\"><strong><code class=\"notion\">kbac8</code> - Family playlist access (multi-relationship-type pattern):</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">policy: {\n  \"subject\":   {\"type\":\"Person\"},\n  \"actions\":   [\"VIEW\"],\n  \"resource\":  {\"type\":\"Playlist\"},\n  \"condition\": {\"cypher\":\"MATCH (subject:Person)-[:MARRIED_TO|PARENT_OF|PARTNERS]-(family:Person)-[:CREATED]->(resource:Playlist)\"}\n}</code></pre>\n\n<h3 class=\"\">Auth</h3>\n<p class=\"notion\">All ten requests use <code class=\"notion\">{{your_sa_token}}</code> as <code class=\"notion\">Authorization: Bearer ...</code> (Config API). The capture script writes the returned policy GID into <code class=\"notion\">policy_gid</code>, which is overwritten each time a new policy is created.</p>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 7 evaluates these policies with single AuthZEN calls and a boxcar batch.</p>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-6",
        "markdown": "/tutorials/tutorial-music-dataset/6.md"
      }
    },
    {
      "chapter": 7,
      "title": "AuthZEN evaluations: yes/no decisions on the music graph",
      "description": "Run thirteen single AuthZEN evaluations and one boxcar batch against the KBAC policies authored in Chapter 6.",
      "body": "<h2 class=\"\">Chapter 7: AuthZEN evaluations</h2>\n\n<p class=\"notion\">From the <a href=\"/guides/guide-authzen\" class=\"fancy-link\">AuthZEN guide</a>: AuthZEN is a standard request shape - <em>subject</em>, <em>resource</em>, <em>action</em> - that returns a yes/no decision. IndyKite implements the standard at <code class=\"notion\">POST /access/v1/evaluation</code> for a single decision and <code class=\"notion\">POST /access/v1/evaluations</code> for a batch (boxcar).</p>\n\n<h3 class=\"\">Auth changes back to the agent token</h3>\n<p class=\"notion\">Evaluations are runtime data, not configuration, so they use the Application Agent credential as <code class=\"notion\">X-IK-ClientKey: {{your_agent_token}}</code> - same as the Capture and CIQ requests. No ServiceAccount Bearer here.</p>\n\n<h3 class=\"\">The thirteen single evaluations</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr>\n<td class=\"simple-table-header-color\"><strong>Request</strong></td>\n<td class=\"simple-table-header-color\"><strong>Subject</strong></td>\n<td class=\"simple-table-header-color\"><strong>Resource</strong></td>\n<td class=\"simple-table-header-color\"><strong>Action</strong></td>\n<td class=\"simple-table-header-color\"><strong>Targets policy</strong></td>\n<td class=\"simple-table-header-color\"><strong>Expected decision</strong></td>\n</tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation</code></td><td class=\"\">Person/<code class=\"notion\">person-52</code></td><td class=\"\">Venue/<code class=\"notion\">venue-1</code></td><td class=\"\">ENTER</td><td class=\"\">kbac2 (venue-entry-by-membership)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation2</code></td><td class=\"\">Person/<code class=\"notion\">person-52</code></td><td class=\"\">Venue/<code class=\"notion\">venue-10</code></td><td class=\"\">ENTER</td><td class=\"\">kbac2 (venue-entry-by-membership)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation3</code></td><td class=\"\">Person/<code class=\"notion\">person-44</code></td><td class=\"\">Playlist/<code class=\"notion\">playlist-5</code></td><td class=\"\">VIEW</td><td class=\"\">kbac8 (family-playlist-access)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation4</code></td><td class=\"\">Person/<code class=\"notion\">person-47</code></td><td class=\"\">Playlist/<code class=\"notion\">playlist-2</code></td><td class=\"\">SHARE</td><td class=\"\">kbac7 (share-subscribed-playlist)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation5</code></td><td class=\"\">Person/<code class=\"notion\">person-40</code></td><td class=\"\">Venue/<code class=\"notion\">venue-3</code></td><td class=\"\">ENTER</td><td class=\"\">kbac2 (venue-entry-by-membership)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation6</code></td><td class=\"\">Person/<code class=\"notion\">person-2</code></td><td class=\"\">Playlist/<code class=\"notion\">playlist-1</code></td><td class=\"\">VIEW</td><td class=\"\">kbac8 (family-playlist-access)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation7</code></td><td class=\"\">Person/<code class=\"notion\">person-44</code></td><td class=\"\">Playlist/<code class=\"notion\">playlist-17</code></td><td class=\"\">SHARE</td><td class=\"\">kbac7 (share-subscribed-playlist)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation8</code></td><td class=\"\">Person/<code class=\"notion\">person-1</code></td><td class=\"\">Playlist/<code class=\"notion\">playlist-13</code></td><td class=\"\">VIEW</td><td class=\"\">kbac8 (family-playlist-access)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation9</code></td><td class=\"\">Person/<code class=\"notion\">person-56</code></td><td class=\"\">Playlist/<code class=\"notion\">playlist-5</code></td><td class=\"\">SHARE</td><td class=\"\">kbac7 (share-subscribed-playlist)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation10</code></td><td class=\"\">Person/<code class=\"notion\">person-39</code></td><td class=\"\">Venue/<code class=\"notion\">venue-21</code></td><td class=\"\">ENTER</td><td class=\"\">kbac2 (venue-entry-by-membership)</td><td class=\"\"><code class=\"notion\">true</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation11</code></td><td class=\"\">Person/<code class=\"notion\">person-52</code></td><td class=\"\">Venue/<code class=\"notion\">venue-1</code></td><td class=\"\">PERFORM</td><td class=\"\">kbac (concert-performer)</td><td class=\"\"><code class=\"notion\">true</code>: karaoke_confidence 0.73 ≥ min_confidence 0.7</td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation12</code></td><td class=\"\">Person/<code class=\"notion\">person-47</code></td><td class=\"\">Venue/<code class=\"notion\">venue-16</code></td><td class=\"\">JOIN</td><td class=\"\">kbac3 (flash-mob-recruitment)</td><td class=\"\"><code class=\"notion\">true</code>: dance_skill 1.0 ≥ min_danceability 0.85</td></tr>\n<tr><td class=\"\"><code class=\"notion\">Evaluation13</code></td><td class=\"\">Person/<code class=\"notion\">person-40</code></td><td class=\"\">Venue/<code class=\"notion\">venue-3</code></td><td class=\"\">DJ</td><td class=\"\">kbac10 (dj-at-venue)</td><td class=\"\"><code class=\"notion\">true</code>: karaoke_confidence 0.87 ≥ 0.8</td></tr>\n</tbody>\n</table>\n<p class=\"notion\">Every request in the collection is expected to answer <code class=\"notion\">true</code>. To see a rule deny, change one value: <code class=\"notion\">Evaluation13</code> with <code class=\"notion\">person-52</code> at <code class=\"notion\">venue-1</code> answers <code class=\"notion\">false</code>, because that person attends the venue but has a karaoke_confidence of 0.73, below 0.8. A <code class=\"notion\">false</code> on one of <code class=\"notion\">Evaluation11</code> to <code class=\"notion\">Evaluation13</code> as written means the policy does not read the property: check its condition against Chapter 6.</p>\n<p class=\"notion\">Every subject here is a <code class=\"notion\">Person</code>. The four policies whose subject is a <code class=\"notion\">Track</code> or a <code class=\"notion\">Playlist</code> (kbac4, kbac5, kbac6, kbac9) are not evaluated in this chapter: a <code class=\"notion\">2.0-kbac</code> policy needs a subject ingested with <code class=\"notion\">is_identity: true</code>, and in this dataset only the people are. An evaluation with a track or a playlist as subject answers <code class=\"notion\">false</code>.</p>\n\n<h3 class=\"\">Single AuthZEN body shape</h3>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"subject\": {\n    \"type\": \"Person\",\n    \"id\": \"person-52\"\n  },\n  \"resource\": {\n    \"type\": \"Venue\",\n    \"id\": \"venue-1\"\n  },\n  \"action\": {\n    \"name\": \"ENTER\"\n  }\n}</code></pre>\n<p class=\"notion\">The platform finds a policy whose <code class=\"notion\">subject.type</code>, cypher <code class=\"notion\">resource:&lt;Type&gt;</code>, and declared action all match, then evaluates the cypher condition against the IKG. The response is an AuthZEN decision (<code class=\"notion\">decision: true|false</code>) plus optional context.</p>\n\n<h3 class=\"\">Boxcar batch</h3>\n<p class=\"notion\">From the <a href=\"/resources\" class=\"fancy-link\">batch authorization resource</a>: when a single caller needs many decisions in one round-trip, send them all to <code class=\"notion\">POST /access/v1/evaluations</code> (note the plural). The collection's <code class=\"notion\">Evaluations</code> request batches three sub-evaluations under a default subject of <code class=\"notion\">person-52</code>; a sub-evaluation can also carry its own <code class=\"notion\">subject</code>, which then replaces the default for that entry:</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"subject\": {\n    \"type\": \"Person\",\n    \"id\": \"person-52\"\n  },\n  \"evaluations\": [\n    {\n      \"resource\": {\n        \"type\": \"Venue\",\n        \"id\": \"venue-1\"\n      },\n      \"action\": {\n        \"name\": \"ENTER\"\n      }\n    },\n    {\n      \"resource\": {\n        \"type\": \"Venue\",\n        \"id\": \"venue-10\"\n      },\n      \"action\": {\n        \"name\": \"ENTER\"\n      }\n    },\n    {\n      \"resource\": {\n        \"type\": \"Playlist\",\n        \"id\": \"playlist-9\"\n      },\n      \"action\": {\n        \"name\": \"SHARE\"\n      }\n    }\n  ]\n}</code></pre>\n<p class=\"notion\">All three are expected to answer <code class=\"notion\">true</code>: the two <code class=\"notion\">ENTER</code> entries through kbac2, the <code class=\"notion\">SHARE</code> entry through kbac7.</p>\n\n<h3 class=\"\">More single examples</h3>\n\n<p class=\"notion\"><strong><code class=\"notion\">Evaluation13</code> - a rule that tests a property (kbac10 dj-at-venue):</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">POST /access/v1/evaluation\n{\n  \"subject\": {\n    \"type\": \"Person\",\n    \"id\": \"person-40\"\n  },\n  \"resource\": {\n    \"type\": \"Venue\",\n    \"id\": \"venue-3\"\n  },\n  \"action\": {\n    \"name\": \"DJ\"\n  }\n}</code></pre>\n\n<p class=\"notion\"><strong><code class=\"notion\">Evaluation8</code> - Person subject + Playlist resource (kbac8 family-playlist):</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"subject\": {\n    \"type\": \"Person\",\n    \"id\": \"person-1\"\n  },\n  \"resource\": {\n    \"type\": \"Playlist\",\n    \"id\": \"playlist-13\"\n  },\n  \"action\": {\n    \"name\": \"VIEW\"\n  }\n}</code></pre>\n\n<h3 class=\"\">Response shape</h3>\n<p class=\"notion\">Successful AuthZEN responses are minimal: a boolean decision and optional context. For example:</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"decision\": true,\n  \"context\": {\n    \"reason\": null\n  }\n}</code></pre>\n<p class=\"notion\">For the boxcar endpoint, the response is an array of <code class=\"notion\">{ decision, context }</code> objects in the same order as the request's <code class=\"notion\">evaluations</code> array.</p>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 8 switches to ContX IQ - data queries with policy-scoped reads and writes - by authoring 24 CIQ policies.</p>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-7",
        "markdown": "/tutorials/tutorial-music-dataset/7.md"
      }
    },
    {
      "chapter": 8,
      "title": "ContX IQ policies: context-aware data access",
      "description": "Author 24 CIQ policies that gate what reads, writes, and deletes are allowed against the music graph - with subject scoping for Person and Application identities.",
      "body": "<h2 class=\"\">Chapter 8: ContX IQ policies</h2>\n\n<p class=\"notion\">From the <a href=\"/guides/guide-contx-iq\" class=\"fancy-link\">ContX IQ guide</a>: ContX IQ moves authorization from \"yes/no\" (KBAC) to \"what data can this caller actually see / change\". A CIQ policy declares a <code class=\"notion\">subject</code> type, a cypher <code class=\"notion\">condition</code> with optional <code class=\"notion\">$param</code> filters, and an <code class=\"notion\">allowed_reads</code> / <code class=\"notion\">allowed_upserts</code> / <code class=\"notion\">allowed_deletes</code> projection over the matched graph.</p>\n\n<h3 class=\"\">Subjects in this collection</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr><td class=\"simple-table-header-color\"><strong>Subject type</strong></td><td class=\"simple-table-header-color\"><strong>Used by</strong></td><td class=\"simple-table-header-color\"><strong>Auth at execute time</strong></td></tr>\n<tr><td class=\"\"><code class=\"notion\">_Application</code></td><td class=\"\">System-level catalog ops (venue playable tracks, artist catalog, karaoke-ready people, attendance stats).</td><td class=\"\"><code class=\"notion\">X-IK-ClientKey: {{your_agent_token}}</code> only.</td></tr>\n<tr><td class=\"\"><code class=\"notion\">Person</code></td><td class=\"\">User-scoped reads/writes (own profile, liked tracks, playlists, family, similar taste, etc.).</td><td class=\"\"><code class=\"notion\">X-IK-ClientKey: {{your_agent_token}}</code> + <code class=\"notion\">Authorization: Bearer {{your_user_token}}</code>.</td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">Person-subject filter convention</h3>\n<p class=\"notion\">Every Person-subject policy in this collection includes:</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"operator\": \"=\",\n  \"attribute\": \"subject.external_id\",\n  \"value\": \"$token.sub\"\n}</code></pre>\n<p class=\"notion\">Without this clause, <code class=\"notion\">MATCH (subject:Person)</code> matches every Person in the graph - not just the caller. Anchoring it to <code class=\"notion\">$token.sub</code> means the platform plugs in the verified <code class=\"notion\">sub</code> claim from the bearer token at execute time. There is no client-supplied <code class=\"notion\">subject_external_id</code> input param, so callers cannot point the query at someone else's data; the bearer is the only identity source.</p>\n\n<h3 class=\"\">The 24 policies (grouped by domain)</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr><td class=\"simple-table-header-color\"><strong>Group</strong></td><td class=\"simple-table-header-color\"><strong>Subject</strong></td><td class=\"simple-table-header-color\"><strong>Policies (request → name)</strong></td></tr>\n<tr><td class=\"\">Application catalog ops</td><td class=\"\"><code class=\"notion\">_Application</code></td><td class=\"\"><code class=\"notion\">ciqpolicy</code> (venue-playable-tracks), <code class=\"notion\">ciqpolicy2</code> (artist-catalog), <code class=\"notion\">ciqpolicy3</code> (karaoke-ready-people), <code class=\"notion\">ciqpolicy21</code> (venue-attendance-stats)</td></tr>\n<tr><td class=\"\">Person - own data</td><td class=\"\"><code class=\"notion\">Person</code></td><td class=\"\"><code class=\"notion\">ciqpolicy4</code> (own-profile), <code class=\"notion\">5</code> (own-liked-tracks), <code class=\"notion\">6</code> (own-playlists), <code class=\"notion\">7</code> (own-subscriptions), <code class=\"notion\">8</code> (own-followed-artists), <code class=\"notion\">9</code> (own-venues), <code class=\"notion\">24</code> (own-playlist-engagement)</td></tr>\n<tr><td class=\"\">Person - family</td><td class=\"\"><code class=\"notion\">Person</code></td><td class=\"\"><code class=\"notion\">ciqpolicy10</code> (family-playlists), <code class=\"notion\">11</code> (children-likes)</td></tr>\n<tr><td class=\"\">Person - venue context</td><td class=\"\"><code class=\"notion\">Person</code></td><td class=\"\"><code class=\"notion\">ciqpolicy12</code> (venue-other-attendees), <code class=\"notion\">13</code> (venue-playlists), <code class=\"notion\">17</code> (matching-venues), <code class=\"notion\">18</code> (liked-tracks-at-venue), <code class=\"notion\">22</code> (people-in-venue-list), <code class=\"notion\">23</code> (eligible-venues-broad)</td></tr>\n<tr><td class=\"\">Person - social</td><td class=\"\"><code class=\"notion\">Person</code></td><td class=\"\"><code class=\"notion\">ciqpolicy14</code> (same-taste), <code class=\"notion\">15</code> (same-artist-followers), <code class=\"notion\">16</code> (created-playlist-subscribers), <code class=\"notion\">19</code> (popular-tracks-by-followed), <code class=\"notion\">20</code> (liked-tracks-avg-energy)</td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">Anatomy of one CIQ policy</h3>\n<p class=\"notion\">Stripped of envelope, a Person-subject policy with a <code class=\"notion\">$param</code> filter looks like:</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"meta\": {\n    \"policy_version\": \"1.0-ciq\"\n  },\n  \"subject\": {\n    \"type\": \"Person\"\n  },\n  \"condition\": {\n    \"cypher\": \"MATCH (subject:Person)-[:WILL_ATTEND]-&gt;(venue:Venue)&lt;-[:WILL_ATTEND]-(other:Person)\",\n    \"filter\": [\n      {\n        \"operator\": \"AND\",\n        \"operands\": [\n          {\n            \"operator\": \"=\",\n            \"attribute\": \"subject.external_id\",\n            \"value\": \"$token.sub\"\n          },\n          {\n            \"operator\": \"=\",\n            \"attribute\": \"venue.property.name\",\n            \"value\": \"$venue_name\"\n          }\n        ]\n      }\n    ]\n  },\n  \"allowed_reads\": {\n    \"nodes\": [\n      \"other.property.firstname\",\n      \"other.property.city\",\n      \"venue.property.name\"\n    ]\n  }\n}</code></pre>\n\n<p class=\"notion\">Each <code class=\"notion\">$param</code> in the filter becomes a required <code class=\"notion\">input_params</code> key when the query that uses this policy is executed (Chapter 10). Missing one returns <code class=\"notion\">HTTP 422 invalid_argument: missing or wrong input params</code>.</p>\n\n<h3 class=\"\">Two real examples from the collection</h3>\n\n<p class=\"notion\"><strong><code class=\"notion\">ciqpolicy4</code> - simplest Person-subject policy (read/update own profile):</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">POST /configs/v1/authorization-policies\n{\n  \"project_id\":   \"{{project_gid}}\",\n  \"name\":         \"ciq-person-own-profile\",\n  \"display_name\": \"Person: Read and Update Own Profile\",\n  \"policy\": \"{\n    \\\"meta\\\":      {\\\"policy_version\\\":\\\"1.0-ciq\\\"},\n    \\\"subject\\\":   {\\\"type\\\":\\\"Person\\\"},\n    \\\"condition\\\": {\n      \\\"cypher\\\":  \\\"MATCH (subject:Person)\\\",\n      \\\"filter\\\":  [{\\\"operator\\\":\\\"=\\\",\\\"attribute\\\":\\\"subject.external_id\\\",\\\"value\\\":\\\"$token.sub\\\"}]\n    },\n    \\\"allowed_reads\\\": {\n      \\\"nodes\\\": [\n        \\\"subject.property.firstname\\\", \\\"subject.property.lastname\\\",\n        \\\"subject.property.email\\\",     \\\"subject.property.age\\\",\n        \\\"subject.property.city\\\",      \\\"subject.property.state\\\",\n        \\\"subject.property.music_mood\\\",\\\"subject.property.karaoke_confidence\\\",\n        \\\"subject.property.dance_skill\\\",\\\"subject.property.profession\\\"\n      ]\n    },\n    \\\"allowed_upserts\\\": { \\\"nodes\\\": { \\\"existing_nodes\\\": [\\\"subject\\\"] } }\n  }\",\n  \"status\": \"ACTIVE\"\n}</code></pre>\n\n<p class=\"notion\"><strong><code class=\"notion\">ciqpolicy14</code> - same-taste with COUNT aggregates and an OR clause:</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">policy: {\n  \"subject\":   {\"type\":\"Person\"},\n  \"condition\": {\n    \"cypher\": \"MATCH (subject:Person)-[:LIKES]->(track:Track)<-[:LIKES]-(other:Person)\n               WHERE subject <> other\n               WITH subject, other, COUNT(DISTINCT track) AS sharedTracks\n               OPTIONAL MATCH (subject)-[:FOLLOWS]->(artist:Artist)<-[:FOLLOWS]-(other)\n               WITH subject, other, sharedTracks,\n                    COUNT(DISTINCT artist) AS sharedArtists\",\n    \"filter\": [{\"operator\":\"AND\",\"operands\":[\n       {\"attribute\":\"subject.external_id\",\"operator\":\"=\", \"value\":\"$token.sub\"},\n       {\"attribute\":\"sharedTracks\",       \"operator\":\">=\",\"value\":\"$min_shared_tracks\"},\n       {\"operator\":\"OR\",\"operands\":[\n         {\"attribute\":\"other.property.city\",\"operator\":\"=\",\"value\":\"subject.property.city\"},\n         {\"attribute\":\"sharedArtists\",      \"operator\":\">=\",\"value\":\"$min_shared_artists\"}\n       ]}\n    ]}]\n  },\n  \"allowed_reads\": {\n    \"nodes\": [\"other.property.firstname\",\"other.property.lastname\",\n              \"other.property.city\",     \"other.property.music_mood\"],\n    \"aggregate_values\": [\"sharedTracks\", \"sharedArtists\"]\n  }\n}</code></pre>\n<p class=\"notion\">The aggregate variables produced by <code class=\"notion\">WITH</code> become first-class <code class=\"notion\">aggregate_values</code> the query can read - more on that in Chapter 9.</p>\n\n<h3 class=\"\">Auth</h3>\n<p class=\"notion\">All <code class=\"notion\">ciqpolicyN</code> requests use the ServiceAccount Bearer (<code class=\"notion\">{{your_sa_token}}</code>) - they are Config API calls. The capture script writes the response id into <code class=\"notion\">policy_gid</code>, which is then consumed by the Knowledge Query immediately following.</p>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 9 turns each policy into one or more Knowledge Queries that declare what to read or write.</p>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-8",
        "markdown": "/tutorials/tutorial-music-dataset/8.md"
      }
    },
    {
      "chapter": 9,
      "title": "Knowledge Queries: declare what to read or write",
      "description": "Author 44 Knowledge Queries against the 24 CIQ policies - read variants, write variants, and delete variants for the music graph.",
      "body": "<h2 class=\"\">Chapter 9: Knowledge Queries</h2>\n\n<p class=\"notion\">From the <a href=\"/guides/guide-contx-iq\" class=\"fancy-link\">ContX IQ guide</a>: a Knowledge Query (KQ) is a thin wrapper that <strong>names a projection</strong> over a CIQ policy. The policy controls what's <em>allowed</em>; the query says what subset of that to <em>actually fetch or write</em>.</p>\n\n<h3 class=\"\">Why one policy can have multiple queries</h3>\n<p class=\"notion\">For a single policy like <code class=\"notion\">ciq-app-venue-playable-tracks</code> the collection ships three variants:</p>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\"><code class=\"notion\">kq</code> - read tracks at the venue.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">kqb</code> - upsert (write) Track→Venue relationships allowed by the same policy.</li>\n<li style=\"list-style-type:disc\"><code class=\"notion\">kqc</code> - delete those relationships.</li>\n</ul>\n<p class=\"notion\">All three reference the same <code class=\"notion\">policy_id</code> (<code class=\"notion\">{{policy_gid}}</code>, the most recent CIQ policy created), but their <code class=\"notion\">query</code> JSON expresses different node/relationship subsets.</p>\n\n<h3 class=\"\">Query body shape</h3>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"project_id\": \"{{project_gid}}\",\n  \"name\": \"kq-app-venue-playable-tracks-read\",\n  \"display_name\": \"App Query: Read Venue's Playable Tracks\",\n  \"description\": \"Read tracks that can be played at a venue\",\n  \"policy_id\": \"{{policy_gid}}\",\n  \"query\": \"{\\\"nodes\\\":[\\\"track.property.title\\\",\\\"track.property.loudness\\\",...],\\\"relationships\\\":[\\\"r\\\"]}\",\n  \"status\": \"ACTIVE\"\n}</code></pre>\n<p class=\"notion\">The <code class=\"notion\">query</code> field is a stringified JSON. Inside, <code class=\"notion\">nodes</code> lists the node properties to project, and <code class=\"notion\">relationships</code> lists relationship variables (named in the policy's cypher) to include. Aggregations are referenced via <code class=\"notion\">aggregate_values</code> when the policy declares them.</p>\n\n<h3 class=\"\">Mapping policy → queries in the collection</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr><td class=\"simple-table-header-color\"><strong>Policy</strong></td><td class=\"simple-table-header-color\"><strong>Queries</strong></td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy</code></td><td class=\"\"><code class=\"notion\">kq</code> (read), <code class=\"notion\">kqb</code> (write), <code class=\"notion\">kqc</code> (delete)</td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy2</code></td><td class=\"\"><code class=\"notion\">kq2</code>, <code class=\"notion\">kq2b</code>, <code class=\"notion\">kq2c</code>, <code class=\"notion\">kq2d</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy3</code></td><td class=\"\"><code class=\"notion\">kq3</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy4</code></td><td class=\"\"><code class=\"notion\">kq4</code> (read), <code class=\"notion\">kq4b</code> (write)</td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy5</code></td><td class=\"\"><code class=\"notion\">kq5</code>, <code class=\"notion\">kq5b</code>, <code class=\"notion\">kq5c</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy6</code></td><td class=\"\"><code class=\"notion\">kq6</code>, <code class=\"notion\">kq6b</code>, <code class=\"notion\">kq6c</code>, <code class=\"notion\">kq6d</code></td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy7</code> - <code class=\"notion\">ciqpolicy9</code></td><td class=\"\">3 variants each (read/write/delete)</td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy10</code> - <code class=\"notion\">ciqpolicy11</code></td><td class=\"\">1 read each (family / children's likes)</td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy12</code></td><td class=\"\"><code class=\"notion\">kq12</code> (read venue attendees)</td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy13</code></td><td class=\"\">3 variants (read/write/delete venue playlists)</td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy14</code> - <code class=\"notion\">ciqpolicy16</code></td><td class=\"\">1 read each (social / matching)</td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy17</code></td><td class=\"\">2 (read, write)</td></tr>\n<tr><td class=\"\"><code class=\"notion\">ciqpolicy18</code> - <code class=\"notion\">ciqpolicy24</code></td><td class=\"\">1 query each (analytics &amp; engagement)</td></tr>\n</tbody>\n</table>\n\n<p class=\"notion\">Total: <strong>44 Knowledge Queries</strong> across the 24 policies. Run them in document order so the capture script can pair each one to its policy.</p>\n\n<h3 class=\"\">Run-order rule</h3>\n<p class=\"notion\">The collection is laid out so that every <code class=\"notion\">ciqpolicyN</code> creation is immediately followed by its query (or queries). The capture script overwrites <code class=\"notion\">policy_gid</code> on every policy create and <code class=\"notion\">query_gid</code> on every query create. Each <code class=\"notion\">ciq exec ...</code> request in the next chapter uses the most recent <code class=\"notion\">query_gid</code>, so a policy → query → execute triplet always sees consistent values.</p>\n\n<h3 class=\"\">Real KQ bodies from the collection</h3>\n\n<p class=\"notion\"><strong><code class=\"notion\">kq4</code> - read own profile (paired with ciqpolicy4):</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">POST /configs/v1/knowledge-queries\n{\n  \"project_id\":   \"{{project_gid}}\",\n  \"name\":         \"kq-person-own-profile-read\",\n  \"display_name\": \"Person Query: Read Own Profile\",\n  \"policy_id\":    \"{{policy_gid}}\",\n  \"query\": \"{\n     \\\"nodes\\\": [\n       \\\"subject.property.firstname\\\", \\\"subject.property.lastname\\\",\n       \\\"subject.property.email\\\",     \\\"subject.property.age\\\",\n       \\\"subject.property.city\\\",      \\\"subject.property.music_mood\\\"\n     ],\n     \\\"relationships\\\": []\n  }\",\n  \"status\": \"ACTIVE\"\n}</code></pre>\n\n<p class=\"notion\"><strong><code class=\"notion\">kq14</code> - same-taste with aggregate values (paired with ciqpolicy14):</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"name\": \"kq-person-same-taste\",\n  \"policy_id\": \"{{policy_gid}}\",\n  \"query\": \"{\n    \\\"nodes\\\": [\n      \\\"other.property.firstname\\\", \\\"other.property.lastname\\\",\n      \\\"other.property.city\\\",      \\\"other.property.music_mood\\\"\n    ],\n    \\\"aggregate_values\\\": [\\\"sharedTracks\\\", \\\"sharedArtists\\\"]\n  }\",\n  \"status\": \"ACTIVE\"\n}</code></pre>\n\n<p class=\"notion\"><strong><code class=\"notion\">kq22</code> - venue whitelist (uses <code class=\"notion\">venue.property.name</code> projection):</strong></p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"name\": \"kq-person-people-in-venue-list\",\n  \"policy_id\": \"{{policy_gid}}\",\n  \"query\": \"{\n    \\\"nodes\\\": [\n      \\\"other.property.firstname\\\",\n      \\\"other.property.city\\\",\n      \\\"venue.property.name\\\"\n    ]\n  }\",\n  \"status\": \"ACTIVE\"\n}</code></pre>\n\n<h3 class=\"\">Auth</h3>\n<p class=\"notion\">All KQ creation requests use the ServiceAccount Bearer (<code class=\"notion\">{{your_sa_token}}</code>) - same as the policies they reference.</p>\n\n<h3 class=\"\">What comes next</h3>\n<p class=\"notion\">Chapter 10 actually executes each Knowledge Query against the music graph using values drawn from the seeded dataset.</p>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-9",
        "markdown": "/tutorials/tutorial-music-dataset/9.md"
      }
    },
    {
      "chapter": 10,
      "title": "Execute the Knowledge Queries against the music graph",
      "description": "Run all 44 paired ciq exec requests, supplying the right input_params and auth headers so each query returns real music-dataset rows.",
      "body": "<h2 class=\"\">Chapter 10: Execute the Knowledge Queries</h2>\n\n<p class=\"notion\">From the <a href=\"/guides/guide-contx-iq\" class=\"fancy-link\">ContX IQ guide</a>: a CIQ execute is what actually fetches data. It posts to <code class=\"notion\">POST /contx-iq/v1/execute</code> with the query's <code class=\"notion\">id</code>, the values for each <code class=\"notion\">$param</code> declared by the underlying policy, and (for Person subjects) the user's bearer token.</p>\n\n<h3 class=\"\">One execute per query</h3>\n<p class=\"notion\">For each <code class=\"notion\">kq...</code> in Chapter 9 the collection ships a paired <code class=\"notion\">ciq exec ...</code> request positioned immediately after it. Naming convention: <code class=\"notion\">ciq exec kq</code>, <code class=\"notion\">ciq exec kqb</code>, ..., <code class=\"notion\">ciq exec kq24</code>. Total: <strong>44 executes</strong>.</p>\n\n<h3 class=\"\">Auth differs by subject type</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr><td class=\"simple-table-header-color\"><strong>Subject</strong></td><td class=\"simple-table-header-color\"><strong>Headers</strong></td></tr>\n<tr><td class=\"\"><code class=\"notion\">_Application</code> (9 executes)</td><td class=\"\"><code class=\"notion\">X-IK-ClientKey: {{your_agent_token}}</code> only.</td></tr>\n<tr><td class=\"\"><code class=\"notion\">Person</code> (35 executes)</td><td class=\"\"><code class=\"notion\">X-IK-ClientKey: {{your_agent_token}}</code> <strong>and</strong> <code class=\"notion\">Authorization: Bearer {{your_user_token}}</code>.</td></tr>\n</tbody>\n</table>\n<p class=\"notion\">Set <code class=\"notion\">your_user_token</code> in the Variables tab to a real end-user access token from your IdP before running any Person-subject execute. The token's <code class=\"notion\">sub</code> claim is what Token Introspect (Chapter 3) uses to resolve the caller to a Person node.</p>\n\n<p class=\"notion\"><strong>The collection is optimized for one end user: Millicent Contextsworth.</strong> The Person-subject executes are written to be run as a single caller, and the seeded <code class=\"notion\">input_params</code> assume that caller is the Person node <code class=\"notion\">Millicent Contextsworth</code> - <code class=\"notion\">external_id: auth0|69c410bfb501d3a02bd01ea2</code>. So set <code class=\"notion\">your_user_token</code> to a token <em>for Millicent</em>. The Person executes are ordered write-before-read, so running them top to bottom as Millicent first creates the referenced data (likes a track, creates/subscribes a playlist, follows an artist, attends a venue) and then the matching read/update/delete executes return it - all resolved to her via <code class=\"notion\">$token.sub</code>.</p>\n<p class=\"notion\"><strong>Mint Millicent's user token.</strong> Use IndyKite's <a href=\"https://toolbelt.indykite.com/\" class=\"fancy-link\">toolbelt.indykite.com</a> to issue a Person-subject user token: sign in with Millicent's <strong>email</strong> <code class=\"notion\">millicent@contextsworth.com</code> and the shared <strong>access code</strong> below. The minted token's <code class=\"notion\">sub</code> resolves to her Person node (<code class=\"notion\">external_id: auth0|69c410bfb501d3a02bd01ea2</code>). The toolbelt issues tokens against the same test Auth0 tenant referenced by Chapter 3's <code class=\"notion\">jwt_matcher</code>. All seeded Auth0 test users share one access code (intentionally public, rotated periodically): <button type=\"button\" class=\"reveal-btn\" data-x=\"SW5keSF\" data-y=\"Sb2NrIQ==\" onclick=\"var s=document.getElementById('test-user-pw');s.textContent=atob(this.dataset.x+this.dataset.y);s.hidden=false;this.hidden=true\">Reveal code</button><code id=\"test-user-pw\" class=\"notion\" hidden></code>. To run as a different seeded user instead, sign in with that user's email and the same code; the bundled example values, though, are tuned for Millicent.</p>\n<p class=\"notion\">The <strong>Music app</strong> - the collection plus all the data needed to recreate the whole environment (nodes, relationships, policies, queries, executes) - can be cloned from <a href=\"https://github.com/indykite/developer-hub/tree/master/music\" class=\"fancy-link\" target=\"_blank\">github.com/indykite/developer-hub/music</a>.</p>\n<p class=\"notion\">If you use your own IdP instead, you'll need a matching Token Introspect configuration (Chapter 3) pointing at that IdP's <code class=\"notion\">issuer</code> + <code class=\"notion\">audience</code>; then mint a token for one of your own users and upsert a matching <code class=\"notion\">Person</code> node via the Capture API (with <code class=\"notion\">external_id</code> equal to the token's <code class=\"notion\">sub</code>) so the CIQ executes resolve to it.</p>\n\n<h3 class=\"\">Execute body shape</h3>\n<p class=\"notion\">After the policy tightening in Chapter 8 (<code class=\"notion\">subject.external_id = $token.sub</code>), the only values left in <code class=\"notion\">input_params</code> are the policy's own <code class=\"notion\">$param</code> filters. Identity comes from the bearer token, not the body.</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"id\": \"{{query_gid}}\",\n  \"input_params\": {\n    \"venue_name\": \"Shower-Concert-Hall\"\n  },\n  \"page_token\": 1\n}</code></pre>\n\n<h3 class=\"\">Sample defaults wired into the collection</h3>\n<table class=\"simple-table\">\n<tbody>\n<tr><td class=\"simple-table-header-color\"><strong>Param</strong></td><td class=\"simple-table-header-color\"><strong>Default value</strong></td><td class=\"simple-table-header-color\"><strong>Why this works</strong></td></tr>\n<tr><td class=\"\">Person identity (via Bearer)</td><td class=\"\"><code class=\"notion\">{{your_user_token}}</code> for an Auth0 user whose <code class=\"notion\">sub</code> matches a seeded Person <code class=\"notion\">external_id</code> (e.g. Cornelius <code class=\"notion\">auth0|69c3ee8cb9ed562744ff9326</code>).</td><td class=\"\">The bearer's verified <code class=\"notion\">sub</code> claim drives <code class=\"notion\">$token.sub</code> in the policy filter - no body field needed.</td></tr>\n<tr><td class=\"\"><code class=\"notion\">venue_name</code></td><td class=\"\"><code class=\"notion\">Shower-Concert-Hall</code></td><td class=\"\">First Venue in the dataset (<code class=\"notion\">venue-1</code>); has 50 PLAYED_AT tracks and 3 attendees.</td></tr>\n<tr><td class=\"\"><code class=\"notion\">artist_name</code></td><td class=\"\"><code class=\"notion\">ABBA</code></td><td class=\"\">Seeded as <code class=\"notion\">artist-2</code>; has 9 albums and 112 tracks.</td></tr>\n<tr><td class=\"\"><code class=\"notion\">venue_ids</code></td><td class=\"\"><code class=\"notion\">[\"venue-1\",\"venue-2\"]</code></td><td class=\"\">Existing Venue external_ids.</td></tr>\n<tr><td class=\"\"><code class=\"notion\">min_confidence</code> / <code class=\"notion\">min_likes</code> / <code class=\"notion\">min_shared_*</code></td><td class=\"\"><code class=\"notion\">0.7</code> / <code class=\"notion\">1</code></td><td class=\"\">Permissive thresholds that return rows on this dataset.</td></tr>\n</tbody>\n</table>\n\n<h3 class=\"\">Real execute bodies from the collection</h3>\n\n<p class=\"notion\"><strong>Smallest possible Person execute</strong> (<code class=\"notion\">ciq exec kq4</code>, own-profile - the policy has no <code class=\"notion\">$param</code> beyond identity, and identity is supplied by the bearer, so <code class=\"notion\">input_params</code> is empty):</p>\n<pre class=\"code\"><code class=\"language-JSON\">POST /contx-iq/v1/execute\nHeaders:\n  X-IK-ClientKey: {{your_agent_token}}\n  Authorization:  Bearer {{your_user_token}}\n{\n  \"id\": \"{{query_gid}}\",\n  \"input_params\": {},\n  \"page_token\":   1\n}\n</code></pre>\n\n<p class=\"notion\"><strong>Person execute with policy params</strong> (<code class=\"notion\">ciq exec kq14</code>, same-taste):</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"id\": \"{{query_gid}}\",\n  \"input_params\": {\n    \"min_shared_tracks\": 1,\n    \"min_shared_artists\": 1\n  },\n  \"page_token\": 1\n}</code></pre>\n\n<p class=\"notion\"><strong>Application-subject execute</strong> (<code class=\"notion\">ciq exec kq</code>, venue playable tracks - no Bearer header, only the agent key):</p>\n<pre class=\"code\"><code class=\"language-JSON\">POST /contx-iq/v1/execute\nHeaders:\n  X-IK-ClientKey: {{your_agent_token}}\n{\n  \"id\": \"{{query_gid}}\",\n  \"input_params\": {\n    \"venue_name\": \"Shower-Concert-Hall\"\n  },\n  \"page_token\": 1\n}\n</code></pre>\n\n<h3 class=\"\">Sample response (read execute)</h3>\n<p class=\"notion\">A successful read execute returns <code class=\"notion\">data</code>, one record per matched row, each with a <code class=\"notion\">nodes</code> map keyed by the references the query declared (and a <code class=\"notion\">relationships</code> map when it declares any). There is no page token in the response: a page shorter than <code class=\"notion\">page_size</code> (default 100) is the last one. Example for <code class=\"notion\">ciq exec kq4</code> (read own profile) when authenticated as Cornelius:</p>\n<pre class=\"code\"><code class=\"language-JSON\">{\n  \"data\": [\n    {\n      \"nodes\": {\n        \"subject.property.firstname\": \"Cornelius\",\n        \"subject.property.lastname\": \"Pickleworth\",\n        \"subject.property.email\": \"cornelius@pickleworth.com\",\n        \"subject.property.age\": 14,\n        \"subject.property.city\": \"Ctrl-Z Canyon\",\n        \"subject.property.state\": \"Texas\",\n        \"subject.property.music_mood\": \"Acoustic Sadness\",\n        \"subject.property.karaoke_confidence\": 0.4,\n        \"subject.property.dance_skill\": 0.67,\n        \"subject.property.profession\": \"Professional Homework Avoider\"\n      }\n    }\n  ]\n}</code></pre>\n\n<h3 class=\"\">What happens at execute time</h3>\n<ol type=\"1\" class=\"numbered-list\" start=\"1\">\n<li>The platform looks up the query by <code class=\"notion\">id</code> and resolves its policy.</li>\n<li>It validates that every <code class=\"notion\">$param</code> from the policy's filter is present in <code class=\"notion\">input_params</code> - missing one returns <code class=\"notion\">HTTP 422</code>.</li>\n<li>For Person subjects, it introspects the bearer token, extracts the <code class=\"notion\">sub</code> claim, and uses it as the value of <code class=\"notion\">$token.sub</code> in the policy filter (which then pins the cypher subject to that one Person node).</li>\n<li>It runs the cypher with the params plugged in, then projects only the fields listed in <code class=\"notion\">allowed_reads</code>.</li>\n<li>The result is the policy-scoped subset of the music graph matching the query's projection.</li>\n</ol>\n\n<h3 class=\"\">What to expect when you run them</h3>\n<p class=\"notion\">With the seeded dataset and the recommended test users from Chapter 5, every paired execute returns rows. Predicted row counts (auth as <strong>Cornelius</strong> unless noted):</p>\n<table class=\"simple-table\">\n<tbody>\n<tr><td class=\"simple-table-header-color\"><strong>Group</strong></td><td class=\"simple-table-header-color\"><strong>Executes</strong></td><td class=\"simple-table-header-color\"><strong>Rows</strong></td></tr>\n<tr><td class=\"\">Application catalog (no bearer)</td><td class=\"\"><code class=\"notion\">ciq exec kq</code> / <code class=\"notion\">kqb</code> / <code class=\"notion\">kqc</code></td><td class=\"\">50 tracks at Shower-Concert-Hall</td></tr>\n<tr><td class=\"\"></td><td class=\"\"><code class=\"notion\">ciq exec kq2</code> / <code class=\"notion\">kq2b</code> / <code class=\"notion\">kq2c</code> / <code class=\"notion\">kq2d</code></td><td class=\"\">9 albums + 112 tracks for ABBA</td></tr>\n<tr><td class=\"\"></td><td class=\"\"><code class=\"notion\">ciq exec kq3</code></td><td class=\"\">3 karaoke-ready persons</td></tr>\n<tr><td class=\"\"></td><td class=\"\"><code class=\"notion\">ciq exec kq21</code></td><td class=\"\">3 attendees of Shower-Concert-Hall</td></tr>\n<tr><td class=\"\">Person, self-only</td><td class=\"\"><code class=\"notion\">kq4</code> / <code class=\"notion\">kq4b</code> / <code class=\"notion\">kq17</code> / <code class=\"notion\">kq17b</code> / <code class=\"notion\">kq23</code></td><td class=\"\">1 row (the caller's own profile / properties)</td></tr>\n<tr><td class=\"\">Person, direct relationships</td><td class=\"\"><code class=\"notion\">kq5</code>/b/c (likes), <code class=\"notion\">kq6</code>/b/c/d (playlists), <code class=\"notion\">kq7</code>/b/c (subscriptions), <code class=\"notion\">kq8</code>/b/c (followed artists), <code class=\"notion\">kq9</code>/b/c (venues), <code class=\"notion\">kq14-kq16</code>, <code class=\"notion\">kq18-kq20</code>, <code class=\"notion\">kq24</code></td><td class=\"\">1 - 5 rows each (Cornelius's seeded engagement)</td></tr>\n<tr><td class=\"\">Two-hop (venue / family)</td><td class=\"\"><code class=\"notion\">kq10</code> (family playlists), <code class=\"notion\">kq12</code>, <code class=\"notion\">kq13</code>/b/c, <code class=\"notion\">kq22</code></td><td class=\"\">ROWS</td></tr>\n<tr><td class=\"\">Parent-side query</td><td class=\"\"><code class=\"notion\">kq11</code> (children-likes)</td><td class=\"\">EMPTY for Cornelius (he's a child); switch the bearer to <strong>Marmaduke</strong> (<code class=\"notion\">auth0|69c4129b0ba356c7db9f91ab</code>) and it returns 6 rows.</td></tr>\n</tbody>\n</table>\n<p class=\"notion\">If a Person execute returns zero rows, check (a) the bearer's <code class=\"notion\">sub</code> claim matches a seeded Person external_id and (b) that user actually has the relationship the cypher walks. Most often the answer is \"use Cornelius for music engagement, Marmaduke for parent-side queries\" - see the Chapter 5 test-user table.</p>\n\n<h3 class=\"\">Recommended order</h3>\n<p class=\"notion\">Run each <code class=\"notion\">ciqpolicyN → kqN... → ciq exec ...</code> triplet sequentially so <code class=\"notion\">policy_gid</code> and <code class=\"notion\">query_gid</code> stay in sync. The collection is already sorted that way - just hit \"Run\" and watch the variables rotate.</p>\n\n<h3 class=\"\">You're done</h3>\n<p class=\"notion\">By the end of this chapter you have run every product surface IndyKite exposes against a non-trivial music graph: environment provisioning, capture, KBAC + AuthZEN, Token Introspect, MCP, ContX IQ policies + queries + executes. Re-use these patterns against your own data: keep the variable layout, swap the dataset, adjust the policies.</p>\n\n<h3 class=\"\">Where to go next</h3>\n<ul class=\"bulleted-list\">\n<li style=\"list-style-type:disc\"><a href=\"/guides/guide-trust-score\" class=\"fancy-link\">Trust Score</a> - assess data freshness, origin, and verification.</li>\n<li style=\"list-style-type:disc\"><a href=\"/guides/guide-external-data-resolver\" class=\"fancy-link\">External Data Resolver</a> - pull in external API data during a query.</li>\n<li style=\"list-style-type:disc\"><a href=\"/guides/guide-outbound-events\" class=\"fancy-link\">Outbound Events</a> - stream every IKG change to Kafka, Event Grid, Service Bus, or Pub/Sub.</li>\n</ul>",
      "links": {
        "html": "/tutorials/tutorial-music-dataset#chapter-10",
        "markdown": "/tutorials/tutorial-music-dataset/10.md"
      }
    }
  ],
  "links": {
    "html": "/tutorials/tutorial-music-dataset",
    "markdown": "/tutorials/tutorial-music-dataset.md"
  }
}