Citrix DaaS REST APIs

How to perform an advanced search for operations in Citrix DaaS

Use REST APIs to perform an advanced search on configuration operations in your Citrix DaaS (formerly Citrix Virtual Apps and Desktops service) site. This enables security auditing and helps to find out the root cause for an unexpected configuration change.

Follow the prerequisites and examples to get started with this API.

You can make API requests using the PowerShell code, C# code, Python, or any tool that supports invoking the REST API.

Prerequisites to perform an advanced search for operations

  • Read the Get started with Citrix Cloud APIs section to ensure that you have the bearer token.
  • Get siteid from How to get site id API.
  • Get the search filters ready.
  • Invoke the API described in this document from a client host or from the API exploration tab to perform an advanced search on configuration operations within the site.

Perform an advanced search for operations using any REST API tool

Learn from the following example to perform an advanced search for operations using any REST API tool.

The following example illustrates how to search for all “Remove Application” operations that were executed by a specific user. For how to perform various searches and sort results, see the API specification.

Request

POST https://api.cloud.com/cvad/manage/ConfigLog/Operations/$search HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
Authorization: CWSAuth bearer=<token-from-prerequisites>
Citrix-CustomerId: loy6oujtu6a4
Citrix-InstanceId: 22ded57c-0306-47e4-b6e8-fed6252759e1

{
    "SearchFilters": [
        {
            "Property": "Text",
            "Value": "Remove Application",
            "Operator": "Contains"
        },
        {
            "Property": "User",
            "Value": "jack.smith@example.com",
            "Operator": "Equals"
        }
    ]
}
<!--NeedCopy-->

Response

HTTP/1.1 200 OK
citrix-transactionid: ce0d3943-e294-4fc8-b2c6-85271d4a0c3b
content-Length: 622
content-Type: application/json; charset=utf-8
date: "Tue, 08 Dec 2020 14:35:08 GMT"
Server: Citrix Systems, Inc.

{
    "Items": [
        {
            "Id": "0d96ecf1-4c73-4a0c-9476-ecbf40289d2b",
            "AdminMachineIP": "",
            "EndTime": "12/21/2020 : 3:21:12 PM",
            "IsSuccessful": true,
            "OperationType": "ConfigurationChange",
            "Parameters": [],
            "Source": "Broker SDK",
            "StartTime": "12/21/2020 : 3:21:12 PM",
            "TargetTypes": [
                "Application"
            ],
            "Text": "Remove Application 'DataExplorer'",
            "User": "jack.smith@example.com"
        },
        {
            "Id": "160bc0d9-48a3-47eb-8012-fee290964017",
            "AdminMachineIP": "",
            "EndTime": "12/21/2020 : 1:48:56 PM",
            "IsSuccessful": true,
            "OperationType": "ConfigurationChange",
            "Parameters": [],
            "Source": "Broker SDK",
            "StartTime": "12/21/2020 : 1:48:56 PM",
            "TargetTypes": [
                "Application"
            ],
            "Text": "Remove Application 'demo'",
            "User": "jack.smith@example.com"
        }
    ],
    "ContinuationToken": "eyJTdGFydGluZ1JlY29yZCI6MywiUmVxdWlyZWRDb3VudCI6MywiQWRkaXRpb25hbERhdGEiOm51bGx9"
}
<!--NeedCopy-->

Perform an advanced search for operations using PowerShell

Learn from the following example to perform an advanced search for operations using any PowerShell code.

function SearchUserOperation {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken,
        [Parameter(Mandatory=$true)]
        [string] $body
    )
    $requestUri = "https://api.cloud.com/cvad/manage/ConfigLog/Operations/`$search"
    $headers = @{
        "Accept" = "application/json";
        "Authorization" = "CWSAuth Bearer=$bearerToken";
        "Citrix-CustomerId" = $customerid;
        "Citrix-InstanceId" = $siteid;
        "Content-Type" = "application/json";
    }
    
    $response = Invoke-RestMethod -Uri $requestUri -Method POST -Headers $headers -Body $body
    return $response
}

$customerId = "customer1"
$siteId = "61603f15-cdf9-4c7f-99ff-91636601a795"
$bearerToken = "ey1.."
$body = @"
{
    "SearchFilters": [
        {
            "Property": "Text",
            "Value": "Remove Application",
            "Operator": "Contains"
        },
        {
            "Property": "User",
            "Value": "jack.smith@example.com",
            "Operator": "Equals"
        }
     ]
}
"@
$response = SearchUserOperation $customerid $siteid $bearerToken $body
<!--NeedCopy-->

Perform an advanced search for operations using C# code

Learn from the following example to perform an advanced search for operations using any C# code.

public static async Task<string> SearchUserOperation(
    string customerid,
    string siteid,
    string bearerToken,
    LogOperationSearchRequestModel model)
{
    var requestUri = "https://api.cloud.com/cvad/manage/ConfigLog/Operations/$search";
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
        client.DefaultRequestHeaders.Add("Citrix-CustomerId", customerid);
        client.DefaultRequestHeaders.Add("Citrix-InstanceId", siteid);
        client.DefaultRequestHeaders.Add("Content-Type", "application/json");
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("CWSAuth Bearer=" + bearerToken);

        var jsonBody = JsonConvert.SerializeObject(model, new JsonSerializerSettings
        {
            Converters = new JsonConverter[] { new StringEnumConverter() }
        });

        var response = await client.PostAsync(requestUri, new StringContent(jsonBody, Encoding.UTF8, "application/json"));

        if (response != null)
        {
            var content = await response.Content.ReadAsStringAsync();
            return content;
        }

        return null;
    }
}
<!--NeedCopy-->

Perform an advanced search for operations using Python

Learn from the following example to perform an advanced search for operations using Python.

import requests 

def search_user_operation(bearerToken, customerid, siteid, operation, username):
    request_uri = "https://api.cloud.com/cvad/manage/ConfigLog/Operations/$search"
    headers = {
                'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
                'Citrix-CustomerId': customerid,
                'Citrix-InstanceId': siteid,
                'Content-Type': 'application/json',
                'Accept': 'application/json'
              }
    payload = json.dumps({
        "SearchFilters": [
            {
                "Property": "Text",
                "Value": operation,
                "Operator": "Contains"
            },
            {
                "Property": "User",
                "Value": username,
                "Operator": "Equals"
            }
        ] 
    })

    response = requests.post(request_uri, headers = headers, verify = False, data = payload)

    return response.json()
<!--NeedCopy-->
Resources
Citrix DaaS REST APIs OpenAPI Specification
Copy Download
How to perform an advanced search for operations in Citrix DaaS