# Generate QR Code

Get a payment QR code for a user — encodes a deep link that pre-fills a send form with the recipient's username and tenant.

## Overview

The QR code encodes a deep link in the format `bper://send?username={username}&tenant={tenantId}`. When scanned by another Aurea-powered app, it opens a pre-filled payment screen with the recipient already selected. The response is a base64-encoded PNG data URL ready to drop directly into an `<img>` tag.

This QR always reflects the user's **primary wallet**. If the user changes their primary wallet, generate a fresh QR code.

> 💡 Cache the QR code image in your UI — it only changes when the user's primary wallet changes. Avoid regenerating on every page load.

### `GET /v1/users/{id}/qr-code`

Authentication: bearer token required.

Returns a base64 PNG QR code encoding a deep link for receiving payments.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | User UUID |

**Responses**

`200` OK

```json
{
  "qrCode": "data:image/png;base64,iVBORw0KGgo..."
}
```

`404` Not Found

```json
{ "detail": "User not found" }
```

## Implementation

```javascript
// Display a user's payment QR code
async function showPaymentQR(token, userId) {
  const res = await fetch(
    `https://api.aureahub.com/v1/users/${userId}/qr-code`,
    { headers: { Authorization: `Bearer ${token}` } }
  );
  if (!res.ok) throw new Error('Failed to load QR code');

  const { qrCode } = await res.json();

  // Drop directly into an <img> tag — it's a data URL
  document.getElementById('payment-qr').src = qrCode;
}

// The QR encodes: bper://send?username=alice&tenant=tenant-uuid
// When scanned by another Aurea app, it opens a pre-filled send screen
```

---

Web version: https://docs.aureahub.com/#users-qr
