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

# Linq

> Use Agentcard with Linq to let your iMessage agent make payments with your users' cards.

[Linq](https://linqapp.com) gives your agent a phone number on iMessage. Agentcard gives it a way to pay. Linq ships a native Agentcard integration, so the card enrollment and the payment approval render as native bubbles in the thread, and your agent gets a card to check out with.

Full reference on Linq's side: [Agentcard guide](https://docs.linqapp.com/channel/imessage/guides/agentcard/).

## How it fits together

1. Your agent receives a text through a Linq webhook (`message.received`).
2. The first time, your agent asks Linq to connect the user to Agentcard. Linq texts them a native card; they add their card and approve with Face ID.
3. When the user wants to buy, your agent creates a payment through Linq. Linq asks the user to approve, then hands your agent card credentials scoped to that purchase.
4. Your agent checks out with those credentials, in a browser or through an ecommerce API.

## Integrate

### 1. Connect your Linq account to Agentcard

Once per Linq account. Linq returns a hosted flow where you sign in with your Agentcard organization.

```bash theme={null}
curl -X POST https://api.linqapp.com/api/partner/v3/payments/providers/agentcard/connect \
  -H "Authorization: Bearer $LINQ_API_TOKEN"
```

### 2. Connect a user

Once per user, by their phone number (`handle`). Linq texts them the enrollment bubble. Wait for the `connection.created` webhook before creating payments.

```bash theme={null}
curl -X POST "https://api.linqapp.com/api/partner/v3/payments/handles/+15551234567/connect" \
  -H "Authorization: Bearer $LINQ_API_TOKEN"
```

### 3. Create a payment

When the cart is ready, create a payment with what the user will approve. Linq sends the approval bubble.

```bash theme={null}
curl -X POST https://api.linqapp.com/api/partner/v3/payments \
  -H "Authorization: Bearer $LINQ_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "handle": "+15551234567",
    "amount": 2306,
    "currency": "usd",
    "merchant": "shop.example.com"
  }'
```

### 4. Get the card and check out

When the payment's status is `ready` (webhook `payment.authorized`), fetch the credentials and complete the checkout.

```bash theme={null}
curl https://api.linqapp.com/api/partner/v3/payments/PAYMENT_ID/credentials \
  -H "Authorization: Bearer $LINQ_API_TOKEN"
```

Subscribe to `payment.authorized`, `payment.declined`, `connection.created` and `connection.revoked` so your agent reacts to facts, not to the conversation.

## Prefer to run Agentcard yourself?

You can also treat Linq as a plain messaging rail: create an Agentcard [vault session](/vault/adding-a-card) or approval link on your server and text the URL as a normal message.

```bash theme={null}
curl -X POST https://api.linqapp.com/api/partner/v3/chats \
  -H "Authorization: Bearer $LINQ_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "'"$LINQ_PHONE_NUMBER"'",
    "to": ["+15551234567"],
    "message": { "parts": [{ "type": "text", "value": "Add a card so I can buy for you: '"$VAULT_URL"'" }] }
  }'
```

The rest of the flow is then the standard one. Follow the [Vault Quickstart](/vault/quickstart) from step 2.
