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 Wallet 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.

For more information, see Create Adaptive Link in the Wallet API reference.

{
    "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"
            }
        }
    }
}

You can generate passes directly from your Adaptive Link with a GET call to https://wallet-api.urbanairship.com/v1/pass/adaptive/{adaptiveLinkId}.

Request parameters may be appended to the base URL to add or update values on the generated pass. For some specialized query parameters, see Generate pass from Adaptive Link in the Wallet API reference.

In addition to the specialized parameters, you may provide a URL parameter as fieldName=value for any field contained in the templates associated with the Adaptive Link. For example, if you wanted to add an offer code, barcode, tags for time zone and location, and a member ID using an external ID, you could append URL query parameters to a base Adaptive Link URL 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 Wallet class fields with unique values. Any field preceded by class constitutes a class field. See Google Wallet Pass Verticals documentation for a full list of class fields for each pass type.

Adaptive Links support generating multiple passes from a single URL. Combine passes from multiple templates in different projects, even if they are different pass types, to do things like:

  • Provide multiple boarding passes at once for a group of travelers
  • Bundle event tickets with parking passes
  • Include a coupon with a loyalty card download

First, create individual Adaptive Links. Then append up to 10 comma-separated Adaptive Link IDs in this format: https://wallet-api.urbanairship.com/v1/pass/adaptive?ids={adaptiveLinkId},{adaptiveLinkId},{adaptiveLinkId}.

Example multi-pass Adaptive Link URL
https://wallet-api.urbanairship.com/v1/pass/adaptive?ids=7XRMaSpcEQk,Y0E6EXuTx5i,XGMuDpx2RDs

You can distribute the URL to users in the above format. As with any other pass link, you can send multi-pass Adaptive Links to users in numerous ways. See Distribute pass links.

You also have the option to use multi-pass URLs in GET API calls. Use a GET call if you don’t want to serve your users an Adaptive Link. Specify a device type in the GET URL to request a .pkpass or JSON and stream it to the user from your app or website. See Generate multiple passes from a single Adaptive Link in the Wallet API reference.

 Note

  • Multi-pass Adaptive Links do not support query parameters for personalizing passes.
  • An error will be displayed to the end user if a link contains more than 10 Adaptive Link IDs.
  • If a URL contains an invalid, unknown, or mismatched platform, an error will be displayed to the end user. For example, if one ID from an Adaptive Link supports both iOS and Android but another only supports Android, then when a user attempts to download the multi-pass bundle on iOS, the download will not work.
  • If any of the Adaptive Links IDs are expired, the multi-pass link will not work.
  • If there are no available passes remaining for any of the included Adaptive Links, the multi-pass link will not work.