Go home

Apple Wallet cards in PassHub Telegram

This document describes how to add support for the Telegram app.



Registering a Device to Receive Push Notifications for a Pass

PassHub for Telegram follows Apple’s Wallet Web Service API for registering a device for receiving push notifications as stated in the following document Apple Wallet Web Service Reference.

PassHub for Telegram uses a different Authorization header to ensure that the app is not erroneously detected as Apple Wallet App.

The Authorization header is the word TelegramPass (instead of ApplePass), followed by a space, followed by the pass’s authorization token as specified in the pass.

If your system already implements the Apple Wallet Web Service API you only need to take in account the special Authorization header for flagging the device as PassHub for Telegram.

The pushToken in the payload is similar to APN pushToken and you need to store it for later use with the push notification service.


User Agent

You can always detect the app by inspecting the user agent. Request from PassHub for Telegram always contain the following user agent part: PassHubTelegram/1.0



Sending Push Notifications to the App


Getting started

The API is open for everybody. While it is not required to use an API key, we recommend to register yourself to get your personal API key (see rate limitation).


Authentication

For authentication send your API key in the HTTP Authorization header as a Bearer token.

Authorization: Bearer [API key]


The push notification request

Sending push notifications consists in sending a POST request with a specific payload to the following endpoint with the content type application/json.

POST https://api.passhub.io/v1/push

Payload:

{
  "pass_type_id": "pass.io.passhub.sample",
  "push_tokens": [
    "59144e4701b04a3abd2bdc5fcb87ce2cbace8fcfc00a476ea7f19c18925d0af4",
    "8e372fdadea847febe0aacb44d3003496a5f24d5855e451eadfb9167e81c77c8"
  ]
}
NameTypeRequired
pass_type_idstringyes
push_tokensarray of stringsyes

In case of success the server will respond with 200 OK. If you send a wrong request (e.g. missing pass_type_id or push_tokens), the server will respond with 400 Bad Request.


Rate Limitation

To protect our constrained resources, the public API is rate limited to 5 push notifications per second (maximum of 300 notifications per minute). All non-authenticated API calls count towards the public rate limit.

If you want to send more notifications, please create your personal API key.

If you hit the rate limit with your request, the backend will reply with 429 Too Many Requests. In such a response the server will send the header Retry-After, which contains the seconds to wait until the request can be retried.

Example:

X-Rate-Limit-Limit: 300
X-Rate-Limit-Remaining: 0
Retry-After: 8

If your request exceeds the overall quota (more than 100 push tokens for non-authenticated calls), the backend will reply with 422 Unprocessable Content.
Consider splitting your request into smaller ones and retry.

If you need a higher quota that is available by default, contact us.



Importing a pass into PassHub for Telegram

Just create a link:

https://t.me/passhubbot/import?startapp=atob(encodeURIComponent(YOUR_PASS_URL_HERE))