# How to Create Passes via API in The Wallet Crew

This guide shows how to create wallet passes from your own systems (CRM, e-commerce, ticketing, POS, or backend). You will configure a pass template, call the API to create a pass, then retrieve a link your customers can open to install it.

<details>

<summary><strong>Real-world examples</strong></summary>

* Create a loyalty card right after a signup form is completed.
* Generate event tickets after payment confirmation, then update them for seat changes.
* Create membership cards and update tier/expiry after each renewal.

</details>

## Prerequisites

Before proceeding, ensure you have the following:

1. **The Wallet Crew Platform Activated:** Your Wallet Crew account and platform should be active.
2. **API Key Generated:** Generate an API key from The Wallet Crew admin console ([API Key](https://docs.thewalletcrew.io/configure/platform/api-key)).
3. **Pass Type Template Configured:** Create and configure a pass type template in The Wallet Crew Wallet.
4. **Variables Assigned:** Assign variables in the pass type to match wallet fields in Apple and Google Wallet that will be populated via the API call.

{% hint style="info" %}
You’ll need two values at API call time: your `tenantId` (in the URL path) and your `passType` (template name).
{% endhint %}

## Step-by-Step Guide

### Step 1: Configure The Wallet Crew

1. **Create a Pass Type Template:**
   * Navigate to the [Pass Type section](https://admin.thewalletcrew.io/tenant/~/passTypes){target="\_blank"|title="Pass Type"} in the admin console.
   * Define a new pass type and configure fields as required.
2. **Define Variables:**
   * Map variables to the pass type fields. **These variables will be populated by the API calls.**

![These variables will be populated by the API calls.](https://3566051324-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWLc8AHXW4tdrAXUBfrYF%2Fuploads%2Fgit-blob-be86ff8ab2d0ce6130f066108f826bdeed0aa064%2Fhow_to_create_passes_via_api_in_the_wallet_crew_1.png?alt=media)

3. **Generate an API Key:**
   * [Access the API settings in the admin console](https://admin.thewalletcrew.io/tenant/~/settings/security/apiKeys){target="\_blank"|title="API Key"} and generate a key for authentication.

### Step 2: Access the API

1. **Connect to Swagger UI or Postman Collection:**
   * Swagger URL: [The Wallet Crew Swagger UI](https://admin.thewalletcrew.io/api/swagger/index.html)
2. **Authenticate Using the API Key:**
   * Add the API key to the `X-API-KEY` header of your requests.
   * Click **Authorize**, then enter your API key (for example, in Swagger).

![Step 2: Access the API](https://3566051324-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWLc8AHXW4tdrAXUBfrYF%2Fuploads%2Fgit-blob-32479874bb2fe7f4f37816e6bc561489002bfefc%2Fhow_to_create_passes_via_api_in_the_wallet_crew_2.png?alt=media)

### Step 3: Create a Pass via API

1. **Test the `POST` Method:**
   * Endpoint: `POST /api/{tenantId}/passes?passType={passType}`
   * Required Parameters:
     * `tenantId`: Your tenant identifier (in the URL path).
     * `passType`: The template name you created (query parameter).
   * Request Body:
   * Select application/json format:

![Step 3: Create a Pass via API](https://3566051324-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWLc8AHXW4tdrAXUBfrYF%2Fuploads%2Fgit-blob-666171a77f34e90c03d9657fe0e8d74d004488d8%2Fhow_to_create_passes_via_api_in_the_wallet_crew_3.png?alt=media)

{% hint style="info" %}
For the complete request/response schema, see the [Pass API reference](https://docs.thewalletcrew.io/develop/guides/wallet/broken-reference).
{% endhint %}

* Example:

![Step 3: Create a Pass via API (2)](https://3566051324-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWLc8AHXW4tdrAXUBfrYF%2Fuploads%2Fgit-blob-b28ab12b9931d168252c029d516b3b95aca947af%2Fhow_to_create_passes_via_api_in_the_wallet_crew_4.png?alt=media)

2. **Successful Response:**
   * You will receive a `passId` in the response. Example:

![Successful Response](https://3566051324-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWLc8AHXW4tdrAXUBfrYF%2Fuploads%2Fgit-blob-7d8f7b1ff7274137285ea6bfccc50d955d4a5a87%2Fhow_to_create_passes_via_api_in_the_wallet_crew_5.png?alt=media)

### Step 4: View or Download the Pass

1. **Admin Console:**
   * Go to the Wallet section and filter by `passId` to view, edit, or download the pass.

![Admin Console](https://3566051324-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWLc8AHXW4tdrAXUBfrYF%2Fuploads%2Fgit-blob-ba22b0e1cf330d814bc4a15144f2e9f732289d85%2Fhow_to_create_passes_via_api_in_the_wallet_crew_6.png?alt=media)

2. **Pass URL:**
   * A common approach is to redirect users to a hosted view page: `GET /api/{tenantId}/passes/{passId}/view`.
   * Use the QR code to add the pass to Apple Wallet or Google Wallet.

![Step 4: View or Download the Pass](https://3566051324-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWLc8AHXW4tdrAXUBfrYF%2Fuploads%2Fgit-blob-3be9f78345ea40d71ad0cd89adcb88b25dcbbf5b%2Fhow_to_create_passes_via_api_in_the_wallet_crew_7.png?alt=media)

## Tips and Best Practices

1. **Examples for Different Pass Types:**
   * **Loyalty Card:**

     ```json
     {
       "identifiers": {"customerId": "12345"},
       "additionalData": {"points": 150}
     }
     ```
   * **Event Ticket:**

     ```json
     {
       "identifiers": {"eventId": "concert2024"},
       "additionalData": {"seat": "A12"}
     }
     ```
   * **Coupon:**

     ```json
     {
       "extensions": {"couponCode": "DISCOUNT10"}
     }
     ```
2. **Testing:**
   * Always test API calls in a staging environment before going live.
   * Staging url: <https://admin-qa.thewalletcrew.io/>
3. **Error Handling:**
   * Ensure proper handling of API errors, such as authentication failures or invalid parameters.

## FAQ

<details>

<summary><strong>Should I use <code>Authorization</code> or <code>X-API-KEY</code>?</strong></summary>

Use `X-API-KEY`. This is the API key header used by The Wallet Crew API reference.

</details>

<details>

<summary><strong>What is <code>passType</code>?</strong></summary>

`passType` is the template name you created in The Wallet Crew. It controls design and which variables are available on the pass.

</details>

<details>

<summary><strong>What should I store on my side?</strong></summary>

Store the returned `passId`. It is the stable identifier you will use to retrieve, update, or notify the same pass later.

</details>

## Conclusion

Creating passes via The Wallet Crew API enables seamless integration with third-party systems and enhances the user experience. By following this guide, you can configure The Wallet Crew, create and manage passes, and retrieve them efficiently. For more advanced use cases, explore additional articles in the Knowledge Base.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.thewalletcrew.io/develop/guides/wallet/how-to-create-passes-via-api-in-the-wallet-crew.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
