Wallet API Examples
In the following example, we are going to create a store card.
These instructions describe how you can create your first Wallet Template! Using cURL calls.
Before you can start using the Wallet API, you need to complete the following steps:
-
Get access credentials.
-
Get your API Key
-
Have cURL installed in your machine
For more information, go to the Build your API Call section.
Your API call must have the following components:
-
A host -> The host requests are always [ https://elastic.messangi.me/ ]
-
An Authorization header -> Your API Key must be included in the Authorization header.
-
A request -> When submitting data to a resource via POST or PUT, you must submit your payload in JSON.
Create a Wallet Pass Template
The steps to create a wallet pass template of a store card using the Wallet API are the following:
curl -X POST "https://elastic.messangi.me/ironbank/v2/wallet/templates" -H "accept: application/json" -H "Authorization: Bearer <YOUR_API_KEY>" -H "Content-Type: multipart/form-data" --form 'template={
"name": "Example Store card",
"type": "storecard",
"description": "Wallet pass storecard example",
"organization": "SmallYuGi7"
}'
-
Copy the curl example above.
-
Paste the curl call into your favorite text editor.
-
Copy your API key and paste it in the
Authorization
header. -
In the data section, we recommend you to specify the
name
( Template name ),type
( Template pass type ),description
( Brief description of the pass ) andorganization
( Your brand inside the pass ) before entering the other parameters. -
Copy the code and paste it in your terminal command.
-
Press Enter.
-
Check the response body and verify the wallet template created.
-
Copy the parameter
serial
(Template ID) located in the response body for future requests.
Update a Wallet Pass Template
Once the template is created, we proceed to add the parameters to create an intuitive store card pass for the user.
The steps to update a wallet pass template of a store card using the Wallet API are the following:
curl -X PATCH "https://elastic.messangi.me/ironbank/v2/wallet/templates/<WALLET_TEMPLATE_ID>" -H "accept: application/json" -H "Authorization: Bearer <YOUR_API_KEY>" -H "Content-Type: multipart/form-data" --form 'template={
"fields": [
{
"place": "HEADER",
"label": "Points",
"fixed": "false"
},
{
"place": "SECONDARY",
"label": "Name",
"fixed": "false"
},
{
"place": "SECONDARY",
"label": "Last Name",
"fixed": "false"
},
{
"place": "AUXILIARY",
"label": "email",
"fixed": "false"
}
],
"images": [
{
"name": "logo",
"fixed": "true"
},
{
"name": "icon",
"fixed": "true"
},
{
"name": "strip",
"fixed": "true"
}
],
"googlePayCompatible" : true,
"visualInfo" : {
"labelColor" : "#666666",
"backgroundColor" : "#f3f3f3",
"foregroundColor" : "#0000ff",
"barcode" : {
"type" : "QR",
"contentFixed" : false,
"altTextFixed" : false
}
}
}' --form "logo=@/mnt/c/Users/tec13/Pictures/logo.png;type=image/png" --form "icon=@/mnt/c/Users/tec13/Pictures/icon.png;type=image/png" --form "strip=@/mnt/c/Users/tec13/Pictures/strip.png;type=image/png"
-
Copy the curl example above.
-
Paste the curl call into your favorite text editor.
-
Copy your API key and paste it in the
Authorization
header. -
Copy the unique identifier
serial
of the wallet template into the URL.
-
Next we add the optional fields to the curl call:
-
Activate pass compatibility with Google Pay
-
Template fields :
PRIMARY
,SECONDARY
,AUXILIARY
,HEADER
. -
Template images:
icon
,logo
,strip
. -
Visual info: barcode [
QR
]The values of the template fields and the barcode are unique.
-
In the data section, we recommend you to specify the
fields
( Template fields ),images
( Template images ),visualInfo
( Visual information of the pass ) andgooglePayCompatible
( Compatibility with Google Pay ). -
Copy the code and paste it in your terminal command.
-
Press Enter.
-
Check the response body and verify the wallet template updated.
-
Copy the parameter
serial
(Template ID) located in the response body for future requests.
Create Wallet Passes
Once the template is created, we proceed to create the store card pass for two users.
The steps to create one or more wallet passes of a store card using the Wallet API are the following:
curl -X POST "https://elastic.messangi.me/ironbank/v2/wallet/templates/<WALLET_TEMPLATE_ID>/passes/batch" -H "accept: application/json" -H "Authorization: Bearer <YOUR_API_KEY>" -H "Content-Type: application/json;charset=UTF-8" -d "{\"items\":[{\"recipientId\":\"abcdefg7\",\"uniqueValues\":{\"fields\":[{\"place\":\"HEADER\",\"label\":\"Points\",\"value\":\"50\"},{\"place\":\"SECONDARY\",\"label\":\"Name\",\"value\":\"Sarah\"},{\"place\":\"SECONDARY\",\"label\":\"Last Name\",\"value\":\"Carter\"},{\"place\":\"AUXILIARY\",\"label\":\"email\",\"value\":\"[email protected]\"}],\"barcode\":{\"altText\":\"my VAR altText\",\"content\":\"my VAR content\"}}},{\"recipientId\":\"abababab\",\"uniqueValues\":{\"fields\":[{\"place\":\"HEADER\",\"label\":\"Points\",\"value\":\"20\"},{\"place\":\"SECONDARY\",\"label\":\"Name\",\"value\":\"Joshua\"},{\"place\":\"SECONDARY\",\"label\":\"Last Name\",\"value\":\"Albarn\"},{\"place\":\"AUXILIARY\",\"label\":\"email\",\"value\":\"[email protected]\"}],\"barcode\":{\"altText\":\"my VAR altText\",\"content\":\"my VAR content\"}}}]}"
-
Copy the curl example above.
-
Paste the curl call into your favorite text editor.
-
Copy your API key and paste it in the
Authorization
header. -
Copy the unique identifier
serial
of the wallet template into the URL. -
Next we add the unique values to the curl call:
-
Template fields:
PRIMARY
,SECONDARY
,AUXILIARY
,HEADER
. -
Visual info: barcode [
QR
]
-
In the data section, specify the
recipientId
( unique identifier of the recipient ),uniqueValues
( unique values ),fields
( template fields which are unique ) andbarcode
( barcode which is unique ).
Copy the code and paste it in your terminal command. -
Press Enter.
-
Check the response body and verify the wallet template updated.
-
In the response body, you can download the passes by copying every value of the
url
parameter and placing it in the browser the pkpass will be downloaded immediately.
"items": [
{
"recipientId": "-8a04732e682g",
"url": "elastic.messangi.me/--"
},
{
"recipientId": "135dfc977382g",
"url": "elastic.messangi.me/--"
}
- Copy the parameter
serial
(Template ID) andrecipientId
located in the response body for future requests.
Download Wallet Passes
Once the pass is created, we proceed to download the store card pass for the users.
The steps to download a wallet pass using the Wallet API are the following:
curl -X GET "https://elastic.messangi.me/ironbank/v2/wallet/templates/<WALLET_TEMPLATE_ID>/passes/<RECIPIENT_ID>/download?forcePkPass=true" -H "accept: application/vnd.apple.pkpass" -H "Authorization: Bearer <YOUR_API_KEY>" --output <WALLET_PASS_NAME>
-
Copy the curl example above.
-
Paste the curl call into your favorite text editor.
-
Copy your API key and paste it in the
Authorization
header. -
In the data section, select the URL and enter the id (
serial
) of the wallet template and his recipient Id (recipientId
) into the URL:
[ https://elastic.messangi.me/ironbank/v2/wallet/templates/{serial
}/passes/{recipientId
}/download?forcePkPass=true ]
-
To download the Wallet Pass with a specific name, type the desired name of the pass :
--output <WALLET_PASS_NAME>
-
Copy the code and paste it in your terminal command or copy the URL to your Browser.
-
Press Enter.
-
The pass will be downloaded immediately.
-
Copy the parameter
serial
(Template ID) andrecipientId
located in the response body for future requests.
Congratulations! You have created your own pass!
Updated about 1 year ago