Citrix DaaS REST APIs

How to delete a machine catalog in Citrix DaaS

Use REST APIs to delete a machine catalog within 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 delete a machine catalog

  • 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 nameOrId of the machine catalog from How to get machine catalogs API.
  • Make sure machines in the catalog that you want to delete were removed from the delivery group.
  • Invoke the API described in this document from a client host or from the API exploration tab to delete a machine catalog.

Delete a machine catalog from your site using any REST API tool

Learn from the following example to delete a machine catalog within your Citrix DaaS site using any REST API tool.

Request

DELETE https://api.cloud.com/cvad/manage/MachineCatalogs/{nameOrId} 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 204 NoContent
citrix-transactionid: f408a14a...
content-Type: application/json; charset=utf-8
date: "Thu, 17 Sep 2020 08:52:43 GMT"
<!--NeedCopy-->

Delete a machine catalog from your site using PowerShell

Learn from the following example to delete a machine catalog within your Citrix DaaS site using any PowerShell code.

function DeleteMachineCatalog {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $nameOrId,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken
    )
    $requestUri = [string]::Format("https://api.cloud.com/cvad/manage/MachineCatalogs/{0}", $nameOrId)
    $headers = @{
        "Accept" = "application/json";
        "Authorization" = "CWSAuth Bearer=$bearerToken";
        "Citrix-CustomerId" = $customerid;
        "Citrix-InstanceId" = $siteid;
    }

    $response = Invoke-RestMethod -Uri $requestUri -Method DELETE -Headers $headers 
    return $response
}

$customerId = "customer1"
$siteId = "61603f15-cdf9-4c7f-99ff-91636601a795"
$nameOrId = "56f1cbf3-1cc6-40cd-9c82-c95633ba88bb"
$bearerToken = "ey1.."
$response = DeleteMachineCatalog $customerid $siteid $nameOrId $bearerToken 
<!--NeedCopy-->

Delete a machine catalog from your site using C# code

Learn from the following example to delete a machine catalog within your Citrix DaaS site using any C# code.

public static async Task<string> DeleteMachineCatalog(
    string customerid,
    string siteid,
    string nameOrId,
    string bearerToken)
{
    var requestUri = string.Format("https://api.cloud.com/cvad/manage/MachineCatalogs/{0}", nameOrId);
    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.Authorization = new AuthenticationHeaderValue("CWSAuth Bearer=" + bearerToken);

        var response = await client.DeleteAsync(requestUri);

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

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

Delete a machine catalog from your site using Python

Learn from the following example to delete a machine catalog within your Citrix DaaS site using Python.

import requests 

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

    response = requests.delete(request_uri, headers = headers)

    return response.json()
<!--NeedCopy-->
Resources
Citrix DaaS REST APIs OpenAPI Specification
Copy Download
How to delete a machine catalog in Citrix DaaS