Creating & Viewing Notifications
  • Send notifications to administrators in Citrix Cloud

Send notifications to administrators in Citrix Cloud

Citrix Cloud has a notification feature that sends messages to the administrators using the main console:

figure_1

The notifications can be sent using a REST API call. This could be useful for third parties trying to extend Citrix Cloud functionality.

Prerequisites

Read the prerequisites and ensure that you have the customerId and the bearer token.

Sending the notification

Following is the API call to send notifications:

Request

POST https://api.cloud.com/notifications/ HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: CwsAuth bearer=<token-from-call-to-trust>
Citrix-CustomerId: acme

{
  "destinationAdmin": "*",
  "component": "Citrix Cloud",
  "createdDate": "2018-04-22T21:11:25.006Z",
  "eventId": "768e5756-08bf-47ce-9566-e286887ba734",
  "severity": "Information",
  "priority": "Normal",
  "content": [{
    "languageTag": "en-US",
    "title": "This is a title",
    "description": "This is a description"
  }]
}
<!--NeedCopy-->

Note:

Replace acme above with the ID of the customer in which to raise the notification. Replace createdDate above with the current time in RFC 3339 format. Replace eventId above with a GUID, uniquely generated for each notification that you wish to raise.

Response

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 2623
Content-Type: application/json; charset=utf-8
Date: Fri, 23 Dec 2016 21:53:37 GMT
X-Cws-TransactionId: 6c3db4d6-125f-4ea3-b938-882bc5dc3caf

{
  "destinationAdmin": "*",
  "component": "Citrix Cloud",
  "createdDate": "2018-04-22T21:11:25.006Z",
  "categories": null,
  "severity": "Information",
  "eventId": "768e5756-08bf-47ce-9566-e286887ba734",
  "priority": "Normal",
  "content": [
    {
      "languageTag": "en-US",
      "title": "This is a title",
      "description": "This is a description",
      "detailUri": null
    }
  ],
  "data": null,
  "externalId": null
}
<!--NeedCopy-->

The star (*) in the destinationAdministrators field indicates the notification will be sent to all administrators on the account. Make sure the eventId field is set to a unique GUID for each notification that you wish to raise.

The notification can now be seen on the Citrix Cloud console:

figure_2

C# Example

This example illustrates how to send a notification.

public static async Task<string> SendNotification(
    string bearerToken, string customer, string title, string description)
{
    var client = new HttpClient();
    client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
    client.DefaultRequestHeaders.Authorization =
        new AuthenticationHeaderValue("CwsAuth", "Bearer=" + bearerToken);
    client.DefaultRequestHeaders.Add("Citrix-CustomerId","acme");

    var payload = JsonConvert.SerializeObject(
        new
        {
            destinationAdmin = "*",
            component = "Citrix Cloud",
            createdDate = XmlConvert.ToString(DateTime.UtcNow, XmlDateTimeSerializationMode.Utc),
            eventId = Guid.NewGuid().ToString(),
            severity = "Information",
            priority = "Normal",
            content = new[] {
                new {
                    languageTag = "en-US",
                    title = title,
                    description = description,
                }
            },
         }
    );
    var response = await client.PostAsync(
        "https://api.cloud.com/notifications/",
        new StringContent(payload, Encoding.UTF8, "application/json")
    );

    response.EnsureSuccessStatusCode();

    var content = await response.Content.ReadAsStringAsync();

    // Parsing the JSON content is left as an exercise to the reader.
    // Consult Json.NET documentation on newtonsoft.com for more information.

    return content;
}
<!--NeedCopy-->
Resources
Creating & Viewing Notifications OpenAPI Specification
Copy Download
Send notifications to administrators in Citrix Cloud