import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "zudoku/ui/Card";
import { Button } from "zudoku/ui/Button";

## What is OTP API?

The OTP (One-Time Password) API provides secure authentication and verification capabilities for your applications. Use OTP codes to verify user identities, secure transactions, enable two-factor authentication (2FA), and protect sensitive operations. Our API delivers OTP codes via SMS with high reliability and fast delivery times.

## How It Works

The OTP API generates and delivers time-limited, single-use verification codes:

### OTP Generation

- **Automatic generation**: Secure, randomly generated codes
- **Configurable length**: Choose between 4-8 digit codes
- **Expiration time**: Set custom expiration periods (default: 5 minutes)
- **One-time use**: Codes are automatically invalidated after use

### OTP Delivery

- **SMS delivery**: Codes are sent via SMS to the user's phone number
- **Fast delivery**: Average delivery time under 3 seconds
- **Global reach**: Send OTP codes to phone numbers worldwide
- **Delivery confirmation**: Track delivery status for each OTP

### OTP Verification

- **Secure validation**: Verify codes server-side for maximum security
- **Rate limiting**: Built-in protection against brute force attacks
- **Usage tracking**: Monitor OTP generation and verification attempts
- **Automatic cleanup**: Expired codes are automatically removed

## Key Features

<div className="not-prose my-6 grid grid-cols-1 gap-4 md:grid-cols-2">
  <Card>
    <CardHeader>
      <CardTitle>High Security</CardTitle>
    </CardHeader>
    <CardContent>
      <p>Cryptographically secure random number generation, time-limited codes, and one-time use enforcement for maximum security.</p>
    </CardContent>
  </Card>

  <Card>
    <CardHeader>
      <CardTitle>Fast Delivery</CardTitle>
    </CardHeader>
    <CardContent>
      <p>Average delivery time under 3 seconds with 99%+ delivery rate, ensuring users receive codes quickly and reliably.</p>
    </CardContent>
  </Card>

  <Card>
    <CardHeader>
      <CardTitle>Flexible Configuration</CardTitle>
    </CardHeader>
    <CardContent>
      <p>Customize code length (4-8 digits), expiration time, and message templates to fit your application's needs.</p>
    </CardContent>
  </Card>

  <Card>
    <CardHeader>
      <CardTitle>Rate Limiting</CardTitle>
    </CardHeader>
    <CardContent>
      <p>Built-in protection against abuse with configurable rate limits for OTP generation and verification attempts.</p>
    </CardContent>
  </Card>

  <Card>
    <CardHeader>
      <CardTitle>Use Cases</CardTitle>
    </CardHeader>
    <CardContent>
      <p>Perfect for user registration, login verification, password reset, transaction confirmation, and two-factor authentication.</p>
    </CardContent>
  </Card>

  <Card>
    <CardHeader>
      <CardTitle>Analytics & Monitoring</CardTitle>
    </CardHeader>
    <CardContent>
      <p>Track OTP generation rates, delivery success, verification attempts, and identify potential security issues.</p>
    </CardContent>
  </Card>
</div>

## Common Use Cases

### User Registration
Verify phone numbers during account creation to ensure valid contact information and reduce fake accounts.

### Login Verification
Add an extra layer of security to user logins with two-factor authentication (2FA).

### Password Reset
Securely verify user identity before allowing password changes.

### Transaction Confirmation
Confirm sensitive operations like payments, transfers, or account changes.

### Account Recovery
Verify user identity when recovering locked or compromised accounts.

## Authentication

The OTP API uses Bearer Token authentication:

- **Header**: `Authorization: Bearer {your_api_token}`
- **Token**: Obtain your API token from [OmaxTelecom Console](https://console.omaxtelecom.com)

## Getting Started

To start using the OTP API:

1. **Get your API credentials**: Log in to [OmaxTelecom Console](https://console.omaxtelecom.com) and navigate to your API settings to obtain your API token.

2. **Choose your environment**:
   - **Sandbox**: For testing and development
   - **Production**: For live operations

3. **Review the API documentation**: Explore all available endpoints, request/response formats, and authentication requirements.

4. **Implement OTP flow**: Start with OTP generation, then add verification logic to your application.

## Security Best Practices

- Always verify OTP codes server-side, never client-side
- Set appropriate expiration times (recommended: 5-10 minutes)
- Implement rate limiting to prevent abuse
- Log verification attempts for security monitoring
- Use HTTPS for all API requests
- Store OTP codes securely and never log them

## API Documentation

<div className="not-prose my-6">
  <Card>
    <CardHeader>
      <CardTitle>Complete API Reference</CardTitle>
      <CardDescription>
        Explore the full API documentation with interactive examples, request/response schemas, and authentication details.
      </CardDescription>
    </CardHeader>
    <CardContent>
      <Button asChild>
        <a href="/api/otp">View API Documentation →</a>
      </Button>
    </CardContent>
  </Card>
</div>

## Need Help?

If you have any questions or need assistance with the OTP API, please contact our support team at [support@omaxtelecom.com](mailto:support@omaxtelecom.com).
