Skip to main content

How to use the PassKit TypeScript SDK

The PassKit TypeScript QuickStart provides working examples for creating and managing Apple Wallet and Google Wallet passes using the PassKit TypeScript gRPC SDK.

Written by Claudia

The QuickStart includes examples for:

  • Membership and loyalty cards

  • Coupons

  • Event tickets

  • Boarding passes

This guide will help you configure your credentials, run the TypeScript QuickStart and test the included examples.

Before You Start

Before using the TypeScript QuickStart, you will need:

  • A PassKit account.

  • Your PassKit SDK credentials.

  • Node.js 20 or later.

  • npm.

  • An Apple Wallet certificate if you want to run the flights example.

The QuickStart supports both ESM and CommonJS builds.

Download the QuickStart

The TypeScript QuickStart is available from the PassKit TypeScript gRPC QuickStart repository.

Clone the repository:

git clone https://github.com/PassKit/passkit-typescript-grpc-quickstart.git 
cd passkit-typescript-grpc-quickstart

Install the project and its dependencies:

npm install

The QuickStart installs the PassKit TypeScript gRPC SDK and builds it during installation.

Alternatively, you can download the repository as a ZIP from GitHub, extract it, open a terminal in the extracted folder and run npm install.

Get Your PassKit SDK Credentials

The PassKit SDK uses SDK credentials to securely authenticate with the PassKit API.

To generate and download your SDK credentials:

  1. Log in to your PassKit account.

  2. Click your account icon in the bottom-left corner, then select Account from the menu.

  3. Select Developer Tools.

  4. Under Account Credentials, locate SDK Credentials.

  5. Follow the on-screen instructions to generate and download your credentials.

When generating your SDK credentials, you will be asked to create a password. This password encrypts your private key and is separate from your PassKit account password.

For TypeScript, you will need:

  • certificate.pem

  • key.pem

  • ca-chain.pem

Important: Keep your SDK credentials and credential password private. Do not commit or share them through Git or another source control repository.

Add Your SDK Credentials

Create a folder named certs in the root of the QuickStart repository.

Add all three SDK credential files to this folder:

passkit-typescript-grpc-quickstart/ 
├── certs/
│ ├── ca-chain.pem
│ ├── certificate.pem
│ └── key.pem

The credential files are ignored by Git and should not be committed to source control.

Configure the QuickStart

Create your local .env file by copying .env.example:

cp .env.example .env

Open .env and set:

PASSKIT_PASSPHRASE=your_passphrase

Replace your_passphrase with the password you created when generating your SDK credentials.

The default credential configuration is:

PASSKIT_ROOT_CERT=./certs/ca-chain.pem 
PASSKIT_PRIVATE_KEY=./certs/key.pem
PASSKIT_CERTIFICATE=./certs/certificate.pem

You do not need to manually decrypt key.pem. The QuickStart uses PASSKIT_PASSPHRASE to load your encrypted SDK private key.

Your SDK credentials and .env file are ignored by Git. Never commit or share them.

Configure Your API Region

Your QuickStart must connect to the API region associated with your PassKit account.

You can find your API region under Developer Tools → API Region in your PassKit account.

For European accounts, use:

PASSKIT_ADDRESS=grpc.pub1.passkit.io

For United States accounts, use:

PASSKIT_ADDRESS=grpc.pub2.passkit.io

The default gRPC port is:

PASSKIT_PORT=443

Your PassKit account data exists in one region, so make sure the configured address matches the API region shown in your account.

Run the QuickStart

Once your dependencies, credentials and .env file have been configured, you can run one of the four guided workflows.

Membership and Loyalty

npm run example:loyalty

Coupons

npm run example:coupons

Event Tickets

npm run example:tickets

Flights and Boarding Passes

npm run example:flights

To run all four workflows, use:

npm run dev

Each workflow creates the resources required for the example and demonstrates common PassKit API operations.

When successful, the workflow outputs the generated pass URL.

Open Your Wallet Pass

When a workflow successfully issues a pass, the QuickStart outputs a PassKit pass URL.

Open the URL on a compatible mobile device to add the pass to Apple Wallet or Google Wallet.

If you open the URL on a desktop, you can use the displayed QR code to open the pass on your phone.

What the Examples Demonstrate

Each workflow demonstrates common operations available through the PassKit TypeScript SDK.

Membership and Loyalty

The loyalty workflow demonstrates:

  • Uploading images

  • Creating templates

  • Creating a program

  • Creating tiers

  • Enrolling members

  • Looking up members

  • Retrieving member events

  • Checking members in and out

  • Updating loyalty points

Coupons

The coupons workflow demonstrates:

  • Uploading images

  • Creating templates

  • Creating a campaign

  • Creating offers

  • Issuing coupons

  • Looking up coupons

  • Listing coupons

  • Redeeming coupons

  • Voiding coupons

Event Tickets

The event tickets workflow demonstrates:

  • Uploading images

  • Creating a template

  • Creating a production

  • Creating a venue

  • Creating an event

  • Creating a ticket type

  • Issuing tickets

  • Looking up tickets

  • Listing tickets

  • Validating tickets

  • Redeeming tickets

Flights

The flights workflow demonstrates:

  • Uploading images

  • Creating a boarding pass template

  • Creating or reusing a carrier

  • Creating or reusing airports

  • Creating a flight

  • Creating a flight designator

  • Issuing a boarding pass

Running the Flights Example

The flights workflow requires an Apple Wallet certificate to be uploaded to your PassKit account.

Add the Pass Type Identifier for your Apple Wallet certificate to .env:

PASSKIT_APPLE_CERTIFICATE=pass.com.example.airline

Replace the example value with the Pass Type Identifier for your own Apple Wallet certificate.

Keeping Generated Resources

By default, each workflow cleans up the test resources it creates.

If you want to retain the resources so you can inspect them in your PassKit account, set:

PASSKIT_KEEP_ASSETS=true

Alternatively, pass the --keep option when running a workflow.

For example:

npm run example:loyalty -- --keep

When resources are retained, you will need to remove them manually from your PassKit account.

For normal QuickStart use, leave:

PASSKIT_KEEP_ASSETS=false

Sending a Pass to an Email Address

You can optionally provide a recipient email address in .env:

PASSKIT_RECIPIENT_EMAIL=

For example:

PASSKIT_RECIPIENT_EMAIL=example@example.com

Leave this value empty if you do not want to provide a recipient email address.

Using ESM and CommonJS

The TypeScript QuickStart supports both ESM and CommonJS.

ESM is the default.

To run the TypeScript source using ESM:

npm run dev:esm -- --quickstart loyalty

To build and run using CommonJS:

npm run dev:cjs -- --quickstart loyalty

You can build both formats with:

npm run build

The compiled output is created in:

dist/esm dist/cjs

To run compiled ESM output:

npm run start:esm -- --quickstart coupons

To run compiled CommonJS output:

npm run start:cjs -- --quickstart coupons

You can also build the formats individually:

npm run build:esm npm run build:cjs

This allows you to use the QuickStart as a reference whether your existing TypeScript or Node.js application uses ESM or CommonJS.

Using the TypeScript SDK in Your Application

Once you have successfully run a QuickStart workflow, use its implementation as a reference when building your own TypeScript application.

The focused examples are contained in the quickstarts directory and demonstrate the recommended structure for working with:

  • Membership and loyalty

  • Coupons

  • Event tickets

  • Flights

The shared PassKit client also provides access to additional services including:

  • Analytics

  • Certificates

  • Distribution

  • Integrations

  • Raw passes

This allows your application to access the wider TypeScript SDK without creating a separate connection for each service.

The QuickStart uses ConnectRPC with a reusable HTTP/2 transport, allowing requests to share the underlying gRPC connection.

Configuration Reference

The main configuration options available in .env are:

PASSKIT_PASSPHRASE
The password used to decrypt your SDK private key. This is required.

PASSKIT_ADDRESS
The PassKit API region. The default is grpc.pub1.passkit.io.

PASSKIT_PORT
The gRPC port. The default is 443.

PASSKIT_ROOT_CERT
The path to ca-chain.pem.

PASSKIT_PRIVATE_KEY
The path to your encrypted key.pem.

PASSKIT_CERTIFICATE
The path to certificate.pem.

PASSKIT_RECIPIENT_EMAIL
An optional email address to use when issuing passes.

PASSKIT_APPLE_CERTIFICATE
The Apple Wallet Pass Type Identifier required by the flights example.

PASSKIT_KEEP_ASSETS
Controls whether generated resources are retained after running a workflow. The default is false.

The legacy PASSKIT_GRPC_ADDRESS and PASSKIT_GRPC_PORT configuration names are also supported.

Test Your Setup

The repository includes checks that can be run without connecting to PassKit.

Run:

npm test

This:

  • Type-checks the TypeScript source.

  • Builds the ESM version.

  • Builds the CommonJS version.

  • Smoke-tests both compiled outputs.

You can also run:

npm run security

These checks are useful after modifying the QuickStart or when using it as the basis for your own application.

Troubleshooting

Node.js is not recognised or is too old

Check your installed Node.js version:

node --version

The TypeScript QuickStart requires Node.js 20 or later.

Credential files cannot be found

Confirm that the certs folder contains:

certificate.pem key.pem ca-chain.pem

Also make sure you are running commands from the root of the QuickStart repository.

Private key cannot be loaded

Check the value of:

PASSKIT_PASSPHRASE

This must be the password you created when generating your SDK credentials, not your PassKit account password.

You do not need to manually decrypt key.pem.

Authentication or connection fails

Check Developer Tools → API Region in your PassKit account and confirm that PASSKIT_ADDRESS matches your region.

For Europe:

grpc.pub1.passkit.io

For the United States:

grpc.pub2.passkit.io

Also make sure certificate.pem, key.pem and ca-chain.pem belong to the same set of SDK credentials.

Flights do not run

Confirm that an Apple Wallet certificate has been uploaded to PassKit and that its Pass Type Identifier has been added to:

PASSKIT_APPLE_CERTIFICATE

Generated resources remain in your account

Cleanup is best-effort. If a workflow is interrupted or cleanup fails, some generated resources may remain.

Remove any remaining test resources manually from your PassKit account.

Also check:

PASSKIT_KEEP_ASSETS

If this is set to true, the QuickStart intentionally retains generated resources.

Next Steps

Once you have successfully run the TypeScript QuickStart, you can use the workflows and shared client as a reference when implementing PassKit in your own TypeScript application.

For additional methods, request fields and response definitions, refer to the PassKit developer documentation.

Did this answer your question?