# Create a tracked iMessage opt-in link

Creates a tracked iMessage opt-in link.

```http
POST https://api.pozy.ai/v1/imessage/senders/{senderId}/opt-in-links
```

- Area: Messaging / iMessage
- Auth: Authorization: Bearer pz_live_...

## Path parameters

- `senderId` (string, required)

## Request body

Content type: `application/json`

- `body`, string, required: Up to 500 characters
- `parameters`, map of string
- `optInCode`, string: 3 to 8 characters

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/imessage/senders/68ef6f94df13738fb25f1e94/opt-in-links" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "body": "string"
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/imessage/senders/68ef6f94df13738fb25f1e94/opt-in-links", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    body: "string"
  }),
});
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/imessage/senders/68ef6f94df13738fb25f1e94/opt-in-links",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "body": "string",
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `success`, boolean
- `link`, object
  - `id`, string
  - `imessage`, string
  - `sms`, string: Can be null
  - `whatsapp`, string: Can be null
  - `url`, string

```json
{
  "success": true,
  "link": {
    "id": "6bfebd43ddc270f6d2c56fc5",
    "imessage": "Hello from Pozy",
    "sms": "string",
    "whatsapp": "string",
    "url": "https://pozy.ai/media/example-1.jpg"
  }
}
```
