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

# Generate OTP Link

> Create WhatsApp magic links for passwordless authentication in Laravel.

Create a passwordless flow: generate a WhatsApp link that pre-fills a message with a unique code. When the user taps **Send** in WhatsApp, you get the verification event via callbacks. Use the Laravel SDK method to keep things concise.

## Parameters

| Field            | Type   | Required | Description                                                 |
| ---------------- | ------ | -------- | ----------------------------------------------------------- |
| expires          | int    | no       | TTL in seconds (default `1800`).                            |
| name             | string | no       | Your app name displayed in messages.                        |
| message.prompt   | string | yes      | Text pre-filled in the WhatsApp link.                       |
| message.success  | string | yes      | Reply when verification succeeds. Use `{link}` placeholder. |
| message.failed   | string | yes      | Reply when verification fails.                              |
| message.expired  | string | yes      | Reply when the link expired.                                |
| callback.success | string | no       | Webhook URL for successful verification.                    |
| callback.failed  | string | no       | Webhook URL for failed verification.                        |

## Generate the link

```php theme={null}
use Hypersender\Hypersender;

$response = Hypersender::otp()->generateLink([
  'expires' => 900,
  'name' => 'YourApp',
  'message' => [
    'prompt' => 'Give me link to login at YourApp',
    'success' => 'Welcome! Here is your login link: {link}',
    'failed' => 'Login failed. Please try again.',
    'expired' => 'This link expired. Request a new one.',
  ],
  'callback' => [
    'success' => 'https://yourdomain.com/api/otp/success',
    'failed' => 'https://yourdomain.com/api/otp/failed',
  ],
]);

$whatsappLink = $response['whatsapp_link'] ?? null;
```

Send `whatsappLink` via email, SMS, or in-app notification. When the user clicks it, WhatsApp opens with the prompt + code. Handle callbacks to finalize the login.

<Warning>
  Secure your callback endpoints (HTTPS + auth) and invalidate links after use.
</Warning>

<Frame>
  <img src="https://mintcdn.com/hypersender/heaRhbtv5g__uNmh/images/docs/whatsapp/img/send-otp-link-code.png?fit=max&auto=format&n=heaRhbtv5g__uNmh&q=85&s=eb36b5cdf7ee9d8baa93c7cc28ed103d" alt="Send OTP Link Code" width="1206" height="692" data-path="images/docs/whatsapp/img/send-otp-link-code.png" />
</Frame>
