> For the complete documentation index, see [llms.txt](https://docs.veza.com/4yItIzMvkpAvMVFAamTf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.veza.com/4yItIzMvkpAvMVFAamTf/developers/api/query-builder/createassessmentquery.md).

# Save a query

CreateAssessmentQuery saves a new query with the specified conditions. See [Query Parameters](/4yItIzMvkpAvMVFAamTf/developers/api/query-builder/parameters.md) for all available constraints and options. To run a query without saving it, see the **query spec** operations.

{% hint style="warning" %}
If copying JSON query specifications from the Veza UI, change `"query_type": "SYSTEM_CREATED"` to `"query_type": "SOURCE_TO_DESTINATION"` before submitting to this API. The API only accepts `SOURCE_TO_DESTINATION` and `DESTINATION_NODES` for user-created queries.
{% endhint %}

{% openapi src="/files/Aco9gj4MY2XoNiD4zIjr" path="/api/v1/assessments/queries" method="post" %}
[openapi.yaml](https://1967633068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZDkWMxox3pekd0NsZJ%2Fuploads%2Fgit-blob-cc6281c14f1540c934b1093e311ed7cf96bd5aea%2Fopenapi.yaml?alt=media)
{% endopenapi %}

Sample Request:

```bash
curl -X 'POST' \
"$BASE_URL/api/v1/assessments/queries" \
-H "authorization: Bearer $VEZA_TOKEN" \
--data-raw '{
  "query_type": "SOURCE_TO_DESTINATION",
  "source_node_types": {
    "nodes": [
      {
        "node_type": "OktaUser",
        "tags": [],
        "conditions": [],
        "condition_expression": null,
        "node_id": "",
        "excluded_tags": [],
        "count_conditions": [],
        "direct_relationship_only": false,
        "node_type_grouping_constraint": null
      }
    ],
    "nodes_operator": "AND"
  },
  "destination_node_types": null,
  "required_intermediate_node_types": null,
  "avoided_intermediate_node_types": null,
  "raw_permissions": null,
  "effective_permissions": null,
  "customized_variables": [],
  "no_relation": false,
  "snapshot_id": "0",
  "access_filter": null,
  "node_relationship_type": "EFFECTIVE_ACCESS",
  "relates_to_exp": {
    "specs": [
      {
        "node_types": {
          "nodes": [
            {
              "node_type": "SnowflakeRole",
              "tags": [],
              "conditions": [],
              "condition_expression": {
                "specs": [
                  {
                    "fn": "EQ",
                    "property": "id",
                    "value": "dn44266.us-east-2.aws.snowflakecomputing.com/role/BILLING",
                    "not": false,
                    "value_property_name": "",
                    "value_property_from_other_node": false
                  }
                ],
                "child_expressions": [],
                "operator": "AND",
                "not": false
              },
              "node_id": "",
              "excluded_tags": [],
              "count_conditions": [],
              "direct_relationship_only": false,
              "node_type_grouping_constraint": null
            }
          ],
          "nodes_operator": "AND"
        },
        "required_intermediate_node_types": null,
        "avoided_intermediate_node_types": null,
        "raw_permissions": null,
        "effective_permissions": {
          "values": [],
          "operator": "OR"
        },
        "no_relation": false,
        "direction": "ANY_DIRECTION"
      }
    ],
    "child_expressions": [
      {
        "specs": [
          {
            "node_types": {
              "nodes": [
                {
                  "node_type": "SnowflakeRole",
                  "tags": [],
                  "conditions": [],
                  "condition_expression": {
                    "specs": [
                      {
                        "fn": "EQ",
                        "property": "id",
                        "value": "dn44266.us-east-2.aws.snowflakecomputing.com/role/AUDITOR",
                        "not": false,
                        "value_property_name": "",
                        "value_property_from_other_node": false
                      }
                    ],
                    "child_expressions": [],
                    "operator": "AND",
                    "not": false
                  },
                  "node_id": "",
                  "excluded_tags": [],
                  "count_conditions": [],
                  "direct_relationship_only": false,
                  "node_type_grouping_constraint": null
                }
              ],
              "nodes_operator": "AND"
            },
            "required_intermediate_node_types": null,
            "avoided_intermediate_node_types": null,
            "raw_permissions": null,
            "effective_permissions": {
              "values": [],
              "operator": "OR"
            },
            "no_relation": false,
            "direction": "ANY_DIRECTION"
          },
          {
            "node_types": {
              "nodes": [
                {
                  "node_type": "SnowflakeRole",
                  "tags": [],
                  "conditions": [],
                  "condition_expression": {
                    "specs": [
                      {
                        "fn": "EQ",
                        "property": "id",
                        "value": "dn44266.us-east-2.aws.snowflakecomputing.com/role/ROLE_A",
                        "not": false,
                        "value_property_name": "",
                        "value_property_from_other_node": false
                      }
                    ],
                    "child_expressions": [],
                    "operator": "AND",
                    "not": false
                  },
                  "node_id": "",
                  "excluded_tags": [],
                  "count_conditions": [],
                  "direct_relationship_only": false,
                  "node_type_grouping_constraint": null
                }
              ],
              "nodes_operator": "AND"
            },
            "required_intermediate_node_types": null,
            "avoided_intermediate_node_types": null,
            "raw_permissions": null,
            "effective_permissions": {
              "values": [],
              "operator": "OR"
            },
            "no_relation": false,
            "direction": "ANY_DIRECTION"
          }
        ],
        "child_expressions": [],
        "operator": "OR",
        "not": false,
        "and_op_type": "INFERRED"
      }
    ],
    "operator": "AND",
    "not": false,
    "and_op_type": "SOURCE_INTERSECT"
  },
  "path_summary_node_types": null,
  "all_entity_condition": null,
  "page_size": "0",
  "page_token": "",
  "variables": [],
  "name": "Okta Users to Snowflake Roles",
  "description": "SoD",
  "risk_level": "CRITICAL",
  "labels": [
    "another_new_label"
  ],
  "visibility": "PRIVATE"
}'
```

Sample response:

A successful response returns the saved query `id`, and full query specification in a `value` object:

```json
{"id":"c169c41c-2650-4f39-8930-f198f70f892b","value":{"id":"c169c41c-2650-4f39-8930-f198f70f892b","name":"Okta Users to Snowflake Roles","description":"SoD","result_type":"NUMBER","query_type":"SOURCE_TO_DESTINATION","raw_permissions":{"values":[],"operator":"AND"},"effective_permissions":{"values":[],"operator":"AND"},"variables":[],"source_node_types":{"nodes":[{"node_type":"OktaUser","tags":[],"conditions":[],"condition_expression":null,"node_id":"","excluded_tags":[],"count_conditions":[],"direct_relationship_only":false,"node_type_grouping_constraint":null}],"nodes_operator":"AND"},"required_intermediate_node_types":{"nodes":[],"nodes_operator":"AND"},"avoided_intermediate_node_types":{"nodes":[],"nodes_operator":"AND"},"destination_node_types":{"nodes":[],"nodes_operator":"AND"},"no_relation":false,"access_filter":null,"created_by":"e3ac5e6a-1946-4688-82a7-8a607133a1c8","visibility":"PRIVATE","owners":["e3ac5e6a-1946-4688-82a7-8a607133a1c8"],"node_relationship_type":"EFFECTIVE_ACCESS","integration_types":["okta","snowflake"],"labels":["another_new_label"],"created_at":"2023-07-29T19:28:30.908762576Z","updated_at":"2023-07-29T19:28:30.908762576Z","source_type":"OktaUser","destination_types":["SnowflakeRole"],"relates_to_exp":{"specs":[{"node_types":{"nodes":[{"node_type":"SnowflakeRole","tags":[],"conditions":[],"condition_expression":{"specs":[{"fn":"EQ","property":"id","value":"dn44266.us-east-2.aws.snowflakecomputing.com/role/BILLING","not":false,"value_property_name":"","value_property_from_other_node":false}],"child_expressions":[],"operator":"AND","not":false},"node_id":"","excluded_tags":[],"count_conditions":[],"direct_relationship_only":false,"node_type_grouping_constraint":null}],"nodes_operator":"AND"},"required_intermediate_node_types":null,"avoided_intermediate_node_types":null,"raw_permissions":null,"effective_permissions":{"values":[],"operator":"OR"},"no_relation":false,"direction":"ANY_DIRECTION"}],"child_expressions":[{"specs":[{"node_types":{"nodes":[{"node_type":"SnowflakeRole","tags":[],"conditions":[],"condition_expression":{"specs":[{"fn":"EQ","property":"id","value":"dn44266.us-east-2.aws.snowflakecomputing.com/role/AUDITOR","not":false,"value_property_name":"","value_property_from_other_node":false}],"child_expressions":[],"operator":"AND","not":false},"node_id":"","excluded_tags":[],"count_conditions":[],"direct_relationship_only":false,"node_type_grouping_constraint":null}],"nodes_operator":"AND"},"required_intermediate_node_types":null,"avoided_intermediate_node_types":null,"raw_permissions":null,"effective_permissions":{"values":[],"operator":"OR"},"no_relation":false,"direction":"ANY_DIRECTION"},{"node_types":{"nodes":[{"node_type":"SnowflakeRole","tags":[],"conditions":[],"condition_expression":{"specs":[{"fn":"EQ","property":"id","value":"dn44266.us-east-2.aws.snowflakecomputing.com/role/ROLE_A","not":false,"value_property_name":"","value_property_from_other_node":false}],"child_expressions":[],"operator":"AND","not":false},"node_id":"","excluded_tags":[],"count_conditions":[],"direct_relationship_only":false,"node_type_grouping_constraint":null}],"nodes_operator":"AND"},"required_intermediate_node_types":null,"avoided_intermediate_node_types":null,"raw_permissions":null,"effective_permissions":{"values":[],"operator":"OR"},"no_relation":false,"direction":"ANY_DIRECTION"}],"child_expressions":[],"operator":"OR","not":false,"and_op_type":"INFERRED"}],"operator":"AND","not":false,"and_op_type":"SOURCE_INTERSECT"},"all_entity_condition":{"specs":[],"child_expressions":[],"operator":"AND","not":false},"risk_level":"CRITICAL","risk_suppressed_constraints":null,"analysis_type":"UNSET","result":0,"result_evaluated_at":null,"result_evaluated":false}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.veza.com/4yItIzMvkpAvMVFAamTf/developers/api/query-builder/createassessmentquery.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
