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

# POST /wpp-url/generate

> Generate WhatsApp click-to-chat links for any phone number, with automatic E.164 normalisation and optional pre-filled message URL-encoding.

## Endpoint

```
POST https://api.bunny.build/api/v1/wpp-url/generate
```

## Authentication

| Header         | Required | Value                    |
| -------------- | -------- | ------------------------ |
| `X-API-Key`    | Yes      | Your API key (`bun_...`) |
| `Content-Type` | Yes      | `application/json`       |

## Overview

Generate WhatsApp click-to-chat links for any phone number. Bunny normalises the number to international E.164 format and returns a direct `wa.me` link. If a message is provided, it also returns a pre-filled version with the message URL-encoded.

## Use cases

* Add "Chat on WhatsApp" buttons to landing pages and product pages
* Generate WhatsApp support links from your CRM
* Build WhatsApp marketing campaign links with pre-filled messages
* Automate onboarding flows that open WhatsApp conversations

## Details

Phone numbers can be passed with or without country code, spaces, dashes, or parentheses. All formats are normalised automatically. Brazilian numbers (10 or 11 digits without country code) get the `+55` prefix added automatically.

## Request body

| Field     | Type   | Required | Description                                          |
| --------- | ------ | -------- | ---------------------------------------------------- |
| `phone`   | string | Yes      | Phone number in E.164 format (e.g. `+5511999999999`) |
| `message` | string | No       | Pre-filled message text (URL-encoded automatically)  |

### Example

```json theme={null}
{
  "phone": "+5511999999999",
  "message": "Hello, I have a question!"
}
```

## Response

### 200 OK

| Field               | Type   | Description                                                                            |
| ------------------- | ------ | -------------------------------------------------------------------------------------- |
| `phone_normalized`  | string | Phone number normalized to digits only (E.164 without the `+`)                         |
| `link`              | string | WhatsApp click-to-chat URL (`https://wa.me/{phone_normalized}`)                        |
| `link_with_message` | string | Pre-filled link with the message URL-encoded. Only present when `message` was provided |

**Example (without message)**

```json theme={null}
{
  "phone_normalized": "5511999999999",
  "link": "https://wa.me/5511999999999"
}
```

**Example (with message)**

```json theme={null}
{
  "phone_normalized": "5511999999999",
  "link": "https://wa.me/5511999999999",
  "link_with_message": "https://wa.me/5511999999999?text=Hello%2C%20I%20have%20a%20question%21"
}
```

### 401 Unauthorized

```json theme={null}
{
  "detail": "Missing API key. Include X-API-Key header."
}
```

### 402 Payment Required

```json theme={null}
{
  "detail": "Monthly quota exceeded. Upgrade your plan."
}
```

### 422 Unprocessable Entity

Invalid phone number.

```json theme={null}
{
  "detail": "Invalid phone number format"
}
```

### 429 Too Many Requests

```json theme={null}
{
  "detail": "Rate limit exceeded. Try again in 60 seconds."
}
```

## cURL example

```bash theme={null}
curl -X POST https://api.bunny.build/api/v1/wpp-url/generate \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"phone": "+5511999999999", "message": "Hello, I have a question!"}'
```
