The Query Builder is fundamental to Rules and Risks, enabling external notifications and enhanced search visibility based on query constraints and conditions. When combined with Webhooks for remediation workflows, these can offer in-the-box tools to begin integrating Veza with external processes.
As Veza does not write changes to your environment, you can use the query builder API to build your own tools and integrate Veza with your internal systems and security processes.
For example, you might use Veza APIs to:
Programmatically detect and add Snowflake users to a role when another role already exists with the required permissions
Progressively query for data resources matching a naming pattern or other condition, and apply tags with the provider's built-in APIs
Discover and alter overly permissive policies granting access to sensitive data
Your Veza success team can offer additional support and access to development tools including a Python SDK. This guide covers some simple examples to help get started with custom queries, including links to additional documentation.
Authentication
To run the provided commands, you'll need to first generate a token from Administration >API Keys. You'll also need to know the base URL of your Veza deployment, such as your-org.veza.com.
Query specifications
You can validate that a query is functioning as intended before saving it with GetAssessmentQuerySpecResult, which will return the total number of entities in the search results.
GetAssessmentQuerySpecNodes returns a paginated list of query results, including entity details. This operation does not return a total count of results. A query spec does not require the full saved query parameters, and instead takes a condensed payload.
GetAssessmentQuerySpecDestinationNodes returns the related destination nodes for a single entity in the results of a saved query. This endpoint can be used, for example, to review the related roles for an individual user when the query specifies User > Role.
Sample Request
Post your request to /query_spec:nodes or /query_spec:result, depending on whether you need a list of the included nodes (including all entity properties), or want the full result count:
The response always returns a value, next_page_token, and has_more. If more results are available, you can get the next page of results by passing the page_token in the request query.
The values array will contain the Individual entity details:
id
Unique Authorization Graph entity ID.
type
Type of entity.
destination_node_count
Number of related entities matching the query conditions.
permissions
For Get destination nodes, the permissions the source entity has to a specific destination entity.
Use GetAssessmentQuerySpecDestinationNodes to find the related entities for an individual result for a query spec. Specify the source_node_id of the entity to get relationships for:
If you want to run the same query repeatedly, or enable Veza Rules or Risks based on the results, you can save it under /assessments/queries.
A saved query includes a name and description, along with any other query parameters.
Get saved query result count or entity details
Use the query ID to run a saved query. Just as for query_spec operations, you can request the paginated entity details or the result count, or get destination nodes for a result: