Send an IM with UCWA - Step 2 - Creating the Application

The first step when creating a new UCWA is to initialise an Application - a two way modality between your Lync user account and an intended recipient.

Thursday, 29 January 2015


The first step in sending an IM is to create the "Application". The Application is a collection of events and resources that provide the ability to control most aspects of the Lync experience, including sending Instant Messages.

In this tutorial we'll only focus on sending an IM, however the Application can provide access to contacts, meetings, schedules, presence subscriptions and much more. Head over to for the full API reference.


Process Flow

Send An IM With UCWA - Creating the Application


Initial Steps

The process to create an Application follows a linear progression through three steps.

  • Connecting to Lync 2013 server
  • Authenticating the User
  • Creating the Application


Connecting to Lync 2013 server

The first step is to send a GET request to your server's autodiscovery URL. The URL is configured when you deploy your Lync environment, and is typically in the format below:

Information: All communication with UCWA, and your Lync servers, is performed via HTTPS. It is important to ensure your Edge Server certificates are valid to avoid errors.

Once you have sent this post, UCWA will then return a set of values in JSON format, containing the user (Authentication) and xframe URL, which is used for authentication throughout the process.


Keep a record of these URLs (and all others returned by UCWA in later steps), as they are used regularly.


Authenticating the User

To authenticate a Lync user account to use UCWA, the user URL is passed your authentication details.

The next step is to send an invalid GET to this URL, in order to generate an OAuth token, that is used in all future requests. This is a rather counter-intuitive step, but it works and is documented by Microsoft, so lets go with it.

Send a GET on the user URL

UCWA will then return an OAuth token in the body of the response.


The token shown above is concatenated an just and example, so please don't use it!

UCWA supports multiple authentication methods, but the easiest to use is basic username/password authentication. To Authenticate, simply pass these details as a webticket to UCWA via the base URL returned earlier.

Information: You will notice that the POST data below isn't in JSON format, unlike most other commands.

Send a GET on UCWA


With the POST data being:



  • emailaddress = your Lync Server user's SIP address
  • password = your Lync Server user's password in plain-text

UCWA will then return the following with a HTTP Status Code of 200

Information: HTTP status codes (ie 200 OK) are used throughout the UCWA framework to provide command statuses.

We're nearly there!


Important Step - Including the Access Token

From this point on, all subsequent GET or POSTs must contain the Access Token retrieved above, in the HTTP header.

Depending on your language or framework of choice, the format of the HTTP header string included in future must be in the following format:

Authorization: Bearer cwt=AAEB...buHc

If you are using Microsoft's .NET framework, the webRequest class (from System.Net) has the ability to add custom HTTP Header strings, which will meet this requirement.

C# Example

    WebRequest request = WebRequest.Create("https://...");
    request.Headers.Add("Authorization", "Bearer cwt=AAEB...buHc");

VB.NET Example

    Dim request As WebRequest = WebRequest.Create("https://...")
    request.Headers.Add("Authorization", "Bearer cwt=AAEB...buHc")

The URL and token above have been abbreviated for simplicity. This addition is mandatory, so don't forget.


Creating the Application

Assuming you've provided appropriate credentials and have received a 200 OK response code (Authenticated!), the next step is to start the Application and retrieve the event URLs that will be used throughout your adventure with UCWA.

Send a GET on the user URL again.


UCWA will then return the Application URL, that is used to retrieve the full Application event resource group.


The final step is to send a POST to the applications URL, and store the resources that are returned. You also need to pass JSON data that registers your application.

Send a POST on the xxx URL


With the POST data being:

  "UserAgent":"My UCWA Application",


  • UserAgent = The application user agent. Officially, this property specifies the identity of the application and can specify information about the operating system, but can also just be an arbitrary descriptor.
  • EndpointId = a GUID you can specify. Each application must have a unique EndpointId
  • Culture = The culture and locale information. This property is used to control various language-specific items, such as the language of the online meeting announcement service.

If successful, UCWA will respond with 201 Created, and JSON data representing the entire collection Application event URLs.

  "userAgent":"UCWA Samples",
      "name":"Satya Nadella",
      "uri":"sip:[email protected]",
        "photo":{"href":"/ucwa/oauth/v1/applications/105/photos/[email protected]"}
      "4d221db7-4af0-476b-9443-8bc874283085":"please pass this in a PUT request",

The reference to 105 above is the ApplicationID, and will change for each application you create.


Important Application Resources

Whilst all the resources shown above have their place, these are the most commonly used.

Resource Description
_links.self Base resource for the current Application
_links.event The Events URL increments for each change in modality or activity, and represents the next URL to query in order to get the current Application or Conversation state. Demonstrated in part 5 of this tutorial, used to change the availability and messaging modality.
_embedded.communication.supportedMessageFormats Demonstrated in part 5 of this tutorial, used to change the type of Instant Message permitted, such as Plain Text or HTML.
_embedded.communication.conversations A collection of resources representing status and settings of an IM conversation.
_embedded.communication.startMessaging The event used to begin an IM conversation.





Lync, UCWA, IM, Instant Message, Office 365, Skype for Business, Lync API, Lync SDK
Share with: 

The first step when creating a new UCWA is to initialise an Application - a two way modality between your Lync user account and an intended recipient.

Support this Site

Popular Articles

What is Kutamo?
Kilimanjaro 2023
Kilimanjaro 2015
Kilimanjaro 2013
Australian Postcodes
New Zealand Postcodes
Worldwide City Database

Recent Articles

Favourite Links

Kutamo Studios
Kilimanjar 2023