{
  "id": "ciq-15",
  "title": "ContX IQ: Manage Node Property Metadata",
  "description": "Add, update, and query metadata on node properties. Metadata provides additional context like timestamps, sources, confidence scores, or audit information for individual property values.",
  "category": "ContX IQ",
  "tags": [
    "ContX IQ Policy",
    "ContX IQ Query",
    "Metadata",
    "Property Attributes",
    "Data Provenance",
    "Audit Trail"
  ],
  "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 property-level metadata management:\n\nWhat is property metadata?\nAdditional attributes attached to individual property values, not the node itself.\n\nExample:\nNode: Person(name: \"Alice\")\nProperty metadata for \"name\":\n- source: \"HR_System\"\n- confidence: 0.95\n- last_verified: \"2024-01-15\"\n\nOperations demonstrated:\n1. Add metadata to existing property\n2. Create new property with metadata\n3. Query/filter by metadata values",
  "usecase": "Scenario: Track data provenance and quality scores for identity attributes.\n\nInitial state:\nPerson(email: \"alice@example.com\")\n\nAfter metadata upsert:\nPerson(email: \"alice@example.com\")\n  └── metadata:\n      - source: \"email_verification_service\"\n      - verified: true\n      - verification_date: \"2024-01-15\"\n\nUse cases for metadata:\n- Data lineage: Track where data came from\n- Quality scores: Confidence levels for ML-derived data\n- Audit trail: When was data last verified\n- Compliance: GDPR-related tracking\n\nQuery by metadata:\n\"Find all Person nodes where email.verified = true\"",
  "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: For authorized user operations\n\nMetadata structure:\n- Attached to individual properties, not nodes\n- Key-value pairs with any JSON-compatible values\n- Queryable/filterable in ContX IQ",
  "steps": "Step 1: Ingest Base Graph Data\n- Authentication: AppAgent credential (X-IK-ClientKey header)\n- Action: POST nodes and relationships\n- Result: Base graph ready for metadata operations\n\nStep 2: Create Metadata Upsert Policy\n- Authentication: ServiceAccount credential (Bearer token)\n- Action: POST policy allowing:\n  - READ on subject nodes\n  - UPSERT on property metadata\n  - READ on nodes with metadata\n- Result: Policy ID returned\n\nStep 3: Create Metadata Upsert Query\n- Authentication: ServiceAccount credential (Bearer token)\n- Action: POST query that:\n  - Adds metadata to existing property (e.g., email.source)\n  - Creates new property with metadata\n- Result: Query ID returned\n\nStep 4: Execute Metadata Upsert\n- Authentication: AppAgent credential + User token\n- Action: POST to /contx-iq/v1/execute\n- Result: Properties now have metadata attached\n\nStep 5: Create Metadata Filter Query\n- Authentication: ServiceAccount credential (Bearer token)\n- Action: POST query that filters by metadata values\n- Example: Find nodes where property.metadata.source = \"HR_System\"\n- Result: Query ID returned\n\nStep 6: Execute Metadata Filter Query\n- Authentication: AppAgent credential + User token\n- Action: POST to /contx-iq/v1/execute\n- Result: Only nodes matching metadata filter returned",
  "graph": {
    "caption": "The graph the example runs on: 9 nodes (3 Person, 2 Car, 1 Bus, 3 LicenseNumber) and 7 relationships (OWNS, HAS). 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": "name",
            "value": "Alice Smith"
          }
        ]
      },
      {
        "external_id": "satchmo",
        "type": "Person",
        "is_identity": true,
        "properties": [
          {
            "type": "email",
            "value": "satchmo@demo.com"
          },
          {
            "type": "name",
            "value": "Louis Armstrong"
          }
        ]
      },
      {
        "external_id": "karel",
        "type": "Person",
        "is_identity": true,
        "properties": [
          {
            "type": "email",
            "value": "karel@demo.com"
          },
          {
            "type": "name",
            "value": "Karel Plihal"
          }
        ]
      },
      {
        "external_id": "kitt",
        "type": "Car",
        "is_identity": false,
        "properties": [
          {
            "type": "manufacturer",
            "value": "pontiac"
          },
          {
            "type": "model",
            "value": "Firebird"
          }
        ]
      },
      {
        "external_id": "caddilacv16",
        "type": "Car",
        "is_identity": false,
        "properties": [
          {
            "type": "manufacturer",
            "value": "Caddilac"
          },
          {
            "type": "model",
            "value": "V-16"
          }
        ]
      },
      {
        "external_id": "harmonika",
        "type": "Bus",
        "is_identity": false,
        "properties": [
          {
            "type": "manufacturer",
            "value": "Ikarus"
          },
          {
            "type": "model",
            "value": "280"
          }
        ]
      },
      {
        "external_id": "ln-xxx",
        "type": "LicenseNumber",
        "is_identity": false,
        "properties": [
          {
            "type": "license",
            "value": "ln-xxx-value"
          }
        ]
      },
      {
        "external_id": "ln-yyy",
        "type": "LicenseNumber",
        "is_identity": false,
        "properties": [
          {
            "type": "license",
            "value": "ln-yyy-value"
          }
        ]
      },
      {
        "external_id": "ln-zzz",
        "type": "LicenseNumber",
        "is_identity": false,
        "properties": [
          {
            "type": "license",
            "value": "ln-zzz-value"
          }
        ]
      }
    ],
    "relationships": [
      {
        "source": "alice",
        "target": "kitt",
        "type": "OWNS",
        "properties": [
          {
            "type": "weight",
            "value": 1
          }
        ]
      },
      {
        "source": "alice",
        "target": "caddilacv16",
        "type": "OWNS",
        "properties": [
          {
            "type": "weight",
            "value": 2
          }
        ]
      },
      {
        "source": "satchmo",
        "target": "caddilacv16",
        "type": "OWNS",
        "properties": []
      },
      {
        "source": "karel",
        "target": "harmonika",
        "type": "OWNS",
        "properties": []
      },
      {
        "source": "kitt",
        "target": "ln-xxx",
        "type": "HAS",
        "properties": [
          {
            "type": "weight",
            "value": 3
          }
        ]
      },
      {
        "source": "caddilacv16",
        "target": "ln-zzz",
        "type": "HAS",
        "properties": []
      },
      {
        "source": "harmonika",
        "target": "ln-yyy",
        "type": "HAS",
        "properties": []
      }
    ]
  },
  "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",
            "type": "Person",
            "is_identity": true,
            "properties": [
              {
                "type": "email",
                "value": "alice@email.com"
              },
              {
                "type": "name",
                "value": "Alice Smith"
              }
            ]
          },
          {
            "external_id": "satchmo",
            "type": "Person",
            "is_identity": true,
            "properties": [
              {
                "type": "email",
                "value": "satchmo@demo.com"
              },
              {
                "type": "name",
                "value": "Louis Armstrong"
              }
            ]
          },
          {
            "external_id": "karel",
            "type": "Person",
            "is_identity": true,
            "properties": [
              {
                "type": "email",
                "value": "karel@demo.com"
              },
              {
                "type": "name",
                "value": "Karel Plihal"
              }
            ]
          },
          {
            "external_id": "kitt",
            "type": "Car",
            "is_identity": false,
            "properties": [
              {
                "type": "manufacturer",
                "value": "pontiac"
              },
              {
                "type": "model",
                "value": "Firebird"
              }
            ]
          },
          {
            "external_id": "caddilacv16",
            "type": "Car",
            "is_identity": false,
            "properties": [
              {
                "type": "manufacturer",
                "value": "Caddilac"
              },
              {
                "type": "model",
                "value": "V-16"
              }
            ]
          },
          {
            "external_id": "harmonika",
            "type": "Bus",
            "is_identity": false,
            "properties": [
              {
                "type": "manufacturer",
                "value": "Ikarus"
              },
              {
                "type": "model",
                "value": "280"
              }
            ]
          },
          {
            "external_id": "ln-xxx",
            "type": "LicenseNumber",
            "is_identity": false,
            "properties": [
              {
                "type": "license",
                "value": "ln-xxx-value"
              }
            ]
          },
          {
            "external_id": "ln-yyy",
            "type": "LicenseNumber",
            "is_identity": false,
            "properties": [
              {
                "type": "license",
                "value": "ln-yyy-value"
              }
            ]
          },
          {
            "external_id": "ln-zzz",
            "type": "LicenseNumber",
            "is_identity": false,
            "properties": [
              {
                "type": "license",
                "value": "ln-zzz-value"
              }
            ]
          }
        ]
      }
    },
    {
      "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": "alice",
              "type": "Person"
            },
            "target": {
              "external_id": "kitt",
              "type": "Car"
            },
            "type": "OWNS",
            "properties": [
              {
                "type": "weight",
                "value": 1
              }
            ]
          },
          {
            "source": {
              "external_id": "alice",
              "type": "Person"
            },
            "target": {
              "external_id": "caddilacv16",
              "type": "Car"
            },
            "type": "OWNS",
            "properties": [
              {
                "type": "weight",
                "value": 2
              }
            ]
          },
          {
            "source": {
              "external_id": "satchmo",
              "type": "Person"
            },
            "target": {
              "external_id": "caddilacv16",
              "type": "Car"
            },
            "type": "OWNS"
          },
          {
            "source": {
              "external_id": "karel",
              "type": "Person"
            },
            "target": {
              "external_id": "harmonika",
              "type": "Bus"
            },
            "type": "OWNS"
          },
          {
            "source": {
              "external_id": "kitt",
              "type": "Car"
            },
            "target": {
              "external_id": "ln-xxx",
              "type": "LicenseNumber"
            },
            "type": "HAS",
            "properties": [
              {
                "type": "weight",
                "value": 3
              }
            ]
          },
          {
            "source": {
              "external_id": "caddilacv16",
              "type": "Car"
            },
            "target": {
              "external_id": "ln-zzz",
              "type": "LicenseNumber"
            },
            "type": "HAS"
          },
          {
            "source": {
              "external_id": "harmonika",
              "type": "Bus"
            },
            "target": {
              "external_id": "ln-yyy",
              "type": "LicenseNumber"
            },
            "type": "HAS"
          }
        ]
      }
    },
    {
      "step": "Step 2",
      "description": "Create a CIQ Policy which designates the Subject node, the cypher, the nodes allowed to be upserted and the nodes allowed to be read. ",
      "filename": "policy.json",
      "language": "Json",
      "ingest": {
        "meta": {
          "policy_version": "1.0-ciq"
        },
        "subject": {
          "type": "Person"
        },
        "condition": {
          "cypher": "MATCH (subject:Person)-[:OWNS]->(car:Car)-[:HAS]->(ln:LicenseNumber)",
          "filter": [
            {
              "attribute": "subject.external_id",
              "operator": "=",
              "value": "$token.sub"
            }
          ]
        },
        "allowed_reads": {
          "nodes": [
            "car",
            "ln",
            "car.*",
            "ln.*"
          ]
        },
        "allowed_upserts": {
          "nodes": {
            "existing_nodes": [
              "ln"
            ]
          }
        }
      }
    },
    {
      "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 (subject:Person)-[:OWNS]->(car:Car)-[:HAS]->(ln:LicenseNumber)\",\"filter\":[{\"attribute\":\"subject.external_id\",\"operator\":\"=\",\"value\":\"$token.sub\"}]},\"allowed_reads\":{\"nodes\":[\"car\",\"ln\",\"car.*\",\"ln.*\"]},\"allowed_upserts\":{\"nodes\":{\"existing_nodes\":[\"ln\"]}}}",
        "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 upsert and retrieve properties with metadata on a node. ",
      "filename": "knowledge_query.json",
      "language": "Json",
      "ingest": {
        "nodes": [
          "car",
          "ln.property.status",
          "ln.property.status.metadata.source",
          "ln.property.status.metadata.assurance_level",
          "ln.property.status.metadata.somethingImportant",
          "ln.property.license",
          "ln.property.license.metadata.source"
        ],
        "relationships": [],
        "upsert_nodes": [
          {
            "name": "ln",
            "properties": [
              {
                "type": "status",
                "value": "$status",
                "metadata": [
                  {
                    "type": "source",
                    "value": "$token.iss"
                  },
                  {
                    "type": "assurance_level",
                    "value": 2
                  },
                  {
                    "type": "somethingImportant",
                    "value": "supercoolvalue"
                  }
                ]
              },
              {
                "type": "license",
                "value": "$ln_number",
                "metadata": [
                  {
                    "type": "source",
                    "value": "The government"
                  }
                ]
              }
            ]
          }
        ],
        "filter": {
          "attribute": "ln.external_id",
          "operator": "=",
          "value": "$ln_external_id"
        }
      }
    },
    {
      "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\":[\"car\",\"ln.property.status\",\"ln.property.status.metadata.source\",\"ln.property.status.metadata.assurance_level\",\"ln.property.status.metadata.somethingImportant\",\"ln.property.license\",\"ln.property.license.metadata.source\"],\"relationships\":[],\"upsert_nodes\":[{\"name\":\"ln\",\"properties\":[{\"type\":\"status\",\"value\":\"$status\",\"metadata\":[{\"type\":\"source\",\"value\":\"$token.iss\"},{\"type\":\"assurance_level\",\"value\":2},{\"type\":\"somethingImportant\",\"value\":\"supercoolvalue\"}]},{\"type\":\"license\",\"value\":\"$ln_number\",\"metadata\":[{\"type\":\"source\",\"value\":\"The government\"}]}]}],\"filter\":{\"attribute\":\"ln.external_id\",\"operator\":\"=\",\"value\":\"$ln_external_id\"}}",
        "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 get the newly created property information. ",
      "filename": "POST https://eu.api.indykite.com/contx-iq/v1/execute",
      "language": "Json",
      "ingest": {
        "id": "knowledge_query_gid",
        "input_params": {
          "status": "Valid",
          "ln_number": "ln-xxx-value",
          "ln_external_id": "ln-xxx"
        },
        "page_token": 1
      }
    },
    {
      "description": "CIQ Execution response.",
      "filename": "response.json",
      "language": "Json",
      "ingest": {
        "data": [
          {
            "nodes": {
              "car": {
                "Id": 58,
                "ElementId": "4:a5c213aa-aa4b-4be5-a17a-a677a80ee634:58",
                "Labels": [
                  "Unique",
                  "Resource",
                  "Car"
                ],
                "Props": {
                  "_service": "capture-api",
                  "create_time": "2025-08-13T17:19:43.014Z",
                  "external_id": "kitt",
                  "id": "twixV9zqQniA201VtZdzxw",
                  "type": "Car",
                  "update_time": "2025-08-13T17:20:00.141Z"
                }
              },
              "ln.property.license": "ln-xxx-value",
              "ln.property.license.metadata.source": "The government",
              "ln.property.status": "Valid",
              "ln.property.status.metadata.assurance_level": 2,
              "ln.property.status.metadata.somethingImportant": "supercoolvalue",
              "ln.property.status.metadata.source": "https://issuer_url"
            }
          }
        ]
      }
    },
    {
      "step": "Step 5",
      "description": "Create a CIQ Query in the context of the policy to retrieve property information according to a filter on one of the newly created metadata. ",
      "filename": "knowledge_query.json",
      "language": "Json",
      "ingest": {
        "nodes": [
          "car",
          "ln.property.status",
          "ln.property.status.metadata.source",
          "ln.property.status.metadata.assurance_level"
        ],
        "relationships": [],
        "filter": {
          "attribute": "ln.property.status.metadata.assurance_level",
          "operator": ">=",
          "value": 2
        }
      }
    },
    {
      "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\":[\"car\",\"ln.property.status\",\"ln.property.status.metadata.source\",\"ln.property.status.metadata.assurance_level\"],\"relationships\":[],\"filter\":{\"attribute\":\"ln.property.status.metadata.assurance_level\",\"operator\":\">=\",\"value\":2}}",
        "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 6",
      "description": "Run a CIQ Execution to read the data. ",
      "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": {
              "car": {
                "Id": 16,
                "ElementId": "4:a5c213aa-aa4b-4be5-a17a-a677a80ee634:16",
                "Labels": [
                  "Unique",
                  "Resource",
                  "Car"
                ],
                "Props": {
                  "_service": "capture-api",
                  "create_time": "2025-08-13T14:18:57.565Z",
                  "external_id": "kitt",
                  "id": "ylK0vV4_T2CeCUxpolR7aw",
                  "type": "Car",
                  "update_time": "2025-08-13T14:18:57.565Z"
                }
              },
              "ln.property.status": "Valid",
              "ln.property.status.metadata.assurance_level": 2,
              "ln.property.status.metadata.source": "https://issuer_url"
            }
          }
        ]
      }
    }
  ],
  "links": {
    "html": "/resources/ciq-15",
    "markdown": "/resources/ciq-15.md",
    "openApi": "https://openapi.indykite.com/"
  }
}