> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blinkops.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Query

Run a read-only SQL query against the CyberArk Identity directory tables, such as `User`, `Role`, and `Proxy`. Use it to resolve usernames and role names into the unique IDs that the other actions take.

**Note**: This endpoint reads data only. It cannot create or modify records.

**Required Permissions**:

* `Report Management`

<Note>
  External Documentation

  To learn more, visit the [CyberArk - Idira Identity documentation](https://docs.cyberark.com/snapshot/identity/en/content/developer/use-queries.htm).
</Note>

## Parameters

<div className="integrations-table">
  | Parameter        | Description                                                                                                                                                                                                                                                                  |
  | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | Caching          | The caching mode for the query results.<br /><br />\* `-1` — return live data, but write the results to the cache.<br />\* Less than `-1` — do not read from or write to the cache.<br />\* `0` — read and write the cache, using the configured caching minutes as the TTL. |
  | Limit            | The maximum number of results to return for the specified page.                                                                                                                                                                                                              |
  | Page Number      | The number of the specific page of results to return.                                                                                                                                                                                                                        |
  | Page Size        | The number of entities to return per page.                                                                                                                                                                                                                                   |
  | Return All Pages | Automatically fetch all resources, page by page.                                                                                                                                                                                                                             |
  | SQL Query        | The SQL query to run. Only read queries are supported.<br /><br />**For Example:** `Select ID, Username from User ORDER BY Username COLLATE NOCASE`                                                                                                                          |
  | Sort Ascending   | Select to sort the results in ascending order. When cleared, the results are sorted in descending order.                                                                                                                                                                     |
  | Sort By          | A comma-separated list of the column names to sort the results by.                                                                                                                                                                                                           |
</div>

## Example Output

```json theme={"dark"}
{
	"success": false,
	"Result": {
		"IsAggregate": false,
		"Count": 0,
		"FullCount": 0,
		"Columns": [
			{
				"Name": "",
				"IsHidden": false,
				"DDName": "",
				"Title": "",
				"DDTitle": "",
				"Description": "",
				"Type": 0,
				"Format": null,
				"Width": 0,
				"TableKey": "",
				"ForeignKey": null
			}
		],
		"Results": [
			{
				"Entities": [
					{
						"Type": "",
						"Key": "",
						"IsForeignKey": false
					}
				],
				"Row": {}
			}
		],
		"ReturnID": ""
	},
	"Message": "",
	"MessageID": "",
	"Exception": "",
	"ErrorID": "",
	"ErrorCode": "",
	"InnerExceptions": "",
	"IsSoftError": false
}
```

## Workflow Library Example

[Run Query with Cyberark   Idira Identity and Send Results Via Email](https://library.blinkops.com/workflows/run-query-with-cyberark---idira-identity-and-send-results-via-email)

<div className="iframe-wrapper">
  <div className="iframe-media">
    <img src="https://mintcdn.com/blinkops-2/ojHYuDeYX5FWuN8a/img/Icons/play-box.svg?fit=max&auto=format&n=ojHYuDeYX5FWuN8a&q=85&s=b8af968e71438a9499c3223c9bd29fb2" alt="Workflow Library" width="16" height="16" data-path="img/Icons/play-box.svg" />

    Preview this Workflow on desktop
  </div>

  <iframe className="iframe" src="https://library.blinkops.com/workflows/run-query-with-cyberark---idira-identity-and-send-results-via-email/canvas" />
</div>
