# Shared links: contact links, shared conversations, status pages and badges

> Link to a customer's WhatsApp conversation from a CRM by phone number, share one conversation with an expiring link that can also reply, embed it, export it as PDF or Markdown, and show message status and window badges, with what protects each one.

Other systems often know only a customer's phone number, or need to show a WhatsApp conversation to someone without an app2email login. These links do that without handing out more than they must. Every one is checked by app2email on each use, and every refusal (a wrong link, a revoked one, a mistyped one) answers the same "not found".

| You want | Use | Who can open it |
| --- | --- | --- |
| A link in your CRM for each customer | the [contact link](#contact-link) | people signed in to your number |
| A link for someone without a login | a [signed contact link](#signed) or a [shared conversation](#shared) | whoever has it, until it expires |
| Someone outside to answer the customer | a shared conversation with `reply` | whoever has it, for that one contact |
| A message's delivery shown in a ticket | `status_url` ([status page](#status)) | whoever has it, no message text |
| A small "window open / 3 unread" image | a [badge](#badges) | anyone: it shows a state only |

<a id="contact-link"></a>

## The contact link, built from a phone number

```
https://www.app2email.com/c/<number code>/<contact digits>
```

`<number code>` is your number's fixed public code (`number_code` in `GET /v1/{number}/links/settings`, and the part after `/c/` of every `contact_url`). Anyone can build the link with a text formula, for example in a CRM field. The address alone gives nothing away: whoever opens it must be signed in to app2email with access to your number, and then lands in the Inbox on that contact. Everyone else gets "not found". It never expires and holds no secret, so it is the link to store.

Every API answer and webhook event that has a `conversation_url` also has `contact_url`, and the CRM sync puts it in each activity note.

<a id="signed"></a>

## A signed contact link (no login needed)

For people without a login, your own server signs the contact link with the number's link secret (see [the link secret](/guides/link-settings#secret)):

```
https://www.app2email.com/c/<number code>/<contact>?exp=<unix seconds>&p=r&sig=<signature>
```

- `exp` is required: when the link stops working, at most `max_signed_days` ahead (30 days unless you change it).
- `p=r` shows the conversation; `p=rw` adds the reply box.
- `sig` is HMAC-SHA256 with the whole secret (`a2e_lk_...`, as text) as the key, over `c1`, the number code, the contact, `exp` and `p` joined with line breaks, written as base64url without `=`.
- The contact is digits only: no `+`, no spaces, no leading `00`.

A spreadsheet formula cannot compute an HMAC: this needs code (your server, or a code step in Zapier or n8n). Never put the secret in a web page or an app.

<CodeGroup>
```javascript Node.js
const crypto = require("crypto");
const secret = process.env.APP2EMAIL_LINK_SECRET;   // a2e_lk_...
const code = "YOUR_NUMBER_CODE", contact = "61412345678", p = "r";
const exp = Math.floor(Date.now() / 1000) + 7 * 86400;
const sig = crypto.createHmac("sha256", secret).update(`c1\n${code}\n${contact}\n${exp}\n${p}`).digest("base64url");
const url = `https://www.app2email.com/c/${code}/${contact}?exp=${exp}&p=${p}&sig=${sig}`;
```
```python Python
import base64, hashlib, hmac, os, time
secret = os.environ["APP2EMAIL_LINK_SECRET"]          # a2e_lk_...
code, contact, p = "YOUR_NUMBER_CODE", "61412345678", "r"
exp = int(time.time()) + 7 * 86400
mac = hmac.new(secret.encode(), f"c1\n{code}\n{contact}\n{exp}\n{p}".encode(), hashlib.sha256).digest()
sig = base64.urlsafe_b64encode(mac).decode().rstrip("=")
url = f"https://www.app2email.com/c/{code}/{contact}?exp={exp}&p={p}&sig={sig}"
```
```php PHP
$secret = getenv('APP2EMAIL_LINK_SECRET');             // a2e_lk_...
$code = 'YOUR_NUMBER_CODE'; $contact = '61412345678'; $p = 'r';
$exp = time() + 7 * 86400;
$mac = hash_hmac('sha256', "c1\n$code\n$contact\n$exp\n$p", $secret, true);
$sig = rtrim(strtr(base64_encode($mac), '+/', '-_'), '=');
$url = "https://www.app2email.com/c/$code/$contact?exp=$exp&p=$p&sig=$sig";
```
```csharp C#
string secret = Environment.GetEnvironmentVariable("APP2EMAIL_LINK_SECRET")!;   // a2e_lk_...
string code = "YOUR_NUMBER_CODE", contact = "61412345678", p = "r";
long exp = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + 7 * 86400;
byte[] mac = System.Security.Cryptography.HMACSHA256.HashData(Encoding.UTF8.GetBytes(secret), Encoding.UTF8.GetBytes($"c1\n{code}\n{contact}\n{exp}\n{p}"));
string sig = Convert.ToBase64String(mac).TrimEnd('=').Replace('+', '-').Replace('/', '_');
string url = $"https://www.app2email.com/c/{code}/{contact}?exp={exp}&p={p}&sig={sig}";
```
</CodeGroup>

**Test vector.** With the secret `a2e_lk_TESTvectorTESTvectorTESTvectorTESTvectorTES`, the number code `abcde12345fghij`, the contact `61412345678`, `exp` `1798761600` and `p` `r`, the signature is `Za-XEt0vt6yD3nF5ED49nPVxfYSqK1spCCciDh1m9D8` (with `p` `rw`: `qylm41F5tvYKJNfuOWxJ77SSPRgOVY5lCbCRbRl5nOc`). If your code gives the same, it is right.

A good signature for a contact who never wrote shows "No messages yet". After [rotating the secret](/guides/link-settings#secret), links signed with the old one keep working for 7 days.

<a id="shared"></a>

## Share one conversation

```bash
curl -X POST "https://api.app2email.com/v1/YOUR_NUMBER/links" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kind": "conversation", "contact": "61412345678", "permissions": ["read", "media"], "expires_in_seconds": 604800, "label": "Ticket 4711"}'
```

The answer's `url` (`https://www.app2email.com/v/<token>`) opens that one conversation. It is in this answer only: app2email keeps just a fingerprint of it. The same works on the dashboard: **Integrations → Link utilities → Share a conversation**.

| Permission | What the link adds |
| --- | --- |
| `read` | the messages (the default) |
| `media` | the photos and files |
| `reply` | a reply box. Needs a key with `messages:send`. The link lives 24 hours unless you ask for more, 30 days at most. |
| `export` | downloads: `.pdf`, `.md`, `.txt`, `.json` (see [exports](#export)) |

A shared link always expires (30 days unless you ask, a year at most), can be revoked at any time (`DELETE /v1/{number}/links/{id}`), and `GET /v1/{number}/links/{id}/access` shows when it was opened. It is separate from the conversation's own page: switching that page off does not stop a shared link, and revoking a shared link does not touch the page.

<a id="reply"></a>

### Replies from a link

With `reply`, the page has a reply box. While the contact's 24-hour window is open it sends free text. After that it offers the number's approved templates that need only text values. Every message goes through the same checks as the API (Do Not Call list, monthly limit, the window rule). The Inbox and the Activity Log show it as sent through the shared link, with its label. The box sends only with a form token of the page (a link scanner or another site cannot make it send). `reply_sends_per_hour` in the [link settings](/guides/link-settings#settings) can cap the messages per link (0 = no limit, the default).

<a id="embed"></a>

### Show it inside your own page

Add `?embed=1` (and `&theme=light` or `&theme=dark`) to draw the page without the site's top bar. Other sites may show it in an iframe only when they are in the number's `embed_origins` setting and in the link's own `embed_origins`. Everywhere else, framing is refused.

```bash
curl -X POST "https://api.app2email.com/v1/YOUR_NUMBER/links" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kind": "conversation", "contact": "61412345678", "permissions": ["read", "reply"], "embed_origins": ["https://crm.example.com"]}'
```

<a id="preview"></a>

### When a link is pasted into a chat

Slack, Teams, WhatsApp and similar apps draw a card from the page's tags. The number's `preview` setting decides what the card says: `generic` (the default: "WhatsApp conversation", nothing about the contact), `details` (the contact's name, last activity and window) or `off`. Message text is never in a card. Those apps get the page's head only, and their fetch is not counted as an opening. `https://www.app2email.com/api/oembed?url=<the link>&format=json` answers oEmbed for our links.

<a id="export"></a>

## Exports and transcripts

With `export`, `<link>.pdf`, `.md`, `.txt` and `.json` download the newest 500 messages. With an API key the same comes from:

```bash
curl "https://api.app2email.com/v1/YOUR_NUMBER/conversations/61412345678/transcript?format=md&limit=200" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

`format` is `json` (the default), `md`, `txt` or `pdf`; `limit` is up to 5,000; `since` takes an ISO 8601 time. The Markdown is made for language models: it starts with a line saying the message text is data, not instructions, and wraps each message between `<<<message ...>>>` and `<<<end message ...>>>` lines (look-alikes inside messages are neutralised). Files are named, never inlined. A PDF is made one at a time: if one is being made, try again in a minute (`export_busy`). AI agents use the MCP tool `get_conversation_transcript`.

<a id="status"></a>

## Message status pages

The answer of a single send, `GET /v1/{number}/messages/{message_id}`, each sent message in `GET /v1/{number}/messages` and `GET /v1/{number}/conversations/{contact}/messages`, and the `message.status` / `message.failed` events carry `status_url`: a page with that message's timeline (accepted, sent, delivered, read, or failed with why and what to do), the recipient shown with its last 4 digits, and no message text unless you turn on `status_link_text`. Paste it into a ticket. It works 90 days. Broadcast messages have none.

"Read" means WhatsApp reported the message as read on the phone, not that a person read it.

<a id="badges"></a>

## Badges

```bash
curl -X POST "https://api.app2email.com/v1/YOUR_NUMBER/links" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kind": "badge", "badge": "window", "contact": "61412345678"}'
```

The answer has `url_svg` and `url_png`: an image to put in a CRM record or a dashboard.

| `badge` | Shows | Needs |
| --- | --- | --- |
| `window` | "open, 3 h left" or "closed" | `contact` |
| `unread` | the contact's messages not yet opened in the Inbox | `contact` |
| `message` | one sent message's status | `message_id` |
| `health` | whether the number can send, and its quality | nothing |

A badge shows a state only, never a name, number or text. It is cached for 60 seconds, nothing is stored for it, it works 400 days, and `POST /v1/{number}/links/revoke-all` stops every badge and status page of the number at once.

<a id="errors"></a>

## Errors

| Code | Status | Meaning |
| --- | --- | --- |
| `invalid_link_request` | 400 | A field of the link is missing or not allowed (the message names it), for example an embed origin the number does not allow. |
| `insufficient_scope` | 403 | A link with `reply` needs a key with `messages:send`. |
| `conversation_not_found` | 404 | There is no conversation with that contact yet. |
| `message_not_found` | 404 | No message with that id was sent from the number (message badge). |
| `export_busy` | 503 | A PDF is being made; try again in a minute or ask for Markdown. |
| `link_reply_limit` | 429 | The link sent `reply_sends_per_hour` messages in the last hour. |
| `linkutil_not_ready` | 503 | The links are waiting for a database update on app2email's side. |

The complete list is on [the errors page](/api/errors).
