> ## 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).

## Parameters

| Parameter | Description |
| - | - |
| Caching | The caching mode for the query results. \* `-1` — return live data, but write the results to the cache. \* Less than `-1` — do not read from or write to the cache. \* `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. **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. |

## 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
}
```
