{
  "id": "ciq-list-1",
  "title": "ContX IQ: How do I list the Knowledge Queries of a project?",
  "description": "List the Knowledge Queries of a project with GET /configs/v1/knowledge-queries: a metadata-only list by default, with each query's id, name, display name, description and status, full_fetch=true to include the query text and policy_id, and search= to filter by name, display name or description.",
  "category": "ContX IQ",
  "tags": [
    "ContX IQ",
    "Knowledge Query",
    "Config API",
    "List",
    "full_fetch",
    "search"
  ],
  "api": "ContX IQ",
  "language": "Bash",
  "lastUpdated": "2026-10-28",
  "openApiEndpoints": [
    "/configs/v1/knowledge-queries"
  ],
  "relatedGuides": [
    "/guides/guide-config-api",
    "/guides/guide-contx-iq"
  ],
  "commonErrors": [
    {
      "code": "422",
      "message": "missing field project_id",
      "solution": "project_id is a required query parameter: pass the project GID."
    },
    {
      "code": "401",
      "message": "Invalid ServiceAccount JWT in Authorization header",
      "solution": "The Config API takes a Service Account Bearer token, not an Application Agent credential."
    }
  ],
  "summary": "Knowledge Queries are Config API objects, so they are listed like every other configuration: GET /configs/v1/knowledge-queries with the project in project_id, authenticated with a Service Account Bearer token.\n\nWithout full_fetch=true the list is metadata only. Each item keeps its identifiers, name, display_name, description, status and timestamps, and the heavy fields come back empty: query and policy_id. That is the list to show in a console or to pick a query by name before reading it by id. With full_fetch=true every item carries its complete definition, query included. search= keeps only the items whose name, display name or description contains the text.\n\nEvery item carries its name, the URL-friendly identifier that is unique in the project, so a client can find the query it needs without reading each one by id.",
  "usecase": "Scenario: An admin console lists the Knowledge Queries of a project by name and lets an operator open one. The console fetches the metadata-only list, renders name and display_name, and reads the selected query by id for its definition. A deployment script does the opposite: it lists with full_fetch=true to compare the stored query text with the one in version control, and uses search= to narrow a large project to the queries of one feature.",
  "requirements": "Prerequisites:\n- ServiceAccount credentials: Bearer token in the Authorization header.\n- A project id (project_id) with at least one Knowledge Query.\n\nRequired API access:\n- GET /configs/v1/knowledge-queries",
  "steps": "Step 1: List the Knowledge Queries of the project\n- Action: GET /configs/v1/knowledge-queries?project_id=<gid>.\n- Result: 200 with a data array. Each item carries id, name, display_name, description, project_id, organization_id, status and the create and update fields; query and policy_id are empty because full_fetch was not requested.\n\nStep 2: List with the full definition\n- Action: the same call with full_fetch=true.\n- Result: each item also carries query, the Knowledge Query definition as a JSON string, and policy_id, the ContX IQ policy it runs under.\n\nStep 3: Filter by text\n- Action: add search=<text>.\n- Result: only the items whose name, display name or description contains the text, metadata only unless full_fetch=true is added as well.",
  "code": [
    {
      "step": "Step 1",
      "description": "The metadata-only list. project_id is required.",
      "filename": "GET https://eu.api.indykite.com/configs/v1/knowledge-queries",
      "language": "Bash",
      "code": "curl -sS \"$API_URL/configs/v1/knowledge-queries?project_id=$PROJECT_ID\" \\\n  -H \"Authorization: Bearer $SA_TOKEN\""
    },
    {
      "description": "200: each item names the query; query and policy_id stay empty without full_fetch.",
      "language": "Json",
      "code": "\nHTTP/2 200\n\n{\n  \"data\": [\n    {\n      \"id\": \"gid-of-knowledge-query-1\",\n      \"name\": \"person-license-numbers\",\n      \"display_name\": \"License numbers a person can see\",\n      \"description\": \"Returns the LicenseNumber values the subject may read\",\n      \"project_id\": \"gid-of-project\",\n      \"organization_id\": \"gid-of-organization\",\n      \"status\": \"ACTIVE\",\n      \"policy_id\": \"\",\n      \"query\": \"\",\n      \"create_time\": \"2026-10-20T08:01:12Z\",\n      \"created_by\": \"gid-of-service-account\",\n      \"update_time\": \"2026-10-20T08:01:12Z\",\n      \"updated_by\": \"gid-of-service-account\"\n    },\n    {\n      \"id\": \"gid-of-knowledge-query-2\",\n      \"name\": \"contract-payment-methods\",\n      \"display_name\": \"Payment methods of contracted users\",\n      \"description\": \"\",\n      \"project_id\": \"gid-of-project\",\n      \"organization_id\": \"gid-of-organization\",\n      \"status\": \"ACTIVE\",\n      \"policy_id\": \"\",\n      \"query\": \"\",\n      \"create_time\": \"2026-10-21T14:37:50Z\",\n      \"created_by\": \"gid-of-service-account\",\n      \"update_time\": \"2026-10-21T14:37:50Z\",\n      \"updated_by\": \"gid-of-service-account\"\n    }\n  ]\n}"
    },
    {
      "step": "Step 2",
      "description": "The same list with every field.",
      "filename": "GET https://eu.api.indykite.com/configs/v1/knowledge-queries",
      "language": "Bash",
      "code": "curl -sS \"$API_URL/configs/v1/knowledge-queries?project_id=$PROJECT_ID&full_fetch=true\" \\\n  -H \"Authorization: Bearer $SA_TOKEN\""
    },
    {
      "description": "200: query is the stored Knowledge Query definition as a JSON string, policy_id the policy it runs under.",
      "language": "Json",
      "code": "\nHTTP/2 200\n\n{\n  \"data\": [\n    {\n      \"id\": \"gid-of-knowledge-query-1\",\n      \"name\": \"person-license-numbers\",\n      \"display_name\": \"License numbers a person can see\",\n      \"description\": \"Returns the LicenseNumber values the subject may read\",\n      \"project_id\": \"gid-of-project\",\n      \"organization_id\": \"gid-of-organization\",\n      \"status\": \"ACTIVE\",\n      \"policy_id\": \"gid-of-ciq-policy-1\",\n      \"query\": \"{\\\"nodes\\\":[\\\"ln.property.number\\\"],\\\"filter\\\":{\\\"attribute\\\":\\\"ln.property.number\\\",\\\"operator\\\":\\\"=\\\",\\\"value\\\":\\\"$ln_number\\\"}}\",\n      \"create_time\": \"2026-10-20T08:01:12Z\",\n      \"created_by\": \"gid-of-service-account\",\n      \"update_time\": \"2026-10-20T08:01:12Z\",\n      \"updated_by\": \"gid-of-service-account\"\n    }\n  ]\n}"
    },
    {
      "step": "Step 3",
      "description": "Only the queries whose name, display name or description contains \"license\".",
      "filename": "GET https://eu.api.indykite.com/configs/v1/knowledge-queries",
      "language": "Bash",
      "code": "curl -sS \"$API_URL/configs/v1/knowledge-queries?project_id=$PROJECT_ID&search=license\" \\\n  -H \"Authorization: Bearer $SA_TOKEN\""
    }
  ],
  "links": {
    "html": "/resources/ciq-list-1",
    "markdown": "/resources/ciq-list-1.md",
    "openApi": "https://openapi.indykite.com/"
  }
}