Citrix DaaS REST APIs

How to get all policy sets in Citrix DaaS

Use REST APIs to get all policy sets in your Citrix DaaS (formerly Citrix Virtual Apps and Desktops service) site.

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 get all policy sets

  • Read Get started with Citrix Cloud APIs section to ensure that you have the bearer token.
  • Get siteid from How to get site id API.
  • Invoke the API described in this document from a client host or from the API exploration tab to get all policy sets in the site.

Get all policy sets in your site using any REST API tool

Learn from the following example to get all policy sets in your Citrix DaaS site using any REST API tool.

Request

GET https://api.cloud.com/cvad/manage/gpo/policySets 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
<!--NeedCopy-->

Response

HTTP/1.1 200 OK
citrix-transactionid: a50180bc...
content-Length: 752
content-Type: application/json; charset=utf-8
date: "Thu,02 Nov 2023 07:55:48 GMT"
Server: Citrix Systems, Inc.

{
  "items": [
    {
      "policySetGuid": "3ed59fc6...",
      "policySetType": "CustomTemplates",
      "name": "CustomTemplates",
      "description": null,
      "policyCount": 0,
      "scopes": null,
      "isAssigned": false
    },
    {
      "policySetGuid": "af9fce6e...",
      "policySetType": "SitePolicies",
      "name": "DefaultSitePolicies",
      "description": null,
      "policyCount": 1,
      "scopes": [
        "All"
      ],
      "isAssigned": false
    },
    {
      "policySetGuid": "7dedd02d...",
      "policySetType": "SiteTemplates",
      "name": "DefaultSiteTemplates",
      "description": "3",
      "policyCount": 7,
      "scopes": null,
      "isAssigned": false
    },
    {
      "policySetGuid": "ce682aab...",
      "policySetType": "DeliveryGroupPolicies",
      "name": "PS01",
      "description": "PS01",
      "policyCount": 1,
      "scopes": [
        "All"
      ],
      "isAssigned": true
    }
  ]
}
<!--NeedCopy-->

Get all policy sets in your site using PowerShell

Learn from the following example to get all policy sets in your Citrix DaaS site using any PowerShell code.

function GetPolicySets {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken
    )
    $requestUri = "https://api.cloud.com/cvad/manage/gpo/policySets"
    $headers = @{
        "Accept" = "application/json";
        "Authorization" = "CWSAuth Bearer=$bearerToken";
        "Citrix-CustomerId" = $customerid;
        "Citrix-InstanceId" = $siteid;
    }
    
    $response = Invoke-RestMethod -Uri $requestUri -Method Get -Headers $headers 
    return $response
}

$customerid = "n2ypkklgy6cv"
$siteid = "12f7438-bf8e-42ba-b1b3-2eb75d098f57"
$bearerToken = "eyJ..."
$response = GetPolicySets $customerid $siteid $bearerToken 
<!--NeedCopy-->

Get all policy sets in your site using C# code

Learn from the following example to get all policy sets in your Citrix DaaS site using any C# code.

public static async Task<string> GetPolicySets(
    string customerid,
    string siteid,
    string bearerToken)
{
    var requestUri = "https://api.cloud.com/cvad/manage/gpo/policySets";
    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("Authorization", $"CWSAuth Bearer={bearerToken}");

        var response = await client.GetAsync(requestUri);

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

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

Get all policy sets in your site using Python

Learn from the following example to get all policy sets in your Citrix DaaS site using Python.

import json
import requests

def get_policy_sets(bearerToken, customerid, siteid):
    request_uri = "https://api.cloud.com/cvad/manage/gpo/policySets"
    headers = {
                'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
                'Citrix-CustomerId': customerid,
                'Citrix-InstanceId': siteid,
                'Content-Type': 'application/json',
                'Accept': 'application/json'
              }

    response = requests.get(request_uri, headers = headers, verify = False)

    return response.json()
<!--NeedCopy-->
Resources
Citrix DaaS REST APIs OpenAPI Specification
Copy Download
How to get all policy sets in Citrix DaaS