Skip to main content

How to use the PassKit Golang SDK

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

Before You Start

Before using the Go QuickStart, you will need:

  • A PassKit account.

  • Your PassKit SDK credentials.

  • Go 1.25 or later.

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

Download the QuickStart

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

Clone the repository:

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

Alternatively, download the repository as a ZIP from GitHub, extract it and open a terminal in the extracted folder.

The PassKit Go SDK is already included as a dependency in go.mod, so you do not need to install the SDK separately using go 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 Go, you will need:

  • certificate.pem

  • key.pem

  • ca-chain.pem

The key-java.pem file is not required for Go.

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

Add the following three SDK credential files to the certs folder in the QuickStart repository:

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

The credential files are excluded from Git and should not be committed to source control.

Decrypt Your Private Key

If your key.pem is encrypted, create a separate decrypted copy for the QuickStart.

From the root of the repository, run:

openssl ec -in certs/key.pem -out certs/key-decrypted.pem

When prompted, enter the password you created when generating your PassKit SDK credentials.

Your certs folder should now contain:

certs/ 
├── ca-chain.pem
├── certificate.pem
├── key.pem
└── key-decrypted.pem

Keeping the decrypted key as a separate file means you retain your original encrypted key.pem.

Important: key-decrypted.pem contains your unencrypted private key. Keep it secure and never commit or share it.

Configure the QuickStart

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

cp .env.example .env

Open .env and configure the QuickStart with your details.

Set your email address using:

PASSKIT_EMAIL=your-email@example.com

This email address is used by examples that send a welcome email containing the wallet pass URL.

If you created a decrypted private key, make sure the private key configuration points to:

certs/key-decrypted.pem

Your .env file and SDK credentials are excluded from Git 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.

European accounts use:

grpc.pub1.passkit.io

United States accounts use:

grpc.pub2.passkit.io

The QuickStart uses the European endpoint by default.

If your account is in the United States region, set the following in .env:

PASSKIT_GRPC_HOST=grpc.pub2.passkit.io

Make sure the configured 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 complete product workflows.

Membership and Loyalty

go run . membership

Coupons

go run . coupons

Event Tickets

go run . event-tickets

Flights and Boarding Passes

go run . flights

Each command runs a single product workflow, creating the resources required for the example and demonstrating common PassKit API operations.

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

Membership and Loyalty

The membership workflow demonstrates operations including:

  • Creating a membership or loyalty program

  • Creating a tier

  • Enrolling a member

  • Retrieving member information

  • Listing and counting members

  • Sending a welcome email

  • Updating a member

  • Adding points

  • Using points

  • Deleting a member

Coupons

The coupons workflow demonstrates operations including:

  • Creating a campaign

  • Creating an offer

  • Issuing a coupon

  • Retrieving coupon information

  • Listing and counting coupons

  • Updating a coupon

  • Redeeming a coupon

  • Voiding a coupon

  • Deleting a coupon offer

Event Tickets

The event tickets workflow demonstrates operations including:

  • Creating a template

  • Creating a production

  • Creating a venue

  • Creating a ticket type

  • Creating an event

  • Issuing an event ticket

  • Validating an event ticket

  • Redeeming an event ticket

Flights

The flights workflow demonstrates operations including:

  • Creating a boarding pass template

  • Creating a carrier

  • Creating airports

  • Creating a flight

  • Creating a flight designator

  • Issuing a boarding pass

  • Cleaning up the generated flight resources

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_ID=pass.com.example.airline

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

Inspecting Generated Resources

The QuickStart can pause before follow-up and cleanup operations are performed, giving you time to inspect the generated passes and resources.

Set the following value in .env:

PASSKIT_CLEANUP_DELAY_SECONDS=60

For example, a value of 60 gives you 60 seconds to inspect the generated resources before the workflow continues with its follow-up and cleanup operations.

Adjust this value depending on how long you need to inspect the generated passes.

Running Individual Examples

The QuickStart also contains individual operations under the examples folder.

These examples use generated identifiers and future dates rather than account-specific PassKit IDs.

You can review and adapt the relevant files when you want to understand how a particular PassKit operation is implemented.

The complete workflows are recommended when getting started because they create and use the required resources in the correct order.

Using the Go SDK in Your Application

Once you have successfully run a QuickStart workflow, you can use the examples as a reference when implementing PassKit in your own Go application.

The QuickStart provides a shared typed API covering functionality including:

  • Membership and loyalty

  • Coupons

  • Event tickets

  • Flights

  • Templates

  • Images

  • Analytics

  • Distribution

  • Integrations

  • Scanners

  • Certificates

  • Messages

  • Raw passes

The QuickStart also uses reusable pooled gRPC connections. The connection pool defaults to four channels and can be configured using PASSKIT_POOL_SIZE.

Potentially destructive bulk membership, coupon and ticket operations require explicit opt-in. Review these operations carefully before enabling them in your own application.

Test Your Setup

The repository includes checks that do not call the live PassKit API or require SDK credentials.

Run the tests with:

go test ./...

You can also run:

go vet ./...

These are useful for checking the project after making changes or when using the QuickStart as the basis for your own integration.

Troubleshooting

Go is not recognised

Check that Go 1.25 or later is installed:

go version

If the command is not recognised, install a supported version of Go and make sure it is available in your system path.

Do I need to install the PassKit SDK separately?

No. The PassKit Go SDK is already declared in the QuickStart's go.mod file and is downloaded through Go modules.

You do not need to run:

go install github.com/PassKit/passkit-golang-grpc-sdk

Credential files cannot be found

Confirm that your certs folder contains the required SDK credential files and that the paths configured by the QuickStart match their location.

For Go, use:

certificate.pem 
ca-chain.pem
key.pem

Do not use key-java.pem.

Private key cannot be decrypted

When running the OpenSSL command, enter the password you created when generating your SDK credentials.

This is separate from your PassKit account password.

If you no longer have the password, generate a new set of SDK credentials.

Authentication or connection fails

Check Developer Tools → API Region in your PassKit account and confirm that the configured gRPC host matches your region.

Use:

grpc.pub1.passkit.io

for Europe or:

grpc.pub2.passkit.io

for the United States.

Also make sure your certificate, private key and CA chain 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_ID

Next Steps

Once you have successfully run the Go QuickStart, you can use the workflows and individual examples as a reference when implementing PassKit in your own Go application.

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

Did this answer your question?