# Purchase phone number

Purchases a phone number.

```http
POST https://api.pozy.ai/v1/phone-numbers/purchase
```

- Area: Phone & voice / Phone Numbers
- Auth: Authorization: Bearer pz_live_...

## Request body

Content type: `application/json`

- `profileId`, string, required
- `country`, string: Default `US`
- `numberType`, string: One of `local`, `mobile`, `national`, `toll_free`
- `areaCode`, string: Matches `^\d{1,4}$`
- `claimId`, string
- `phoneNumber`, string: Matches `^\+[1-9]\d{6,14}$`
- `connectWhatsapp`, boolean: Default `true`
- `wantsSms`, boolean: Default `false`
- `wantsWhatsapp`, boolean: Default `false`
- `purchaseIntentId`, string: Up to 100 characters
- `allowMultiple`, boolean: Default `false`

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/phone-numbers/purchase" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "profileId": "6a0b6573846efc28aaa9a3ff"
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/phone-numbers/purchase", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    profileId: "6a0b6573846efc28aaa9a3ff"
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.post(
    "https://api.pozy.ai/v1/phone-numbers/purchase",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "profileId": "6a0b6573846efc28aaa9a3ff",
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200


```json
{
  "message": "Hello from Pozy",
  "checkoutUrl": "https://pozy.ai/media/example-1.jpg"
}
```
