Create a working PassKit membership card, coupon, event ticket, or flight boarding pass with the official .NET SDK. You can choose an example from a simple menu—no source-code changes are required.
The examples print a wallet pass URL and automatically remove the test resources they create.
You need:
- .NET 8 SDK or a newer supported .NET SDK/runtime
- a free PassKit account
- PassKit SDK credentials
git clone https://github.com/PassKit/passkit-c-sharp-quickstart.git
cd passkit-c-sharp-quickstart
dotnet restore c-sharp-quickstart.csprojYou can also download the repository as a ZIP from GitHub and open a terminal in the extracted folder.
-
Sign in to PassKit.
-
Open Developer Tools from the account menu.
-
Under Account Credentials, select SDK Credentials.
-
Choose a strong password when prompted. This encrypts your private key; it is not your PassKit account password.
-
Download the three files sent to your registered email address:
certificate.pemkey.pemca-chain.pem
Keep the password safe. PassKit does not store your private key or certificate. Generating another credential set invalidates the existing credentials.
Create a certs folder and copy all three files into it.
macOS or Linux:
mkdir -p certs
cp /path/to/downloads/certificate.pem certs/
cp /path/to/downloads/key.pem certs/
cp /path/to/downloads/ca-chain.pem certs/
cp .env.example .envWindows PowerShell:
New-Item -ItemType Directory -Force certs
Copy-Item "$HOME\Downloads\certificate.pem" certs\
Copy-Item "$HOME\Downloads\key.pem" certs\
Copy-Item "$HOME\Downloads\ca-chain.pem" certs\
Copy-Item .env.example .envYour folder should look like this:
passkit-c-sharp-quickstart/
├── .env
└── certs/
├── ca-chain.pem
├── certificate.pem
└── key.pem
These files and .env are ignored by Git. Never commit or share them.
Open .env in a text editor. Add the password you chose when generating the SDK credentials:
PASSKIT_ENVIRONMENT=pub1
PASSKIT_CERTIFICATE=certs/certificate.pem
PASSKIT_PRIVATE_KEY=certs/key.pem
PASSKIT_ROOT_CERT=certs/ca-chain.pem
PASSKIT_PASSPHRASE=replace-with-your-sdk-credential-password
PASSKIT_POOL_SIZE=5
PASSKIT_RECIPIENT_EMAIL=
PASSKIT_APPLE_CERTIFICATE=
PASSKIT_KEEP_ASSETS=falseCheck Developer Tools → API Region in PassKit:
- use
pub1for the European server - use
pub2for the US server
Your PassKit account and its data belong to one region, so this value must match your account. The quickstart loads .env automatically.
dotnet run --project c-sharp-quickstart.csprojChoose an example from the menu:
Choose an example:
1. loyalty
2. coupons
3. tickets
4. flights
Selection [1]:
You can also run an example directly:
dotnet run --project c-sharp-quickstart.csproj -- loyalty
dotnet run --project c-sharp-quickstart.csproj -- coupons
dotnet run --project c-sharp-quickstart.csproj -- tickets
dotnet run --project c-sharp-quickstart.csproj -- flightsWhen successful, the quickstart prints a URL similar to:
https://pub1.pskt.io/4MEIqDFudziP4ZFKx5osw3
Open the URL on a phone to add the pass to Apple Wallet or Google Wallet. On a desktop, the PassKit page displays a QR code you can scan with a phone.
By default, cleanup runs even when an example fails partway through. To inspect the generated records in your PassKit account, change this setting in .env:
PASSKIT_KEEP_ASSETS=trueYou will then need to delete those resources manually. Change it back to false for normal quickstart use.
Flights require an Apple pass certificate uploaded to PassKit. Add its pass type identifier to .env:
PASSKIT_APPLE_CERTIFICATE=pass.com.example.airlineIf this value is empty, the flights example explains the requirement and exits without creating resources.
loyalty: templates, a program, tiers, enrolment, external-ID lookup, check-in/out, and earning and burning pointscoupons: templates, a campaign, offers, coupons, lookup, redemption, and voidingtickets: a template, production, venue, event, ticket type, issuance, validation, and redemptionflights: a template, carrier, airports, flight, scheduled designator, semantic boarding-pass fields, and passenger and infant passes
Most users only need to set the region and passphrase.
| Variable | Default | Purpose |
|---|---|---|
PASSKIT_ENVIRONMENT |
pub1 |
pub1 for Europe or pub2 for USA |
PASSKIT_ADDRESS |
Derived from the region | Optional full PassKit gRPC HTTPS address |
PASSKIT_CERTIFICATE |
certs/certificate.pem |
PEM certificate path; .pfx and .p12 also work |
PASSKIT_PRIVATE_KEY |
certs/key.pem |
PEM private-key path |
PASSKIT_ROOT_CERT |
certs/ca-chain.pem |
PassKit CA chain used for TLS validation |
PASSKIT_PASSPHRASE |
Empty | SDK private-key passphrase, or PKCS #12 password |
PASSKIT_POOL_SIZE |
5 |
Number of reusable gRPC channels |
PASSKIT_RECIPIENT_EMAIL |
Empty | Optional welcome-email recipient |
PASSKIT_APPLE_CERTIFICATE |
Empty | Apple pass type identifier for flights |
PASSKIT_KEEP_ASSETS |
false |
Preserve generated PassKit resources |
Values already set in your terminal take precedence over .env.
Confirm that all three .pem files are inside certs/, that their names have not changed, and that you are running the command from the repository folder.
Check PASSKIT_PASSPHRASE. It must be the password chosen when generating SDK Credentials, not your PassKit login password. Generate a new credential set if the password or files have been lost, then replace all three local files together.
Check your API region under Developer Tools → API Region. Use pub1 for Europe or pub2 for the US. Also check whether a corporate firewall or VPN blocks outbound HTTPS/gRPC traffic.
The pass URL begins with https://pub1.pskt.io/ for Europe or https://pub2.pskt.io/ for the US. Correct PASSKIT_ENVIRONMENT in .env and rerun the example.
Check spam and quarantine folders. Corporate mail systems may block certificate attachments. Follow the guidance in the PassKit help centre or contact PassKit support if the email is still missing.
Upload an Apple pass certificate to PassKit and set PASSKIT_APPLE_CERTIFICATE to its pass type identifier.
The quickstart attempts each cleanup operation independently and reports anything it cannot delete. Remove reported resources in the PassKit portal, then verify that PASSKIT_KEEP_ASSETS=false.
Quickstarts/PassKitApi.cs groups the strongly typed SDK clients in one discoverable place. It covers loyalty, coupons, event tickets, flights, templates, images, analytics, SmartPass distribution and messaging, integrations/webhooks, scanner configuration, certificates, and raw passes.
using Quickstart.Common;
using var pool = new GrpcConnectionPool.GrpcConnectionPool();
var api = new PassKitApi(pool.GetChannel());
var program = await api.Loyalty.getProgramAsync(programId);
var template = await api.Templates.getTemplateAsync(templateId);The SDK provides strongly typed protobuf request and response objects and synchronous and asynchronous methods. Keep account deletion, password/API-secret management, team administration, certificate mutation, NFC credentials, and broad bulk operations in dedicated, access-controlled administrative tools.
The test suite checks the complete Node quickstart facade method list against SDK 1.1.162. Tests/ApiParityTests.cs fails if a corresponding C# RPC is missing, including membership batch updates and distribution messaging methods.
The methods introduced in SDK 1.1.162 also have typed convenience helpers:
await api.AddMessageAsync(message);
var messages = await api.GetMessagesAsync();
await api.CancelMessageAsync(messageId);
// Bulk changes require an explicit safety opt-in.
await api.BatchUpdateMembersAsync(batchRequest, allowBulkOperation: true);These checks do not connect to PassKit or require credentials:
dotnet build c-sharp-quickstart.csproj --configuration Release
dotnet test Tests/c-sharp-quickstart.Tests.csproj --configuration Release
dotnet format c-sharp-quickstart.csproj --verify-no-changes
dotnet list c-sharp-quickstart.csproj package --vulnerable --include-transitiveCI runs the same offline checks without receiving PassKit credentials.