Skip to main content

How to use the PassKit Python SDK

The PassKit Python QuickStart provides working examples for creating and managing Apple Wallet and Google Wallet passes using the PassKit Python 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 Python QuickStart and test the included examples.

Before You Start

Before using the Python QuickStart, you will need:

  • A PassKit account.

  • Your PassKit SDK credentials.

  • Python 3.9 or later.

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

Download the QuickStart

The Python QuickStart is available from the PassKit Python QuickStart repository.

Clone the repository:

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

Create a Python virtual environment:

python3 -m venv .venv

On macOS or Linux, activate the virtual environment with:

source .venv/bin/activate

On Windows PowerShell:

.venv\Scripts\Activate.ps1

Then install the QuickStart and its dependencies:

python -m pip install -e .

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 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.

Your SDK credentials contain three files:

  • certificate.pem

  • key.pem

  • ca-chain.pem

Keep your SDK credential password and credential files secure.

Important: Do not commit or share your SDK credentials. Generating a new set of SDK credentials will invalidate your existing credentials.

Add Your SDK Credentials

In the root of the QuickStart repository, create a folder named:

certs

Add all three SDK credential files to this folder.

Your project should contain:

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

You do not need to manually decrypt key.pem. The QuickStart can use the encrypted private key with the password you created when generating your SDK credentials.

The certs folder is ignored by Git to help prevent your credentials from being 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 to the password you created when generating your SDK credentials.

Your credential paths are configured to use:

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

Both your .env file and SDK credentials should remain private and should not be committed to source control.

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 gRPC connections, use:

Europe

grpc.pub1.passkit.io

United States

grpc.pub2.passkit.io

Set PASSKIT_ADDRESS in your .env file to the appropriate hostname.

For example:

PASSKIT_ADDRESS=grpc.pub1.passkit.io

The default gRPC port is:

PASSKIT_PORT=443

Make sure the API region matches the region shown in your PassKit account.

Run the QuickStart

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

Membership and Loyalty

python main.py membership

You can also use:

python main.py loyalty

Coupons

python main.py coupons

Event Tickets

python main.py event-tickets

You can also use:

python main.py tickets

Flights and Boarding Passes

python main.py flights

Each workflow creates the resources required for the example and performs a series of common PassKit API operations.

Open Your Wallet Pass

When an example completes successfully, 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, the PassKit page displays a QR code that you can scan with your phone.

What the Examples Demonstrate

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

Membership and Loyalty

The membership workflow demonstrates operations including:

  • Uploading images

  • Creating templates

  • Creating a program and tiers

  • Enrolling a member

  • Updating a member

  • Looking up members by ID and external ID

  • Checking members in and out

  • Earning points

  • Burning points

  • Listing and counting members

  • Retrieving member event history

Coupons

The coupons workflow demonstrates operations including:

  • Uploading images

  • Creating coupon templates

  • Creating a campaign and offers

  • Issuing coupons

  • Updating coupons

  • Retrieving coupons

  • Listing and counting coupons

  • Redeeming coupons

  • Voiding coupons

Event Tickets

The event tickets workflow demonstrates operations including:

  • Uploading images

  • Creating a template

  • Creating a production

  • Creating a venue and event

  • Creating a ticket type

  • Issuing an event ticket

  • Updating a ticket

  • Looking up tickets by ID, ticket number and order number

  • Listing and counting tickets

  • Validating tickets

  • Redeeming tickets

Flights

The flights workflow demonstrates operations including:

  • Uploading images

  • Creating a boarding pass template

  • Creating or reusing a carrier

  • Creating or reusing airports

  • Creating a flight

  • Creating a flight designator

  • Looking up flight information

  • Issuing a boarding pass

  • Looking up a boarding pass

Running the Flights Example

The flights workflow requires an Apple Wallet pass 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 your own Pass Type Identifier.

The QuickStart uses default carrier and airport codes for the example. If those resources already exist in your account, they are reused rather than recreated.

Reused carrier and airport resources are not deleted during cleanup.

Keeping Generated Resources

By default, the QuickStart removes the test resources it creates after running a workflow.

Cleanup also runs if an example fails partway through, helping prevent test resources from accumulating in your PassKit account.

If you want to keep the generated resources so you can inspect them, set the following value in .env:

PASSKIT_KEEP_ASSETS=true

You will then need to remove the generated resources manually.

For normal QuickStart use, leave:

PASSKIT_KEEP_ASSETS=false

Sending a Welcome Email

If you want the QuickStart to send a generated pass to an email address, set:

PASSKIT_RECIPIENT_EMAIL=

to the email address you want to use.

For example:

PASSKIT_RECIPIENT_EMAIL=example@example.com

Leave this value empty if you do not want to send a welcome email.

Exploring the SDK

The guided workflows provide examples of common PassKit operations, but the Python SDK contains additional methods that you can use in your own application.

To view the operations currently exposed through the QuickStart, run:

python main.py operations

This command does not require SDK credentials or a connection to PassKit.

The individual product folders also contain reusable methods for:

  • Membership and loyalty

  • Coupons

  • Event tickets

  • Flights

You can use these implementations as a reference when building your own integration.

Troubleshooting

Credential files cannot be found

Confirm that all three credential files are inside the certs folder:

certificate.pem 
key.pem
ca-chain.pem

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

Private key cannot be decrypted

Check the value of:

PASSKIT_PASSPHRASE

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

If you generate a new set of SDK credentials, replace all three credential files together.

Authentication or connection fails

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

grpc.pub1.passkit.io

for Europe, or:

grpc.pub2.passkit.io

for the United States.

Also check whether a firewall or VPN is blocking outbound HTTPS or gRPC traffic.

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

The QuickStart attempts to clean up the resources created during each workflow.

If resources remain, check the terminal output for cleanup errors and remove the remaining resources from your PassKit account.

Also confirm that:

PASSKIT_KEEP_ASSETS=false

Next Steps

Once you have successfully run the Python QuickStart, you can use the examples and reusable methods as a reference when implementing PassKit in your own Python application.

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

Did this answer your question?