Pass2U Pass API User Guide
Pass2U Pass API User Guide
Pass2U Pass API User Guide
Version 2.2.1
2.1 December 10, 2018 Add pass issue and installation event
callbacks to webhook urls
1
Get Started with the Pass API
With Pass2U Pass API v2, we’ve rebuilt this API from the ground up to be simpler,
more consistent, and truly RESTful style without binding to any programming
language. Retailers, marketing companies, advertisers, third party ticket/coupon
providers, or travel agencies, can easily use Pass API to automate the process of
creating and updating mobile coupons, membership cards, punch cards, event
tickets, and travel passes in existing platforms or systems.
2
Fundamental Concepts
The primary concept is that passes are created from issued models. All created
passes are located at unique download URLs which are in form of
https://www.pass2u.net/d/passId
Generated download URLs for passes from API can be distributed through your own
channels to customers(e.g. email, SMS, official website, app, facebook...).
2. Click to select a style you want to distribute to customers. The model’s style
determines the overall default visual appearance of the passes.
3
3. On Model Designer page, you can quickly configure model appearance and
the barcode type. About field type, only Dynamic field (e.g. member name,
email, Individual discount, points, balances, and etc.) can be customized and
used in Pass API. In order to identify and customize this field via Pass API,
the dynamic field should be named with a unique key. Fixed field means all
passes of the model use the same data. Fixed, Points and Credits fields
can’t be used in Pass API.
4
generate unique 8-digit number barcode for every pass automatically by
Pass2U platform, you needn’t specify barcode in Pass2U API.
4. After completing model design, please click Next until the model is issued.
The model appears on the Issuing tab within dashboard and you will get the
Model ID of the model.
5. Use the Model ID to manipulate Pass API. After the pass is created, you will
get the passId in the API response. Please keep it in your system so that
pass can be managed individually.
API Overview
All API URLs referred in the documentation starting with the following endpoint:
https://api.pass2u.net/v2
5
uteName}
Authentication
Pass2U uses 32-characters length of Base64 encoded string as API key to
authenticate request. The API key must be included in all API requests to Pass2U
server in header ''x-api-key'' like the following sample:
x-api-key: e6a45207817bb8e9b1f3e67bb696067c
API key allows access to your private data in Pass2U. It should be kept strictly
confidential and not share with others. If you have to change the API key, please
6
request exceeds the limit, Pass2U will return a 429 error along with a message
corresponding to which limit was exceeded.
These attributes can be customized and updated when using "Create pass" or
"Update pass" API. Followings are replacement rules of visual appearance:
● If you don’t specify any attributes (e.g. logoText) in request payload, the
attributes will be set by model attributes.
● If you specify attributes in request payload, the attributes will be customized
for the pass.
● "Delete pass attribute" API is used to reset pass attribute to the default
attribute of the model.
Type (max
Name Description
length)
7
(2) Associated App Keys
The date and time in ISO 8601 format to indicate when the
expirationDate string (30) pass expires. The value must be a complete date with hours,
minutes, and seconds with time zone. Example:
8
2018-10-18T16:53:00+08:00
backgroundColor string (18) Background color of the pass, specified as an CSS-style RGB
9
xample: rgb(23, 187, 82)
triple. E
logoText string (35) The logoText displayed next to the logo on the pass.
The model style controls which images can be used. The table shows the images
supported by each model style. For details, see Apple Wallet Developer Guide.
10
Image types. Must be one of the following values: icon
type string (35)
(required), logo, strip, background, thumbnail, footer.
You can specify an array of data for up to 10 iBeacons per pass. When the card
holder enters within range of a defined iBeacon, a notification will show on the lock
screen.
array of
An array of beacon objects. Apple Wallet limits the pass to 10
beacons JSON
beacon objects.
objects
proximityUUID string (36) Unique identifier of a Bluetooth Low Energy location beacon.
11
(4) Location Dictionary Keys (Array)
You can specify an array of data for up to 10 locations per pass. When the card
holder enters within range of a defined location, a notification will show on the lock
screen.
Boarding Pass With a large radius, on the order of a thousand meters or closer.
With a small radius, the current location must be on the order of a hundred
Coupon
meters or closer.
Event Ticket With a large radius, on the order of a thousand meters or closer.
With a small radius, the current location must be on the order of a hundred
Store Card
meters or closer.
With a small radius, the current location must be on the order of a hundred
Generic
meters or closer.
array of
An array of location objects. Apple Wallet limits the pass to 10
locations JSON
location objects.
objects
12
Text displayed on the lock screen when the pass is currently
relevantText string (255) relevant. For example, a description of the nearby location
such as "Store nearby on 1st and Main."
an JSON
barcode A JSON object of barcode.
object
Every field has its own attributes. Attributes of a field can be given values when
using "Create pass" or "Update pass" API. Followings are replacement rules of
fields:
● Only Dynamic fields can be given values. A field which is configured as Dynamic
when designing the model is a Dynamic field.
13
● If you don’t specify custom data to fields in API, the default data of the fields
of the model will be used.
● If you don’t specify data to attributes of a field in API, the default attributes of
the field of the model will be used.
● If you specify custom data for a field in API, API will set the custom data to the
field and keep the field data as customized. The field data will not be updated
even if updating the model unless you use "Update pass" API to update the
field data.
● If you want to remove the customized data of the field and reset to the default
field data of the model, please use "Delete custom field" API.
● If you specify an empty value to an attribute of a field (ex: "fields":[
{"key":"field1","label":""} ] "), API will give empty value to the attribute.
14
string
This is a unique identifier for the specified model field that can
key
(100) be defined on Model Designer.
string
label Label text for the field.
(150)
string
Value of the field. It can be a string, ISO 8601 date format as a
value
(5000) string, or number.
Format string for the alert text that is displayed when the pass is
updated. The format string must contain the escape %@, which
changeMessage string (80) is replaced by the field’s new value. For example, "Get changed
to %@". If you don’t specify a change message, the user isn’t
notified when the field changes.
Create pass
Create a unique pass from the specified model by customizing attributes and
Dynamic fields of the model.
URL Structure
Method URL
POST https://api.pass2u.net/v2/models/{modelId}/passes?source={sourceId}
x-api-key: { x-api-key}
Accept: application/json
15
Content-Type: application/json
The membership card have the member’s name, date of birth, member level, profile
photo, expiration date and relevant locations that the member preferred. In addition,
configuring background color to distinguish different member level that are intended
to enhance users' experience. All values provided will replace default values of the
model.
{
"expirationDate":"2018-12-31T23:00:15+08:00",
"foregroundColor":"rgb(51, 50, 46)",
"backgroundColor":"rgb(237, 219, 21)",
"labelColor":"rgb(196, 54, 39)",
"sharingProhibited":true,
"fields":[
{
"key":"name",
"label":"Name",
"value":"Fi-Lin,Chen"
},{
"key":"birth",
"label":"Birth",
"value":"Dec’10 1999"
},
{
"key":"level",
"label":"Level",
"value":"GOLD"
}
],
"barcode":{
"message":"1234567890",
"altText":"1234567890"
},
"images":[
{
16
"type":"thumbnail",
"hex":"d33b9f1426d363340c2946557f173c402cd74014"
}
],
"locations":[
{
"latitude":25.0413093,
"longitude":121.55269329999999,
"relevantText":"Store nearby on 1st and Main."
},
{
"latitude":12.0413093,
"longitude":181.3226,
"relevantText":"Take a break with Bistro Coffee"
}
]}
{
"barcodeMessage":"1234567890",
"modelId":1919,
"passId":"VT-2I77F5ADz",
"createdTime":"2018-01-25T16:19:36+08:00",
"expirationDate":"2018-12-31T23:00:15+08:00"
}
Name Description
The unique ID of the created pass you should keep. When updating this
passId
pass, please provide this passId.
expirationDate The date and time when a pass expires and whether it is still valid. After
17
the expiration date, the pass is automatically voided.
https://www.pass2u.net/d/{passId}
Update pass
Update a generated pass by adding or changing customizable attributes and
dynamic fields of the model. A notification message will be sent to mobile devices of
the pass holders and shown on lock screens (e.g. latest news, balances, points,
special discount, customer information, records...).
URL Structure
Method URL
PUT https://api.pass2u.net/v2/models/{modelId}/passes/{passId}
passId string Yes The unique ID of the specified pass you want to update.
18
{
"expirationDate":"2019-12-31T23:00:15+08:00",
"foregroundColor":"rgb(51, 50, 46)",
"backgroundColor":"rgb(211, 79, 46)",
"labelColor":"rgb(196, 54, 39)",
"fields":[
{
"key":"level",
"label":"Level",
"value":"DIAMON",
"changeMessage":"You get highest and most rewarding level %@"
}
],
}
{
"barcodeMessage":"1234567890",
"modelId":1919,
"passId":"VT-2I77F5ADz",
"updatedTime":"2018-01-25T16:19:36+08:00",
"expirationDate":"2018-12-31T23:00:15+08:00"
}
Name Description
The unique ID of the created pass you should keep. Use this passId to
passId
manipulate the pass hereafter.
19
Reset pass attribute
Reset a customized Top-Level Key or Lower-Level Key attribute of the specified
pass to use the default value of the model (e.g. logo text, colors, relevant date,
expiration date...).
URL Structure
Method URL
DELETE https://api.pass2u.net/v2/models/{modelId}/passes/{passId}/attributes/{att
ributeName}
none
20
Content-Type: application/json
none
URL Structure
Method URL
DELETE https://api.pass2u.net/v2/models/{modelId}/passes/{passId}/fields/{fieldK
ey}
none
21
HTTP Response Header
Content-Type: application/json
none
URL Structure
Method URL
DELETE https://api.pass2u.net/v2/models/{modelId}/passes/{passId}/fields/{fieldK
ey}/attributes/{attributeName}
22
Accept: application/json
Content-Type: application/json
none
none
If you want to distribute a pass via web page or app other than Pass2U web page,
you can use this API get the pkpass file directly.
URL Structure
Method URL
GET https://api.pass2u.net/v2/models/{modelId}/passes/{passId}
passId string Yes The unique ID of the specified pass you want to get.
23
Content-Disposotion: attachment; filename=pass.pkpass
URL Structure
Method URL
GET https://api.pass2u.net/v2/models/{modelId}/passes/{passId}/status
passId string Yes The unique ID of the specified pass you want to query.
none
{
"passId":"VT-2I77F5ADz",
"devices":[
{
"brand":"iPhone",
"model":"XR",
"installedATime":"2019-12-31T23:00:15+08:00"
}
],
"redemptions":[
{
"campaignId": 2455,
"campaignName":"NIKE Run",
"checkoutAccount":"Betty",
"storeName":"HK No.1",
"redeemedTime":"2019-12-31T23:00:15+08:00"
}
],
}
Name Description
installedTime The date and time when the pass installed in the device
checkoutAccount The Pass2U Checkout account name who redeemed the pass
The name of the store which Pass2U Checkout account who redeemed
storeName
the pass belongs to
25
Upload pass image
When creating or updating the pass, you may want to replace the default model
image with a new image. The model style defines which types of images can be
assigned. Please refer to Apple Wallet Developer Guide to learn more about image
types for different styles.
URL Structure
Method URL
POST https://api.pass2u.net/v2/images
26
HTTP Request Header
x-api-key: { x-api-key}
Accept: application/json
Content-Type: image/png
Upload limitations
Icon 58 58
Footer 572 30
{
"hex":"89b9a6edb1132bae969711230ef63e3fb367f34e"
27
}
Name Description
The unique hex for the image you may use if the pass have to be
hex
customized the image.
Error Codes
{
"message":"error"
}
If you generated a pass which is not created by API or a pass is installed in a user
28
device, you can get the notification by HTTP POST when the relevant webhook urls
are specified. You can assign pass generating and installation webhook urls in step
3 “Configure Model Issuing Settings” in model issuing process.
29
Pass Generated Event
URL Structure
Method URL
POST Your pass generating webhook url (HTTPS is required) and will be called
by Pass2U
30
distributedAt string The date and time when pass is generated in ISO 8601 format.
{
"passId": "fjnUGLFqLst9",
"distributedAt": "2018-12-10T09:41:50+08:00",
"modelId": 2126
URL Structure
Method URL
POST Your pass installation webhook url (HTTPS is required) and will be called
by Pass2U
The unique ID of the specified model which the installed pass belongs
modelId string
to. You can find modelId in Dashboard.
installedAt string The date and time when pass is installed in ISO 8601 format.
31
{
"passId": "fjnUGLFqLst9",
"installedAt": "2018-12-10T09:41:50+08:00",
"modelId": 2126
32