Example API Calls - Apple Wallet

This article provides examples of common API calls for creating and updating Apple Wallet passes.  
Please use this as a guide to begin experimenting with the Urban Airship Reach API for creating passes and using the data that gets returned, especially with regards to the "publicUrl" key.
See our documentation for a complete set of examples.

Making API calls to generate Apple Wallet passes

The below example API call will create a single pass, provide a download URL to allow a single iOS device to download that .pkpass file and install.

curl -X POST https://reach-api.urbanairship.com/v1/pass/123 \
    -H "Authorization: Basic " \
    -H "Content-Type: application/json" \
    -H "Api-Revision: 1.2" \
    -d '{
           "headers": {
               "expirationDate": {
                  "value": "2014-08-20T9:41-08:00"
                }
           },
           "fields": {
               "Text": {
                  "changeMessage": "edited text value",
                  "value": "Text Value",
                  "label": "Text Label"
               },
           "publicURL": {
               "type": "single"
           }
        }'

 

The above API call returns approximately the following data:

{
   "createdAt":"2016-04-26T03:17:49Z",
   "headers":{
      "suppress_strip_shine":{
         "changeMessage":null,
         "label":"",
         "hideEmpty":false,
         "formatType":"String",
         "value":"",
         "fieldType":"topLevel",
         "required":false
      }
   },
   "serialNumber":"68e073a0-e241-4b40-94c7-111111111111",
   "publicUrl":{
      "path":"https:\/\/wallet-api.urbanairship.com\/v1\/download\/pass\/4dfd61cf-7587-49ff-b678-268462d419a9",
      "image":"https:\/\/wallet-api.urbanairship.com\/v1\/download\/pass\/4dfd61cf-7587-49ff-b678-268462d419a9.png",
      "type":"Single"
   },
   "id":"123456789876",
   "templateId":"12345656",
   "fields":{
      "Details":{
         "changeMessage":"",
         "label":"Coupon Details",
         "hideEmpty":false,
         "formatType":"String",
         "value":"very special info",
         "fieldType":"secondary",
         "required":false,
         "order":3
      }
   },
   "url":"https:\/\/wallet-api.urbanairship.com\/v1\/pass\/13282815\/download",
   "updatedAt":"2016-04-26T03:17:49Z",
   "tags":[
      
   ],
   "status":"not_been_installed"
}

 

 

An important key returned in the above .json is the publicUrl key: 


   "publicUrl":{
      "path":"https:\/\/wallet-api.urbanairship.com\/v1\/download\/pass\/4dfd61cf-7587-49ff-b678-268462d419a9",
      "image":"https:\/\/wallet-api.urbanairship.com\/v1\/download\/pass\/4dfd61cf-7587-49ff-b678-268462d419a9.png",
      "type":"Single"
   }

 

Within the publicUrl key are three main pieces of data:

  • Path: For passes created with a publicUrl key, this will be the public download URL for this generated pass.  
  • Image: A url to download a preview image of the pass.
  • Type: A pass can be of type "Single" where it is allowed to be installed to one device or of type "Multiple" where it can be installed to any number of devices.

 

Related content:

Was this article helpful?
0 out of 0 found this helpful
Submit a request