Create adaptive links using the API

 Note

You must use the API to create adaptive links for event tickets and boarding passes. See:

 Tip

You can take advantage of adaptive links even when supporting a single platform; if a user on the unsupported platform attempts to install your pass, you can send the user to a landing page.

When creating the adaptive link, use ID null for the second template, and make sure to include a value for landingPageUrl.

You must have at least one Apple Wallet and one Google Pay template to create an adaptive link.

Perform a one-time POST API call to https://wallet-api.urbanairship.com/v1/links/adaptive, referring to your template ID. Sample data and JSON parameters are below.

Example
{
    "androidTemplateId": "610213",
    "availablePasses": 100000,
    "iosTemplateId": "581252",
    "isPersonalized": "false",
    "landingPageUrl": "https://airship.com",
    "locationRadius": 10,
    "maxResultLocations": 5,
    "locations": [
        {
            "latitude": 45.5898,
            "longitude": -122.5951,
            "relevantText": "Welcome to Portland... Voodoo Donuts is near..."
        },
        {
            "latitude": 37.7835926,
            "longitude": -122.3982583,
            "relevantText": "Hello Airship SF"
        }
    ],
    "payload": {
        "externalId": null,
        "fields": {
            "offercode": {
                "value": "MJ85SMR"
            }
        },
        "headers": {
            "barcodeAltText": {
                "value": "MJ85SMR"
            },
            "barcode_value": {
                "value": "MJ85SMR"
            }
        }
    }
}

If you set the parameterEncoding parameter on your adaptive link, you can generate passes directly from your adaptive link with a GET call to https://wallet-api.urbanarishp.com/pass/adaptive/{adaptiveLinkId}/{device_type}.

When generating passes this way, you can append request parameters mapping to pass fields to the URL to add or update values to the pass at creation time. You can find a list of reserved parameters and other information about the adaptive link API here. Outside of reserved parameters, you can provide the fieldName=value for any field contained in the adaptive link.

If you configured your Adaptive Link object with the isPersonalized flag set to false (or the flag is absent), the first request will create a pass, and subsequent requests will create new instances of this same pass. If the isPersonalized flag is true, or your request includes URL-encoded parameters, every request will create a new pass.

Example

If you wanted to add an offer code, barcode, member ID, and time/location, you could append query parameters to an adaptive link as follows:

https://wallet-api.urbanairship.com/v1/pass/adaptive/QXynXTbMhS?offercode=AUGUST&barcode=A1234567&tags=PST~OR&exid=A1234567
 Note

You cannot personalize Google Pay class fields with unique values. Any field preceded by class constitutes a class field. See Google Pay Pass Verticals documentation for a full list of class fields for each pass type.