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

# Rich Link Previews

> Send a link that iMessage shows as a preview card.

Send a URL as a `link` part and iMessage shows it as a preview card. Over RCS and SMS, how the link looks depends on the recipient's phone.

## Send a link

```bash curl theme={null}
curl https://api.blujay.io/v1/chats/chat_abc123/messages \
  -H "Authorization: Bearer blu_your_api_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042-tracking" \
  -d '{ "message": { "parts": [{ "type": "link", "value": "https://example.com/orders/1042" }] } }'
```

```javascript Node.js theme={null}
const response = await fetch("https://api.blujay.io/v1/chats/chat_abc123/messages", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BLUJAY_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "order-1042-tracking",
  },
  body: JSON.stringify({
    message: { parts: [{ type: "link", value: "https://example.com/orders/1042" }] },
  }),
});
console.log(response.status, (await response.json()).data.message.id);
```

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

response = requests.post(
    "https://api.blujay.io/v1/chats/chat_abc123/messages",
    headers={
        "Authorization": f"Bearer {os.environ['BLUJAY_API_KEY']}",
        "Idempotency-Key": "order-1042-tracking",
    },
    json={"message": {"parts": [{"type": "link", "value": "https://example.com/orders/1042"}]}},
    timeout=60,
)
print(response.status_code, response.json()["data"]["message"]["id"])
```

## Constraints

* **`https://` only**, up to 2,048 characters.
* **The link goes alone.** A `link` part must be the only part in its message. Send any text as a separate message.
* **Not before the contact replies.** Until the person replies to your number, links are rejected, in a `link` part or inside text. See [Sending Rules](https://docs.blujay.io/messaging/sending-rules.md).
* **Follow-ups only.** `POST /v1/chats` never accepts a `link` part ([`FIRST_MESSAGE_LINK_NOT_ALLOWED`](https://docs.blujay.io/errors/first-message-link-not-allowed)). Send it into the chat.

## Related

> [card] [Sending Messages](https://docs.blujay.io/messaging/send-messages.md)
>
> Every part type and how to send it.

> [card] [Sending Rules](https://docs.blujay.io/messaging/sending-rules.md)
>
> What you can send before the contact replies.


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