Xamarin SDK

Supported Versions

PerimeterX supports the following SDKs:

  • iOS version 9 and higher
  • Android SDK version 21 (5.0 Lollipop) and higher


The PerimeterX Xamarin SDK works by constantly profiling and evaluating device behavior to ensure that the connections to your mobile APIs and services are genuine.

This process is complex and detailed yet only requires initializing a client to manage a set of secure HTTP headers which are added to all HTTP and HTTPS requests made by the mobile application to the origin server.


The following are required to install the PerimeterX Xamarin SDK:

  • Administrative access to the PerimeterX Portal to retrieve the PerimeterX application ID.
  • An active PerimeterX Enforcer.


Download the NuGet Package

Download and install the latest stable PXSdk NuGet package from the NuGet Gallery. You can do this as you would any other NuGet package.

Initialize the PerimeterX SDK

Include the PXSdk namespace in your source file.

using PXSdk;

Retrieve the appropriate IPXClient by calling PXClientFactory.GetPXClient() and call the Start function. You must pass in the PerimeterX App ID.

IPXClient pxClient = PXClientFactory.GetPXClient();

Add all the IPXClient.HttpHeaders to your HTTP request before sending it.

foreach (KeyValuePair<string, string> pair in pxClient.HttpHeaders)
    webRequest.Headers.Add(pair.Key, pair.Value);



It is not recommended for the application to make network calls going through the PerimeterX Enforcer without PerimeterX headers.

If you receive a 403: Unauthorized response, pass in the body of the response (as a string) to the HandleResponse function. The return value is a boolean indicating if the 403 response was due to PerimeterX.

if (httpResponse.StatusCode == 403)
    bool isPXEnforcement = pxClient.HandleResponse(responseBody.ToString());
    if (!isPXEnforcement) {
        // handle 403 responses not resulting from PX enforcement

PXSdk OnCaptchaComplete Event

To trigger certain events when the Captcha has been solved or closed, add a new CaptchaCompleteHandler function to the OnCaptchaComplete event. You can choose what you would like these functions to do based on the resulting PXCaptchaResult and PXCaptchaCancelReason, which are passed as arguments to the function.

pxClient.OnCaptchaComplete += new IPXClient.CaptchaCompleteHandler((result, reason) =>
      // ...