> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keebai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /v1/loyalty/memberships/{id}/passes/apple/link

> Issue the Apple Wallet pass for a membership and get a public download link for the .pkpass.

Issues the Apple Wallet card for a membership and returns a **public download link** for the `.pkpass` file. Opening it on an iPhone triggers the native "Add to Apple Wallet" flow.

This is the symmetric counterpart to [the Google save link](/dev/endpoints/loyalty-pass-google): a URL you can put in a QR code, a WhatsApp message, or a button, rather than a binary you have to host yourself.

## Endpoint

```
POST https://api.keebai.com/v1/loyalty/memberships/{id}/passes/apple/link
```

## Required scope

`loyalty:write`

## Headers

| Header          | Required | Value                    |
| --------------- | -------- | ------------------------ |
| `Authorization` | Yes      | `Bearer kbai_pk_<token>` |

## Path parameters

| Parameter | Type     | Description                |
| --------- | -------- | -------------------------- |
| `id`      | `string` | The membership `ObjectId`. |

No body.

## Example request

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.keebai.com/v1/loyalty/memberships/6650aaaa1111bbbb2222cccc/passes/apple/link \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ```

  ```js JavaScript theme={null}
  const response = await fetch(
    "https://api.keebai.com/v1/loyalty/memberships/6650aaaa1111bbbb2222cccc/passes/apple/link",
    {
      method: "POST",
      headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` },
    },
  );
  const { download_url } = await response.json();
  ```

  ```python Python theme={null}
  import os, requests

  resp = requests.post(
      "https://api.keebai.com/v1/loyalty/memberships/6650aaaa1111bbbb2222cccc/passes/apple/link",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      timeout=20,
  )
  resp.raise_for_status()
  download_url = resp.json()["download_url"]
  ```
</CodeGroup>

## Response

### 201 Created

```json theme={null}
{
  "download_url": "https://passkit.keebai.com/api/v1/passkit/shared/8f3a2b1c4d5e6f70"
}
```

### 400 Bad Request

The program has no published wallet template, or Apple Wallet credentials are not configured for this deployment — see the notes.

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `loyalty:write` scope.

### 404 Not Found

No membership with that id in your company.

### 502 Bad Gateway

The loyalty service is unreachable.

## Operational notes

<Warning>
  **The download link is unauthenticated by design.** It carries an opaque share token that resolves the pass on its own — anyone holding the URL can download that customer's card. Send it to the customer directly and do not put it anywhere public or indexable.
</Warning>

* **A published wallet template is required**, same as for Google. Without one the call fails with `400 no published wallet template for this program`.
* **Apple Wallet needs signing credentials to be loaded.** They are provisioned out of band, separately from Google's. If they are absent, the call returns `400` explaining so — Google Wallet issuance can be working while Apple is not.
* **Calling twice reuses the existing pass.** The link stays valid; reissue if the customer lost it.
* **The raw `.pkpass` binary is not exposed through the public API.** This surface is JSON, and the download link covers the same use case — same reasoning as media download.
* **Once added, the card stays in sync.** Ledger movements refresh the balance on the customer's phone without another call.


## OpenAPI

````yaml POST /v1/loyalty/memberships/{id}/passes/apple/link
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/loyalty/memberships/{id}/passes/apple/link:
    post:
      tags:
        - loyalty
      summary: Emitir el link de descarga del pase de Apple Wallet
      description: >-
        Devuelve un link público de descarga del .pkpass, apto para QR o para
        mandar por WhatsApp. Requiere que las credenciales de Apple Wallet estén
        cargadas; si no, responde 400.
      operationId: PublicLoyaltyController_issueApplePassLink
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApplePassLinkDto'
      security:
        - PAT: []
components:
  schemas:
    PublicApplePassLinkDto:
      type: object
      properties:
        download_url:
          type: string
          description: >-
            Link público de descarga del .pkpass. Sirve para QR, WhatsApp o
            copiar y pegar
      required:
        - download_url
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````