Citrix DaaS REST APIs

How to create a physical machine catalog in Citrix DaaS

Use REST APIs to create a physical machine catalog 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 create a physical 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.
  • Make sure that Citrix Connector has been installed in your domain service.
  • Get the physical machines ready and domain-joined.
  • Invoke the API described in this document from a client host or from the API exploration tab to create a physical machine catalog.

Create a physical machine catalog in your site using any REST API tool

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

Request

POST https://api.cloud.com/cvad/manage/MachineCatalogs 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

{
    "Name": "CVAD_APIs_Physical_MC",
    "AllocationType": "Random",
    "IsRemotePC": false,
    "MachineType": "Physical",
    "MinimumFunctionalLevel": "L7_9",
    "PersistUserChanges": "Discard",
    "ProvisioningType": "Manual",
    "SessionSupport": "MultiSession"
}
<!--NeedCopy-->

Response

HTTP/1.1 200 OK
citrix-transactionid: 9d1ae41f...
content-Length: 582
content-Type: application/json; charset=utf-8
date: "Thu, 17 Sep 2020 06:08:32 GMT"

{
    "AgentVersion": "-",
    "HypervisorConnection": null,
    "OSType": "-",
    "OSVersion": "-",
    "DeliveryGroups": [],
    "Name": "CVAD_APIs_Physical_MC",
    "Id": "87c29b00...",
    "Uid": 2,
    "AllocationType": "Random",
    "AssignedCount": 0,
    "AvailableAssignedCount": 0,
    "AvailableCount": 0,
    "AvailableUnassignedCount": 0,
    "Description": null,
    "IsPowerManaged": false,
    "IsRemotePC": false,
    "JobsInProgress": null,
    "MachineType": "Physical",
    "MinimumFunctionalLevel": "L7_9",
    "HasBeenPromoted": false,
    "HasBeenPromotedFrom": "Unknown",
    "CanRollbackVMImage": false,
    "PersistChanges": "OnLocal",
    "ProvisioningScheme": null,
    "ProvisioningType": "Manual",
    "ProvisioningProgress": null,
    "PvsAddress": null,
    "PvsDomain": null,
    "RemotePCEnrollmentScopes": null,
    "Scopes": [
        {
            "Id": "00000000...",
            "Uid": null,
            "Name": "All",
            "Description": null,
            "IsBuiltIn": true,
            "IsAllScope": true,
            "IsTenantScope": false,
            "TenantId": null,
            "TenantName": null
        }
    ],
    "Tenants": null,
    "SessionSupport": "MultiSession",
    "SharingKind": "Unknown",
    "TotalCount": 0,
    "IsBroken": false,
    "Errors": [],
    "Warnings": [],
    "UnassignedCount": 0,
    "UsedCount": 0,
    "Zone": {
        "Id": "00000000...",
        "Uid": null,
        "Name": "Initial Zone"
    }
}
<!--NeedCopy-->

Create a physical machine catalog in your site using PowerShell

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

function CreateMachineCatalog {
    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/MachineCatalogs"
    $headers = @{
        "Accept" = "application/json";
        "Content-Type"="application/json";
        "Authorization" = "CWSAuth Bearer=$bearerToken";
        "Citrix-CustomerId" = $customerid;
        "Citrix-InstanceId" = $siteid;
    }
    $response = Invoke-RestMethod -Uri $requestUri -Method POST -Headers $headers -Body $body 
    return $response
}

$customerId = "customer1"
$siteId = "61603f15-cdf9-4c7f-99ff-91636601a795"
$bearerToken = "ey1.."
$body = @"
{
    "Name": "CVAD_APIs_Physical_MC",
    "AllocationType": "Random",
    "IsRemotePC": false,
    "MachineType": "Physical",
    "MinimumFunctionalLevel": "L7_9",
    "PersistUserChanges": "Discard",
    "ProvisioningType": "Manual",
    "SessionSupport": "MultiSession"
}
"@
$response = CreateMachineCatalog $customerid $siteid $bearerToken $body
<!--NeedCopy-->

Create a physical machine catalog in your site using C# code

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

public static async Task<string> CreateMachineCatalog(
    string customerid,
    string siteid,
    string bearerToken,
    CreateMachineCatalogRequestModel model)
{
    var requestUri = "https://api.cloud.com/cvad/manage/MachineCatalogs";
    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 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-->

Create a physical machine catalog in your site using Python

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

import requests 

def create_machine_catalog(bearerToken, customerid, siteid):
    request_uri = "https://api.cloud.com/cvad/manage/MachineCatalogs"
    headers = {
                'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
                'Citrix-CustomerId': customerid,
                'Citrix-InstanceId': siteid,
                'Content-Type': 'application/json',
                'Accept': 'application/json'
              }
    payload = json.dumps({
        "Name": "CVAD_APIs_Physical_MC",
        "AllocationType": "Random",
        "IsRemotePC": false,
        "MachineType": "Physical",
        "MinimumFunctionalLevel": "L7_9",
        "PersistUserChanges": "Discard",
        "ProvisioningType": "Manual",
        "SessionSupport": "MultiSession"
    })

    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 create a physical machine catalog in Citrix DaaS