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

> ## Agent Instructions
> Agentcard is for companies whose agent buys for their users. Pick one path: the opencommerce SDK (@agent-cards/commerce-sdk) gives your agent one buy tool that finds the product, builds the cart, gets the user's approval and places the order at real stores; the Agentcard SDK (@agent-cards/sdk) pays with the user's own card when your agent already shops in a browser (Browser Use, Kernel, Browserbase, Anchor or Notte); the Purchase API (POST /buy) does the same purchase flow over plain HTTP in any language; Issuing gives the agent its own card.
> Start with `npx agent-cards init` in the app's folder (Node 22 or later). No invite is needed: it creates your Agentcard account if you don't have one, installs the opencommerce SDK and puts the credentials in the env file, kept out of git. From a coding agent, run `npx agent-cards init --print --categories all --implementation tool --wallet vault --skip-install` to get the setup steps to apply yourself.
> Vault is by invitation: request it at https://agentcard.com/get-started?utm_source=docs&utm_medium=llms&utm_campaign=agent-instructions. opencommerce needs no invite.
> Never ask a user for a card number, expiry date or CVV in chat. Send them the Vault link; they add their card on Agentcard's page, and the agent never sees the number.
> Every purchase is approved by the user, with a passkey or Face ID, or by an auto-approval they granted. An approval covers one merchant and one exact total. If the total changes, ask again. When a result says the user already said yes, don't ask again.
> `init` writes PRODUCTION credentials, which place real orders, so test in sandbox first. For opencommerce, run `npx agent-cards credentials --mode sandbox` and put the two lines it prints in place of the production ones in the env file `init` wrote, because that command only prints them; sandbox then runs the whole flow against real stores and stops before payment, so no order is placed and nobody is charged. For Vault and Issuing, sandbox credentials issue test cards that no real merchant accepts; try the checkout against shop.agentcard.sh, a test store on Stripe test mode.
> Tell the user an order is placed only after Agentcard reports it placed.
> Vault is free up to 5,000 users (https://agentcard.com/pricing). opencommerce takes 1% of each completed order. Full docs in one file: https://docs.agentcard.com/llms-full.txt

# Add to Apple Pay or Google Pay

> Get the encrypted data Apple Pay or Google Pay takes to add a card to your user's phone.

Ask from your server when your user taps "Add to Apple Wallet" or "Add to Google Pay" in your app, and pass the answer to your app. The answer holds the card encrypted for the wallet, never the card number, and works for one add only. [Add a card to Apple Pay or Google Pay](https://docs.agentcard.com/issuing/adding-to-phone-wallets.md) walks through both phones.

> [!WARNING]
>
> This answers `wallet_provisioning_not_enabled` for every card today, because phone wallets are not switched on for Agentcard cards yet. See [Add a card to Apple Pay or Google Pay](https://docs.agentcard.com/issuing/adding-to-phone-wallets.md) for what your users can do in the meantime.

**card\_id** `string` *required*

A multi-use card your company issued, open, in the mode of your access token.

**wallet** `string` *required*

`apple_pay` or `google_pay`.

**device\_id** `string` *required*

An id your app keeps for the phone the card goes to.

**certificates** `string[]`

Apple Pay only, required. The certificates Apple handed your app, each in base64.

**nonce** `string`

Apple Pay only, required. The nonce Apple handed your app, in base64.

**nonce\_signature** `string`

Apple Pay only, required. The nonce signature Apple handed your app, in base64.

**activation\_data** `string`

Apple Pay. Base64, for `PKAddPaymentPassRequest.activationData`.

**encrypted\_pass\_data** `string`

Apple Pay. Base64, for `PKAddPaymentPassRequest.encryptedPassData`.

**ephemeral\_public\_key** `string`

Apple Pay. Base64, for `PKAddPaymentPassRequest.ephemeralPublicKey`.

**opaque\_payment\_card** `string`

Google Pay. Base64, for `PushTokenizeRequest.setOpaquePaymentCard`.

**network** `string`

Google Pay. `visa`.

**token\_service\_provider** `string`

Google Pay. `visa`.

**last4** `string`

Google Pay. The card's last four digits, for `setLastDigits`.

```bash Apple Pay theme={null}
curl -X POST https://api.agentcard.sh/api/v2/cards/card_22943fc47c3865e20527c7a5/wallet_provisioning \
  -H "Authorization: Bearer $ORG_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"wallet":"apple_pay","device_id":"install-6f1c2a","certificates":["MIIEnzCCBEWgAwIB..."],"nonce":"3q2+7w==","nonce_signature":"MEUCIQDx..."}'
```

```bash Google Pay theme={null}
curl -X POST https://api.agentcard.sh/api/v2/cards/card_22943fc47c3865e20527c7a5/wallet_provisioning \
  -H "Authorization: Bearer $ORG_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"wallet":"google_pay","device_id":"wallet-9d2c47e1"}'
```

```json Apple Pay theme={null}
{
  "object": "wallet_provisioning",
  "card_id": "card_22943fc47c3865e20527c7a5",
  "wallet": "apple_pay",
  "activation_data": "TUFDQUNUSVZB...",
  "encrypted_pass_data": "eyJlbmNyeXB0ZWRE...",
  "ephemeral_public_key": "BEc6Hc2nBvRk..."
}
```

```json Google Pay theme={null}
{
  "object": "wallet_provisioning",
  "card_id": "card_22943fc47c3865e20527c7a5",
  "wallet": "google_pay",
  "opaque_payment_card": "eyJjYXJkSW5mbyI6...",
  "network": "visa",
  "token_service_provider": "visa",
  "last4": "6803"
}
```

The answer carries `Cache-Control: no-store`. Apple's nonce expires within a few minutes, so ask as soon as your app sends it.

Agentcard refuses a card that cannot go in a wallet before anything reaches the phone. A single-use card answers `409`:

```json theme={null}
{
  "error": {
    "code": "card_not_reusable",
    "message": "Only a multi-use card can go in a phone wallet. A single-use card closes after its first charge."
  }
}
```

| Status | Code | What it means | What to do |
| - | - | - | - |
| 400 | `invalid_request` | A field is missing or is not base64. | Send the fields shown above for your wallet. |
| 404 | `card_not_found` | No issued card with that id on your company, in this mode. | Check the card id and the mode of your access token. |
| 409 | `card_not_reusable` | The card is single-use. | Issue a multi-use card with `"type": "multi_use"`. |
| 409 | `card_not_open` | The card is paused, closed or still being created. | Resume the card, or wait until its status reads `open`. |
| 409 | `wallet_provisioning_unavailable` | The card is a test-mode card, or was made from a card the user added. | Use a live card your company issued. |
| 502 | `wallet_provisioning_failed` | The card network did not return the wallet data. | Open the add-card screen again and retry. |
| 503 | `wallet_provisioning_not_enabled` | The card network has not enabled phone wallets for your cards yet. | Retry later, or ask Agentcard support. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.