{
  "id": "ciq-11",
  "title": "ContX IQ: User Consent Management - How does a user grant and revoke payment access?",
  "description": "Demonstrates user-controlled consent workflows where a Person can authorize a Company to access their payment method, and later revoke that access. Uses user tokens as subjects for self-service data governance.",
  "category": "ContX IQ",
  "tags": [
    "ContX IQ Policy",
    "ContX IQ Query",
    "Consent Management",
    "User Subject",
    "Grant Access",
    "Revoke Access",
    "Payment Method",
    "GDPR"
  ],
  "api": "ContX IQ",
  "language": "Json",
  "lastUpdated": "2026-03-20",
  "openApiEndpoints": [
    "/capture/v1/nodes",
    "/capture/v1/relationships",
    "/configs/v1/authorization-policies",
    "/configs/v1/knowledge-queries",
    "/contx-iq/v1/execute"
  ],
  "relatedGuides": [
    "/guides/guide-contx-iq",
    "/guides/guide-sandbox"
  ],
  "commonErrors": [
    {
      "code": "401",
      "message": "UNAUTHENTICATED",
      "solution": "Check credentials: ServiceAccount Bearer token for config APIs, X-IK-ClientKey for execution"
    },
    {
      "code": "404",
      "message": "NOT_FOUND",
      "solution": "Verify the query/policy ID exists and belongs to your project"
    }
  ],
  "summary": "This example demonstrates user-controlled consent management:\n\nUse case: A Person grants a Company permission to charge their payment method, then later revokes it.\n\nKey concepts:\n1. User authenticates with their token -> becomes the query subject\n2. User can only manage consent for their OWN payment methods\n3. GRANTED relationship represents active consent\n4. Deleting GRANTED relationship revokes consent\n\nOperations:\n- Grant: Create Company -[GRANTED]-> PaymentMethod relationship\n- Revoke: Delete Company -[GRANTED]-> PaymentMethod relationship\n\nThis pattern supports GDPR consent requirements and user self-service.",
  "usecase": "Scenario: alice wants to let City Parking Inc (companyParking) charge her credit card (cb123) for parking.\n\nInitial graph:\nPerson(alice) -[HAS]-> PaymentMethod(cb123)\nCompany(companyParking) -[OFFERS]-> Contract(ct123) <-[ACCEPTED]- Person(alice)\nContract(ct123) -[COVERS]-> Vehicle(car1) -[HAS]-> LicenseNumber(license1)\n(bob has the same shape with kl123, ct234, car2 and license2)\n\nGrant consent workflow:\n1. alice authenticates (token introspected)\n2. alice executes the grant query\n3. Result: Company(companyParking) -[GRANTED]-> PaymentMethod(cb123)\n\nLater, alice revokes consent:\n1. alice authenticates again\n2. alice executes the revoke query\n3. Result: the GRANTED relationship is deleted\n\nAuthorization ensures:\n- alice can only grant/revoke consent for HER payment methods, to a company whose contract she accepted\n- The policy cypher verifies Person -[HAS]-> PaymentMethod and Company -[OFFERS]-> Contract <-[ACCEPTED]- Person\n- Other users cannot modify alice's consents, because the subject is bound to the token's sub claim",
  "requirements": "Prerequisites:\n- ServiceAccount credentials: For creating policies and queries (Bearer token)\n- AppAgent credentials: For data ingestion and query execution (X-IK-ClientKey)\n- User access token: JWT for the Person granting/revoking consent\n\nHow to pass user token:\n- Header: Authorization: Bearer {user_access_token}\n- The token identifies the Person and scopes operations to their data",
  "steps": "Step 1: Ingest Person, PaymentMethod, Contract, Vehicle, LicenseNumber and Company Data\n- Authentication: AppAgent credential (X-IK-ClientKey header)\n- Action: POST Person (alice, bob), PaymentMethod (cb123, kl123), Contract (ct123, ct234), Vehicle (car1, car2), LicenseNumber (license1, license2) and Company (companyParking) nodes\n- Action: POST HAS (Person -> PaymentMethod, Vehicle -> LicenseNumber), ACCEPTED, COVERS and OFFERS relationships\n- Result: Graph ready for consent management\n\nStep 2: Create Consent Grant Policy\n- Authentication: ServiceAccount credential (Bearer token)\n- Action: POST policy with subject type Person, filter subject.external_id = $token.sub, allowing the authenticated Person to:\n  - UPSERT a GRANTED relationship from a Company to their PaymentMethod\n- Authorization path (policy cypher): Company -[OFFERS]-> Contract <-[ACCEPTED]- subject -[HAS]-> PaymentMethod, Contract -[COVERS]-> Vehicle -[HAS]-> LicenseNumber\n- Result: Policy ID returned\n\nStep 3: Create Consent Grant Query\n- Authentication: ServiceAccount credential (Bearer token)\n- Action: POST query that upserts company -[GRANTED]-> payment and returns company.external_id, subject.external_id and payment.external_id\n- Parameters: none; the policy binds the subject to the token sub claim and the graph pattern selects the company\n- Result: Query ID returned\n\nStep 4: Execute Consent Grant (as alice)\n- Authentication: AppAgent credential + alice's token (Bearer header)\n- Action: POST to /contx-iq/v1/execute with empty input_params\n- Result: Company(companyParking) -[GRANTED]-> PaymentMethod(cb123) created; the response returns companyParking, cb123 and alice\n\nStep 5: Create Consent Revoke Policy\n- Authentication: ServiceAccount credential (Bearer token)\n- Action: POST policy with subject type Person, cypher MATCH (company:Company)-[g1:GRANTED]->(payment:PaymentMethod)<-[:HAS]-(subject:Person), filter subject.external_id = $token.sub, allowing the authenticated Person to:\n  - DELETE the GRANTED relationship g1 from a Company to their PaymentMethod\n- Result: Policy ID returned\n\nStep 6: Create Consent Revoke Query\n- Authentication: ServiceAccount credential (Bearer token)\n- Action: POST query with delete_relationships [\"g1\"] that also returns company.external_id, subject.external_id and payment.external_id\n- Parameters: none; the policy binds the subject to the token sub claim and the graph pattern selects the relationship\n- Result: Query ID returned\n\nStep 7: Execute Consent Revoke (as alice)\n- Authentication: AppAgent credential + alice's token (Bearer header)\n- Action: POST to /contx-iq/v1/execute with empty input_params\n- Result: Company(companyParking) -[GRANTED]-> PaymentMethod(cb123) deleted",
  "graph": {
    "caption": "The graph the example runs on: 11 nodes (2 Person, 2 PaymentMethod, 2 Contract, 2 Vehicle, 2 LicenseNumber, 1 Company) and 10 relationships (HAS, ACCEPTED, COVERS, OFFERS). Hover a node for its properties, click it to highlight its neighbourhood.",
    "nodes": [
      {
        "external_id": "alice",
        "type": "Person",
        "is_identity": true,
        "properties": [
          {
            "type": "email",
            "value": "alice@email.com"
          },
          {
            "type": "given_name",
            "value": "Alice"
          },
          {
            "type": "last_name",
            "value": "Smith"
          }
        ]
      },
      {
        "external_id": "bob",
        "type": "Person",
        "is_identity": true,
        "properties": [
          {
            "type": "email",
            "value": "bob@email.com"
          },
          {
            "type": "given_name",
            "value": "Bob"
          }
        ]
      },
      {
        "external_id": "cb123",
        "type": "PaymentMethod",
        "is_identity": false,
        "properties": [
          {
            "type": "payment_name",
            "value": "Credit Card"
          }
        ]
      },
      {
        "external_id": "kl123",
        "type": "PaymentMethod",
        "is_identity": false,
        "properties": [
          {
            "type": "payment_name",
            "value": "Klarna"
          }
        ]
      },
      {
        "external_id": "ct123",
        "type": "Contract",
        "is_identity": false,
        "properties": [
          {
            "type": "category",
            "value": "Parking"
          },
          {
            "type": "status",
            "value": "Active"
          }
        ]
      },
      {
        "external_id": "ct234",
        "type": "Contract",
        "is_identity": false,
        "properties": [
          {
            "type": "category",
            "value": "Parking"
          },
          {
            "type": "status",
            "value": "Active"
          }
        ]
      },
      {
        "external_id": "car1",
        "type": "Vehicle",
        "is_identity": false,
        "properties": [
          {
            "type": "category",
            "value": "Car"
          },
          {
            "type": "is_active",
            "value": true
          },
          {
            "type": "vin",
            "value": "rtfhcnvjt471"
          }
        ]
      },
      {
        "external_id": "car2",
        "type": "Vehicle",
        "is_identity": false,
        "properties": [
          {
            "type": "category",
            "value": "Car"
          },
          {
            "type": "is_active",
            "value": true
          },
          {
            "type": "vin",
            "value": "kdcbfrt178"
          }
        ]
      },
      {
        "external_id": "license1",
        "type": "LicenseNumber",
        "is_identity": false,
        "properties": [
          {
            "type": "status",
            "value": "Active"
          },
          {
            "type": "number",
            "value": "AX123456"
          }
        ]
      },
      {
        "external_id": "license2",
        "type": "LicenseNumber",
        "is_identity": false,
        "properties": [
          {
            "type": "status",
            "value": "Active"
          },
          {
            "type": "number",
            "value": "OL123456"
          }
        ]
      },
      {
        "external_id": "companyParking",
        "type": "Company",
        "is_identity": false,
        "properties": [
          {
            "type": "name",
            "value": "City Parking Inc"
          }
        ]
      }
    ],
    "relationships": [
      {
        "source": "bob",
        "target": "kl123",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "alice",
        "target": "cb123",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "alice",
        "target": "ct123",
        "type": "ACCEPTED",
        "properties": []
      },
      {
        "source": "bob",
        "target": "ct234",
        "type": "ACCEPTED",
        "properties": []
      },
      {
        "source": "ct123",
        "target": "car1",
        "type": "COVERS",
        "properties": []
      },
      {
        "source": "ct234",
        "target": "car2",
        "type": "COVERS",
        "properties": []
      },
      {
        "source": "car1",
        "target": "license1",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "car2",
        "target": "license2",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "companyParking",
        "target": "ct234",
        "type": "OFFERS",
        "properties": []
      },
      {
        "source": "companyParking",
        "target": "ct123",
        "type": "OFFERS",
        "properties": []
      }
    ]
  },
  "graphEnd": {
    "caption": "The dashed GRANTED relationship from companyParking to alice's payment method cb123 is created in step 4 and deleted again in step 7, so the final graph is the initial one. It is drawn to show what the consent looked like while it existed.",
    "nodes": [
      {
        "external_id": "alice",
        "type": "Person",
        "is_identity": true,
        "properties": [
          {
            "type": "email",
            "value": "alice@email.com"
          },
          {
            "type": "given_name",
            "value": "Alice"
          },
          {
            "type": "last_name",
            "value": "Smith"
          }
        ]
      },
      {
        "external_id": "bob",
        "type": "Person",
        "is_identity": true,
        "properties": [
          {
            "type": "email",
            "value": "bob@email.com"
          },
          {
            "type": "given_name",
            "value": "Bob"
          }
        ]
      },
      {
        "external_id": "cb123",
        "type": "PaymentMethod",
        "is_identity": false,
        "properties": [
          {
            "type": "payment_name",
            "value": "Credit Card"
          }
        ]
      },
      {
        "external_id": "kl123",
        "type": "PaymentMethod",
        "is_identity": false,
        "properties": [
          {
            "type": "payment_name",
            "value": "Klarna"
          }
        ]
      },
      {
        "external_id": "ct123",
        "type": "Contract",
        "is_identity": false,
        "properties": [
          {
            "type": "category",
            "value": "Parking"
          },
          {
            "type": "status",
            "value": "Active"
          }
        ]
      },
      {
        "external_id": "ct234",
        "type": "Contract",
        "is_identity": false,
        "properties": [
          {
            "type": "category",
            "value": "Parking"
          },
          {
            "type": "status",
            "value": "Active"
          }
        ]
      },
      {
        "external_id": "car1",
        "type": "Vehicle",
        "is_identity": false,
        "properties": [
          {
            "type": "category",
            "value": "Car"
          },
          {
            "type": "is_active",
            "value": true
          },
          {
            "type": "vin",
            "value": "rtfhcnvjt471"
          }
        ]
      },
      {
        "external_id": "car2",
        "type": "Vehicle",
        "is_identity": false,
        "properties": [
          {
            "type": "category",
            "value": "Car"
          },
          {
            "type": "is_active",
            "value": true
          },
          {
            "type": "vin",
            "value": "kdcbfrt178"
          }
        ]
      },
      {
        "external_id": "license1",
        "type": "LicenseNumber",
        "is_identity": false,
        "properties": [
          {
            "type": "status",
            "value": "Active"
          },
          {
            "type": "number",
            "value": "AX123456"
          }
        ]
      },
      {
        "external_id": "license2",
        "type": "LicenseNumber",
        "is_identity": false,
        "properties": [
          {
            "type": "status",
            "value": "Active"
          },
          {
            "type": "number",
            "value": "OL123456"
          }
        ]
      },
      {
        "external_id": "companyParking",
        "type": "Company",
        "is_identity": false,
        "properties": [
          {
            "type": "name",
            "value": "City Parking Inc"
          }
        ]
      }
    ],
    "relationships": [
      {
        "source": "bob",
        "target": "kl123",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "alice",
        "target": "cb123",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "alice",
        "target": "ct123",
        "type": "ACCEPTED",
        "properties": []
      },
      {
        "source": "bob",
        "target": "ct234",
        "type": "ACCEPTED",
        "properties": []
      },
      {
        "source": "ct123",
        "target": "car1",
        "type": "COVERS",
        "properties": []
      },
      {
        "source": "ct234",
        "target": "car2",
        "type": "COVERS",
        "properties": []
      },
      {
        "source": "car1",
        "target": "license1",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "car2",
        "target": "license2",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "companyParking",
        "target": "ct234",
        "type": "OFFERS",
        "properties": []
      },
      {
        "source": "companyParking",
        "target": "ct123",
        "type": "OFFERS",
        "properties": []
      },
      {
        "source": "companyParking",
        "target": "cb123",
        "type": "GRANTED",
        "transient": true
      }
    ]
  },
  "code": [
    {
      "step": "Step 1",
      "description": "Capture the nodes needed for this use case.",
      "filename": "POST https://eu.api.indykite.com/capture/v1/nodes/",
      "language": "Json",
      "ingest": {
        "nodes": [
          {
            "external_id": "alice",
            "is_identity": true,
            "type": "Person",
            "properties": [
              {
                "type": "email",
                "value": "alice@email.com"
              },
              {
                "type": "given_name",
                "value": "Alice"
              },
              {
                "type": "last_name",
                "value": "Smith"
              }
            ]
          },
          {
            "external_id": "bob",
            "type": "Person",
            "is_identity": true,
            "properties": [
              {
                "type": "email",
                "value": "bob@email.com"
              },
              {
                "type": "given_name",
                "value": "Bob"
              }
            ]
          },
          {
            "external_id": "cb123",
            "type": "PaymentMethod",
            "properties": [
              {
                "type": "payment_name",
                "value": "Credit Card"
              }
            ]
          },
          {
            "external_id": "kl123",
            "type": "PaymentMethod",
            "properties": [
              {
                "type": "payment_name",
                "value": "Klarna"
              }
            ]
          },
          {
            "external_id": "ct123",
            "type": "Contract",
            "properties": [
              {
                "type": "category",
                "value": "Parking"
              },
              {
                "type": "status",
                "value": "Active"
              }
            ]
          },
          {
            "external_id": "ct234",
            "type": "Contract",
            "properties": [
              {
                "type": "category",
                "value": "Parking"
              },
              {
                "type": "status",
                "value": "Active"
              }
            ]
          },
          {
            "external_id": "car1",
            "type": "Vehicle",
            "properties": [
              {
                "type": "category",
                "value": "Car"
              },
              {
                "type": "is_active",
                "value": true
              },
              {
                "type": "vin",
                "value": "rtfhcnvjt471"
              }
            ]
          },
          {
            "external_id": "car2",
            "type": "Vehicle",
            "properties": [
              {
                "type": "category",
                "value": "Car"
              },
              {
                "type": "is_active",
                "value": true
              },
              {
                "type": "vin",
                "value": "kdcbfrt178"
              }
            ]
          },
          {
            "external_id": "license1",
            "type": "LicenseNumber",
            "properties": [
              {
                "type": "status",
                "value": "Active"
              },
              {
                "type": "number",
                "value": "AX123456",
                "metadata": {
                  "assurance_level": 3,
                  "source": "BRREG"
                }
              }
            ]
          },
          {
            "external_id": "license2",
            "type": "LicenseNumber",
            "properties": [
              {
                "type": "status",
                "value": "Active"
              },
              {
                "type": "number",
                "value": "OL123456",
                "metadata": {
                  "assurance_level": 3,
                  "source": "BRREG"
                }
              }
            ]
          },
          {
            "external_id": "companyParking",
            "type": "Company",
            "properties": [
              {
                "type": "name",
                "value": "City Parking Inc"
              }
            ]
          }
        ]
      }
    },
    {
      "description": "Capture the relationships needed for this use case.",
      "filename": "POST https://eu.api.indykite.com/capture/v1/relationships/",
      "language": "Json",
      "ingest": {
        "relationships": [
          {
            "source": {
              "external_id": "bob",
              "type": "Person"
            },
            "target": {
              "external_id": "kl123",
              "type": "PaymentMethod"
            },
            "type": "HAS"
          },
          {
            "source": {
              "external_id": "alice",
              "type": "Person"
            },
            "target": {
              "external_id": "cb123",
              "type": "PaymentMethod"
            },
            "type": "HAS"
          },
          {
            "source": {
              "external_id": "alice",
              "type": "Person"
            },
            "target": {
              "external_id": "ct123",
              "type": "Contract"
            },
            "type": "ACCEPTED"
          },
          {
            "source": {
              "external_id": "bob",
              "type": "Person"
            },
            "target": {
              "external_id": "ct234",
              "type": "Contract"
            },
            "type": "ACCEPTED"
          },
          {
            "source": {
              "external_id": "ct123",
              "type": "Contract"
            },
            "target": {
              "external_id": "car1",
              "type": "Vehicle"
            },
            "type": "COVERS"
          },
          {
            "source": {
              "external_id": "ct234",
              "type": "Contract"
            },
            "target": {
              "external_id": "car2",
              "type": "Vehicle"
            },
            "type": "COVERS"
          },
          {
            "source": {
              "external_id": "car1",
              "type": "Vehicle"
            },
            "target": {
              "external_id": "license1",
              "type": "LicenseNumber"
            },
            "type": "HAS"
          },
          {
            "source": {
              "external_id": "car2",
              "type": "Vehicle"
            },
            "target": {
              "external_id": "license2",
              "type": "LicenseNumber"
            },
            "type": "HAS"
          },
          {
            "source": {
              "external_id": "companyParking",
              "type": "Company"
            },
            "target": {
              "external_id": "ct234",
              "type": "Contract"
            },
            "type": "OFFERS"
          },
          {
            "source": {
              "external_id": "companyParking",
              "type": "Company"
            },
            "target": {
              "external_id": "ct123",
              "type": "Contract"
            },
            "type": "OFFERS"
          }
        ]
      }
    },
    {
      "step": "Step 2",
      "description": "Create a CIQ Policy which designates a relationship between a PaymentMethod and a Company can be upserted. ",
      "filename": "policy.json",
      "language": "Json",
      "ingest": {
        "meta": {
          "policy_version": "1.0-ciq"
        },
        "subject": {
          "type": "Person"
        },
        "condition": {
          "cypher": "MATCH (company:Company)-[:OFFERS]->(contract:Contract)<-[:ACCEPTED]-(subject:Person)-[:HAS]->(payment:PaymentMethod), (contract)-[:COVERS]->(vehicle:Vehicle)-[:HAS]->(ln:LicenseNumber)",
          "filter": [
            {
              "attribute": "subject.external_id",
              "operator": "=",
              "value": "$token.sub"
            }
          ]
        },
        "allowed_reads": {
          "nodes": [
            "company.*",
            "subject.*",
            "payment.*"
          ]
        },
        "allowed_upserts": {
          "relationships": {
            "relationship_types": [
              {
                "type": "GRANTED",
                "source_node_label": "Company",
                "target_node_label": "PaymentMethod"
              }
            ]
          }
        }
      }
    },
    {
      "description": "Request to create the CIQ Policy configuration using REST.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/authorization-policies",
      "language": "Json",
      "ingest": {
        "project_id": "your_project_gid",
        "description": "description of policy",
        "display_name": "policy name",
        "name": "policy-name",
        "policy": "{\"meta\":{\"policy_version\":\"1.0-ciq\"},\"subject\":{\"type\":\"Person\"},\"condition\":{\"cypher\":\"MATCH (company:Company)-[:OFFERS]->(contract:Contract)<-[:ACCEPTED]-(subject:Person)-[:HAS]->(payment:PaymentMethod), (contract)-[:COVERS]->(vehicle:Vehicle)-[:HAS]->(ln:LicenseNumber)\",\"filter\":[{\"attribute\":\"subject.external_id\",\"operator\":\"=\",\"value\":\"$token.sub\"}]},\"allowed_reads\":{\"nodes\":[\"company.*\",\"subject.*\",\"payment.*\"]},\"allowed_upserts\":{\"relationships\":{\"relationship_types\":[{\"type\":\"GRANTED\",\"source_node_label\":\"Company\",\"target_node_label\":\"PaymentMethod\"}]}}}",
        "status": "ACTIVE",
        "tags": []
      }
    },
    {
      "description": "Request to read the CIQ Policy configuration using REST.",
      "filename": "policy_request.json",
      "language": "Json",
      "ingest": {
        "id": "your_policy_configuration_gid"
      }
    },
    {
      "step": "Step 3",
      "description": "Create a CIQ Query in the context of the policy to create a GRANTED relationship between a company and a payment method. ",
      "filename": "knowledge_query.json",
      "language": "Json",
      "ingest": {
        "nodes": [
          "company.external_id",
          "subject.external_id",
          "payment.external_id"
        ],
        "upsert_relationships": [
          {
            "name": "newRel",
            "source": "company",
            "target": "payment",
            "type": "GRANTED"
          }
        ]
      }
    },
    {
      "description": "Request to create a CIQ Query configuration using REST.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/knowledge-queries",
      "language": "Json",
      "ingest": {
        "project_id": "your_project_gid",
        "description": "description of knowledge query",
        "display_name": "knowledge query name",
        "name": "knowledge-query-name",
        "policy_id": "your_policy_gid",
        "query": "{\"nodes\":[\"company.external_id\",\"subject.external_id\",\"payment.external_id\"],\"upsert_relationships\":[{\"name\":\"newRel\",\"source\":\"company\",\"target\":\"payment\",\"type\":\"GRANTED\"}]}",
        "status": "ACTIVE"
      }
    },
    {
      "description": "Read the CIQ Query Configuration.",
      "filename": "GET https://eu.api.indykite.com/configs/v1/knowledge-queries/{id}",
      "language": "Json",
      "ingest": {
        "id": "your_knowledge_query_configuration_gid"
      }
    },
    {
      "step": "Step 4",
      "description": "Run a CIQ Execution to create a GRANTED relationship from the Person access token.  ",
      "filename": "POST https://eu.api.indykite.com/contx-iq/v1/execute",
      "language": "Json",
      "ingest": {
        "id": "knowledge_query_gid",
        "input_params": {},
        "page_token": 1
      }
    },
    {
      "description": "CIQ Execution response.",
      "filename": "response.json",
      "language": "Json",
      "ingest": {
        "data": [
          {
            "nodes": {
              "company.external_id": "companyParking",
              "payment.external_id": "cb123",
              "subject.external_id": "alice"
            }
          }
        ]
      }
    },
    {
      "step": "Step 5",
      "description": "Create a CIQ Policy which designates a relationship between a PaymentMethod and a Company can be deleted. ",
      "filename": "policy.json",
      "language": "Json",
      "ingest": {
        "meta": {
          "policy_version": "1.0-ciq"
        },
        "subject": {
          "type": "Person"
        },
        "condition": {
          "cypher": "MATCH (company:Company)-[g1:GRANTED]->(payment:PaymentMethod)<-[:HAS]-(subject:Person)",
          "filter": [
            {
              "attribute": "subject.external_id",
              "operator": "=",
              "value": "$token.sub"
            }
          ]
        },
        "allowed_reads": {
          "nodes": [
            "company.*",
            "subject.*",
            "payment.*"
          ]
        },
        "allowed_deletes": {
          "relationships": [
            "g1"
          ]
        }
      }
    },
    {
      "description": "Json to create the CIQ Policy configuration using REST.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/authorization-policies",
      "language": "Json",
      "ingest": {
        "project_id": "your_project_gid",
        "description": "description of policy",
        "display_name": "policy name",
        "name": "policy-name",
        "policy": "{\"meta\":{\"policy_version\":\"1.0-ciq\"},\"subject\":{\"type\":\"Person\"},\"condition\":{\"cypher\":\"MATCH (company:Company)-[g1:GRANTED]->(payment:PaymentMethod)<-[:HAS]-(subject:Person)\",\"filter\":[{\"attribute\":\"subject.external_id\",\"operator\":\"=\",\"value\":\"$token.sub\"}]},\"allowed_reads\":{\"nodes\":[\"company.*\",\"subject.*\",\"payment.*\"]},\"allowed_deletes\":{\"relationships\":[\"g1\"]}}",
        "status": "ACTIVE",
        "tags": []
      }
    },
    {
      "description": "Json to read the CIQ Policy configuration using REST.",
      "filename": "policy_request.json",
      "language": "Json",
      "ingest": {
        "id": "your_policy_configuration_gid"
      }
    },
    {
      "step": "Step 6",
      "description": "Create a CIQ Query in the context of the policy to delete a GRANTED relationship between a company and a payment method.",
      "filename": "knowledge_query.json",
      "language": "Json",
      "ingest": {
        "nodes": [
          "company.external_id",
          "subject.external_id",
          "payment.external_id"
        ],
        "delete_relationships": [
          "g1"
        ]
      }
    },
    {
      "description": "Json to create a CIQ Query configuration using REST.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/knowledge-queries",
      "language": "Json",
      "ingest": {
        "project_id": "your_project_gid",
        "description": "description of knowledge query",
        "display_name": "knowledge query name",
        "name": "knowledge-query-name",
        "policy_id": "your_policy_gid",
        "query": "{\"nodes\":[\"company.external_id\",\"subject.external_id\",\"payment.external_id\"],\"delete_relationships\":[\"g1\"]}",
        "status": "ACTIVE"
      }
    },
    {
      "description": "Read the CIQ Query Configuration.",
      "filename": "GET https://eu.api.indykite.com/configs/v1/knowledge-queries/{id}",
      "language": "Json",
      "ingest": {
        "id": "your_knowledge_query_configuration_gid"
      }
    },
    {
      "step": "Step 7",
      "description": "Run a CIQ Execution to delete a GRANTED relationship from the Person access token. ",
      "filename": "POST https://eu.api.indykite.com/contx-iq/v1/execute",
      "language": "Json",
      "ingest": {
        "id": "knowledge_query_gid",
        "input_params": {},
        "page_token": 1
      }
    },
    {
      "description": "CIQ Execution response.",
      "filename": "response.json",
      "language": "Json",
      "ingest": {
        "data": [
          {
            "nodes": {
              "company.external_id": "companyParking",
              "payment.external_id": "cb123",
              "subject.external_id": "alice"
            }
          }
        ]
      }
    }
  ],
  "links": {
    "html": "/resources/ciq-11",
    "markdown": "/resources/ciq-11.md",
    "openApi": "https://openapi.indykite.com/"
  }
}