# ContX IQ: How do I connect system nodes (_Application) to business data?

> Learn how to link auto-generated system nodes (_Application, _AppAgent) to your business data in the knowledge graph. This is essential for using the Application as an authorized subject in ContX IQ queries.

**Category:** ContX IQ  
**API:** ContX IQ  
**Tags:** ContX IQ Policy, ContX IQ Query, Application Linking, _Application Node, System Integration, Write Query
**Last Updated:** 2026-03-20
**OpenAPI Endpoints:** /capture/v1/nodes, /capture/v1/relationships, /configs/v1/authorization-policies, /configs/v1/knowledge-queries, /contx-iq/v1/execute
**Related Guides:** /guides/guide-contx-iq, /guides/guide-sandbox

## Summary

This example demonstrates how to connect system-generated nodes to business data:

Background: When you create an Application and AppAgent in IndyKite:
- _Application node is auto-created in the IKG
- _AppAgent node is auto-created and linked to _Application

Problem: These system nodes are isolated from your business data.

Solution: Use a ContX IQ write query to create relationships:
_Application -[HAS_AGREEMENT_WITH]-> Company

After linking, the Application can:
- Use itself as an authorized subject in queries
- Traverse through business data relationships
- Access data according to graph-based policies

## Use Case

Scenario: Your Application needs to query data on behalf of Company1.

System state after credential creation:
- _Application(app-123) exists (auto-created)
- _AppAgent(agent-456) exists (auto-created)
- Company1, Person, Vehicle nodes exist (your data)
- No connection between _Application and business data

Linking operation:
Create: _Application(app-123) -[HAS_AGREEMENT_WITH]-> Company1

After linking:
- Queries with $_appId filter can match this Application
- Application can traverse to Company1's data (Vehicles, Contracts, etc.)
- Policies based on the HAS_AGREEMENT_WITH path now apply

This is a foundational step for most ContX IQ scenarios.

## Requirements

Prerequisites:
- ServiceAccount credentials: For creating policies and queries (Bearer token)
- AppAgent credentials: For data ingestion and query execution (X-IK-ClientKey)
- Note: The _Application and _AppAgent nodes already exist after credential creation

Required API access:
- POST /capture/v1/nodes/ and /capture/v1/relationships/ (business data)
- POST /configs/v1/authorization-policies (create linking policy)
- POST /configs/v1/knowledge-queries (create linking query)
- POST /contx-iq/v1/execute (execute linking)

## Steps

Step 1: Ingest Business Data
- Authentication: AppAgent credential (X-IK-ClientKey header)
- Action: POST Company, Person, Vehicle nodes and relationships
- Result: Business graph ready (but not connected to _Application)

Step 2: Create Linking Policy
- Authentication: ServiceAccount credential (Bearer token)
- Action: POST policy allowing _Application to create HAS_AGREEMENT_WITH relationships
- Key detail: Uses $_appId filter which auto-resolves to the calling Application's ID
- Result: Policy ID returned

Step 3: Create Linking Query
- Authentication: ServiceAccount credential (Bearer token)
- Action: POST write query that creates _Application -[HAS_AGREEMENT_WITH]-> Company
- The query uses $_appId to reference the subject Application
- Result: Query ID returned

Step 4: Execute Linking
- Authentication: AppAgent credential (X-IK-ClientKey header)
- Action: POST to /contx-iq/v1/execute with the linking query
- Result: _Application is now connected to Company in the graph

Step 5: Cleanup
- Action: DELETE query and policy (the relationship remains in the graph)

## Graph

The graph the example runs on: 18 nodes (3 Person, 2 PaymentMethod, 3 Contract, 3 Vehicle, 3 LicenseNumber, 2 Company, 2 Application) and 17 relationships (HAS, ACCEPTED, COVERS, OWNS, HAS_AGREEMENT_WITH). Hover a node for its properties, click it to highlight its neighbourhood.

- Person `alice` (identity): email=alice@email.com, given_name=Alice, last_name=Smith
- Person `ryan` (identity): email=ryan@yahoo.co.uk, given_name=ryan, last_name=mushu
- Person `tilda` (identity): email=tilda@yahoo.co.uk, given_name=tilda, last_name=mushu
- PaymentMethod `cb123`: payment_name=Credit Card
- PaymentMethod `kl123`: payment_name=Klarna
- Contract `ct123`: category=Insurance, status=Active, number=hfgrten123
- Contract `ct234`: category=Insurance, status=Active, number=hfgrten234
- Contract `ct985`: category=Insurance, status=Active, number=hfgrten985
- Vehicle `car1`: category=Car, is_active=true, vin=rtfhcnvjt471
- Vehicle `car2`: category=Car, is_active=true, vin=kdcbfrt178
- Vehicle `truck1`: category=Truck, is_active=true, vin=sncnrkcldp
- LicenseNumber `license1`: status=Active, number=AX123456
- LicenseNumber `license2`: status=Active, number=OL123456
- LicenseNumber `license3`: status=Active, number=VN123456
- Company `company1`: name=Company1, registration=256314523
- Company `company2`: name=Company2, registration=942365123
- Application `application1`: name=Application
- Application `application2`: name=Application2
- `ryan` -[HAS]-> `cb123`
- `tilda` -[HAS]-> `kl123`
- `alice` -[HAS]-> `cb123`
- `ryan` -[ACCEPTED]-> `ct123`
- `tilda` -[ACCEPTED]-> `ct234`
- `alice` -[ACCEPTED]-> `ct985`
- `ct123` -[COVERS]-> `car1`
- `ct985` -[COVERS]-> `car1`
- `ct234` -[COVERS]-> `truck1`
- `car1` -[HAS]-> `license1`
- `truck1` -[HAS]-> `license2`
- `car2` -[HAS]-> `license3`
- `company1` -[OWNS]-> `car1`
- `company1` -[OWNS]-> `car2`
- `company1` -[OWNS]-> `truck1`
- `application1` -[HAS_AGREEMENT_WITH]-> `company1`
- `application2` -[HAS_AGREEMENT_WITH]-> `company1`

## Code Examples

### Step 1

Capture the nodes needed for this use case.

**POST https://eu.api.indykite.com/capture/v1/nodes/**

```json
{
  "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": "ryan",
      "is_identity": true,
      "type": "Person",
      "properties": [
        {
          "type": "email",
          "value": "ryan@yahoo.co.uk"
        },
        {
          "type": "given_name",
          "value": "ryan"
        },
        {
          "type": "last_name",
          "value": "mushu"
        }
      ]
    },
    {
      "external_id": "tilda",
      "is_identity": true,
      "type": "Person",
      "properties": [
        {
          "type": "email",
          "value": "tilda@yahoo.co.uk"
        },
        {
          "type": "given_name",
          "value": "tilda"
        },
        {
          "type": "last_name",
          "value": "mushu"
        }
      ]
    },
    {
      "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": "Insurance"
        },
        {
          "type": "status",
          "value": "Active"
        },
        {
          "type": "number",
          "value": "hfgrten123",
          "metadata": {
            "assurance_level": 3,
            "source": "BRREG"
          }
        }
      ]
    },
    {
      "external_id": "ct234",
      "type": "Contract",
      "properties": [
        {
          "type": "category",
          "value": "Insurance"
        },
        {
          "type": "status",
          "value": "Active"
        },
        {
          "type": "number",
          "value": "hfgrten234",
          "metadata": {
            "assurance_level": 3,
            "source": "BRREG"
          }
        }
      ]
    },
    {
      "external_id": "ct985",
      "type": "Contract",
      "properties": [
        {
          "type": "category",
          "value": "Insurance"
        },
        {
          "type": "status",
          "value": "Active"
        },
        {
          "type": "number",
          "value": "hfgrten985",
          "metadata": {
            "assurance_level": 3,
            "source": "BRREG"
          }
        }
      ]
    },
    {
      "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": "truck1",
      "type": "Vehicle",
      "properties": [
        {
          "type": "category",
          "value": "Truck"
        },
        {
          "type": "is_active",
          "value": true
        },
        {
          "type": "vin",
          "value": "sncnrkcldp"
        }
      ]
    },
    {
      "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": "license3",
      "type": "LicenseNumber",
      "properties": [
        {
          "type": "status",
          "value": "Active"
        },
        {
          "type": "number",
          "value": "VN123456",
          "metadata": {
            "assurance_level": 3,
            "source": "BRREG"
          }
        }
      ]
    },
    {
      "external_id": "company1",
      "type": "Company",
      "properties": [
        {
          "type": "name",
          "value": "Company1"
        },
        {
          "type": "registration",
          "value": "256314523"
        }
      ]
    },
    {
      "external_id": "company2",
      "type": "Company",
      "properties": [
        {
          "type": "name",
          "value": "Company2"
        },
        {
          "type": "registration",
          "value": "942365123"
        }
      ]
    },
    {
      "external_id": "application1",
      "type": "Application",
      "properties": [
        {
          "type": "name",
          "value": "Application"
        }
      ]
    },
    {
      "external_id": "application2",
      "type": "Application",
      "properties": [
        {
          "type": "name",
          "value": "Application2"
        }
      ]
    }
  ]
}
```


Capture the relationships needed for this use case.

**POST https://eu.api.indykite.com/capture/v1/relationships/**

```json
{
  "relationships": [
    {
      "source": {
        "external_id": "ryan",
        "type": "Person"
      },
      "target": {
        "external_id": "cb123",
        "type": "PaymentMethod"
      },
      "type": "HAS"
    },
    {
      "source": {
        "external_id": "tilda",
        "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": "ryan",
        "type": "Person"
      },
      "target": {
        "external_id": "ct123",
        "type": "Contract"
      },
      "type": "ACCEPTED"
    },
    {
      "source": {
        "external_id": "tilda",
        "type": "Person"
      },
      "target": {
        "external_id": "ct234",
        "type": "Contract"
      },
      "type": "ACCEPTED"
    },
    {
      "source": {
        "external_id": "alice",
        "type": "Person"
      },
      "target": {
        "external_id": "ct985",
        "type": "Contract"
      },
      "type": "ACCEPTED"
    },
    {
      "source": {
        "external_id": "ct123",
        "type": "Contract"
      },
      "target": {
        "external_id": "car1",
        "type": "Vehicle"
      },
      "type": "COVERS"
    },
    {
      "source": {
        "external_id": "ct985",
        "type": "Contract"
      },
      "target": {
        "external_id": "car1",
        "type": "Vehicle"
      },
      "type": "COVERS"
    },
    {
      "source": {
        "external_id": "ct234",
        "type": "Contract"
      },
      "target": {
        "external_id": "truck1",
        "type": "Vehicle"
      },
      "type": "COVERS"
    },
    {
      "source": {
        "external_id": "car1",
        "type": "Vehicle"
      },
      "target": {
        "external_id": "license1",
        "type": "LicenseNumber"
      },
      "type": "HAS"
    },
    {
      "source": {
        "external_id": "truck1",
        "type": "Vehicle"
      },
      "target": {
        "external_id": "license2",
        "type": "LicenseNumber"
      },
      "type": "HAS"
    },
    {
      "source": {
        "external_id": "car2",
        "type": "Vehicle"
      },
      "target": {
        "external_id": "license3",
        "type": "LicenseNumber"
      },
      "type": "HAS"
    },
    {
      "source": {
        "external_id": "company1",
        "type": "Company"
      },
      "target": {
        "external_id": "car1",
        "type": "Vehicle"
      },
      "type": "OWNS"
    },
    {
      "source": {
        "external_id": "company1",
        "type": "Company"
      },
      "target": {
        "external_id": "car2",
        "type": "Vehicle"
      },
      "type": "OWNS"
    },
    {
      "source": {
        "external_id": "company1",
        "type": "Company"
      },
      "target": {
        "external_id": "truck1",
        "type": "Vehicle"
      },
      "type": "OWNS"
    },
    {
      "source": {
        "external_id": "application1",
        "type": "Application"
      },
      "target": {
        "external_id": "company1",
        "type": "Company"
      },
      "type": "HAS_AGREEMENT_WITH"
    },
    {
      "source": {
        "external_id": "application2",
        "type": "Application"
      },
      "target": {
        "external_id": "company1",
        "type": "Company"
      },
      "type": "HAS_AGREEMENT_WITH"
    }
  ]
}
```

### Step 2

Policy which designates the derived query can create the HAS_AGREEMENT_WITH relationship.

**policy.json**

```json
{
  "meta": {
    "policy_version": "1.0-ciq"
  },
  "subject": {
    "type": "_Application"
  },
  "condition": {
    "cypher": "MATCH (subject:_Application) MATCH (company:Company)-[r2:OWNS]->(vehicle:Vehicle)",
    "filter": [
      {
        "operator": "AND",
        "operands": [
          {
            "attribute": "subject.external_id",
            "operator": "=",
            "value": "$_appId"
          },
          {
            "attribute": "company.external_id",
            "operator": "=",
            "value": "$companyID"
          }
        ]
      }
    ]
  },
  "allowed_upserts": {
    "relationships": {
      "relationship_types": [
        {
          "type": "HAS_AGREEMENT_WITH",
          "source_node_label": "_Application",
          "target_node_label": "Company"
        }
      ]
    }
  },
  "allowed_reads": {
    "nodes": [
      "company.*",
      "subject.*"
    ]
  }
}
```


Request to create a CIQ Policy configuration using REST.

**POST https://eu.api.indykite.com/configs/v1/authorization-policies**

```json
{
  "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\":\"_Application\"},\"condition\":{\"cypher\":\"MATCH (subject:_Application) MATCH (company:Company)-[r2:OWNS]->(vehicle:Vehicle)\",\"filter\":[{\"operator\":\"AND\",\"operands\":[{\"attribute\":\"subject.external_id\",\"operator\":\"=\",\"value\":\"$_appId\"},{\"attribute\":\"company.external_id\",\"operator\":\"=\",\"value\":\"$companyID\"}]}]},\"allowed_upserts\":{\"relationships\":{\"relationship_types\":[{\"type\":\"HAS_AGREEMENT_WITH\",\"source_node_label\":\"_Application\",\"target_node_label\":\"Company\"}]}},\"allowed_reads\":{\"nodes\":[\"company.*\",\"subject.*\"]}}",
  "status": "ACTIVE",
  "tags": []
}
```


Request to read the CIQ Policy configuration using REST.

**policy_request.json**

```json
{
  "id": "your_policy_configuration_gid"
}
```

### Step 3

The CIQ Query designates the relationship to upsert. 

**knowledge_query.json**

```json
{
  "nodes": [
    "subject.external_id"
  ],
  "relationships": [
    "r1"
  ],
  "upsert_relationships": [
    {
      "name": "r1",
      "source": "subject",
      "target": "company",
      "type": "HAS_AGREEMENT_WITH"
    }
  ]
}
```


Request to create a CIQ Query configuration using REST.

**POST https://eu.api.indykite.com/configs/v1/knowledge-queries**

```json
{
  "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\":[\"subject.external_id\"],\"relationships\":[\"r1\"],\"upsert_relationships\":[{\"name\":\"r1\",\"source\":\"subject\",\"target\":\"company\",\"type\":\"HAS_AGREEMENT_WITH\"}]}",
  "status": "ACTIVE"
}
```


Read the CIQ Query Configuration.

**GET https://eu.api.indykite.com/configs/v1/knowledge-queries/{id}**

```json
{
  "id": "your_knowledge_query_configuration_gid"
}
```

### Step 4

CIQ Execution request in json format.

**POST https://eu.api.indykite.com/contx-iq/v1/execute**

```json
{
  "id": "ciq_query_gid",
  "input_params": {
    "companyID": "company1"
  }
}
```


CIQ Execution response in json format.

**response.json**

```json
{
  "data": [
    {
      "nodes": {
        "subject.external_id": "application_external_id"
      },
      "relationships": {
        "r1": {
          "Id": 1152932499723124700,
          "ElementId": "5:3a2b09d5-2923-45d7-8453-8b1c698427b0:1152932499723124736",
          "StartId": 0,
          "StartElementId": "4:3a2b09d5-2923-45d7-8453-8b1c698427b0:0",
          "EndId": 15,
          "EndElementId": "4:3a2b09d5-2923-45d7-8453-8b1c698427b0:15",
          "Type": "HAS_AGREEMENT_WITH",
          "Props": {
            "create_time": "2025-06-09T15:12:46.374Z",
            "id": "48BJHS2CTFKcVpD4cUF8IA",
            "update_time": "2025-06-09T15:12:46.374Z"
          }
        }
      }
    },
    {
      "nodes": {
        "subject.external_id": "application_external_id"
      },
      "relationships": {
        "r1": {
          "Id": 1152932499723124700,
          "ElementId": "5:3a2b09d5-2923-45d7-8453-8b1c698427b0:1152932499723124736",
          "StartId": 0,
          "StartElementId": "4:3a2b09d5-2923-45d7-8453-8b1c698427b0:0",
          "EndId": 15,
          "EndElementId": "4:3a2b09d5-2923-45d7-8453-8b1c698427b0:15",
          "Type": "HAS_AGREEMENT_WITH",
          "Props": {
            "create_time": "2025-06-09T15:12:46.374Z",
            "id": "48BJHS2CTFKcVpD4cUF8IA",
            "update_time": "2025-06-09T15:12:46.374Z"
          }
        }
      }
    },
    {
      "nodes": {
        "subject.external_id": "application_external_id"
      },
      "relationships": {
        "r1": {
          "Id": 1152932499723124700,
          "ElementId": "5:3a2b09d5-2923-45d7-8453-8b1c698427b0:1152932499723124736",
          "StartId": 0,
          "StartElementId": "4:3a2b09d5-2923-45d7-8453-8b1c698427b0:0",
          "EndId": 15,
          "EndElementId": "4:3a2b09d5-2923-45d7-8453-8b1c698427b0:15",
          "Type": "HAS_AGREEMENT_WITH",
          "Props": {
            "create_time": "2025-06-09T15:12:46.374Z",
            "id": "48BJHS2CTFKcVpD4cUF8IA",
            "update_time": "2025-06-09T15:12:46.374Z"
          }
        }
      }
    }
  ]
}
```

### Step 5

Delete the CIQ Query.

**DELETE https://eu.api.indykite.com/configs/v1/knowledge-queries/{id}**

```json
{
  "id": "your_knowledge_query_configuration_gid"
}
```


Delete the CIQ Policy.

**DELETE https://eu.api.indykite.com/configs/v1/authorization-policies/{id}**

```json
{
  "id": "your_policy_configuration_gid"
}
```

## Common Errors

### 401: UNAUTHENTICATED

**Solution:** Check credentials: ServiceAccount Bearer token for config APIs, X-IK-ClientKey for execution

### 404: NOT_FOUND

**Solution:** Verify the query/policy ID exists and belongs to your project

---

Source: https://developer.indykite.com/resources/ciq-8