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

# Send OTP

> Dispatches a 6-digit verification code to a WhatsApp number.

## Request Body

<ParamField body="to" type="string" required>
  The recipient's phone number in strict E.164 format (e.g., `+919876543210`).
</ParamField>

<ParamField body="app" type="string" required>
  The name of your application, used for branding in the message.
</ParamField>

<Note>
  **Expiry**: The dispatched OTP code is valid for exactly **10 minutes** from the time of generation.
</Note>

### Request Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://otpedge.com/api/v1/send-otp \
       -H "Authorization: Bearer your_api_key_here" \
       -H "Content-Type: application/json" \
       -d '{
         "to": "+919876543210",
         "app": "MySecureApp"
       }'
  ```

  ```javascript JavaScript (Fetch) theme={null}
  const response = await fetch('https://otpedge.com/api/v1/send-otp', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      to: '+919876543210',
      app: 'MySecureApp'
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python (Requests) theme={null}
  import requests

  url = "https://otpedge.com/api/v1/send-otp"
  headers = {
      "Authorization": "Bearer your_api_key_here",
      "Content-Type": "application/json"
  }
  payload = {
      "to": "+919876543210",
      "app": "MySecureApp"
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```php PHP (cURL) theme={null}
  <?php
  $ch = curl_init("https://otpedge.com/api/v1/send-otp");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
      "to" => "+919876543210",
      "app" => "MySecureApp"
  ]));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer your_api_key_here",
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);
  echo $response;
  ?>
  ```

  ```go Go (net/http) theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"net/http"
  )

  func main() {
  	url := "https://otpedge.com/api/v1/send-otp"
  	payload := map[string]string{
  		"to":  "+919876543210",
  		"app": "MySecureApp",
  	}
  	jsonPayload, _ := json.Marshal(payload)

  	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload))
  	req.Header.Set("Authorization", "Bearer your_api_key_here")
  	req.Header.Set("Content-Type", "application/json")

  	client := &http.Client{}
  	res, err := client.Do(req)
  	if err != nil {
  		fmt.Println(err)
  		return
  	}
  	defer res.Body.Close()

  	fmt.Println("Response Status:", res.Status)
  }
  ```
</CodeGroup>

### Response Examples

<ResponseExample>
  ```json 200 OK (Dispatched) theme={null}
  {
    "success": true,
    "req_id": "oe_a1b2c3d4e5f6",
    "status": "dispatched"
  }
  ```

  ```json 429 Too Many Requests (Cooldown) theme={null}
  {
    "error": "Spam Prevention: Too many requests to this number. Please wait 60 seconds.",
    "code": "SPAM_COOLDOWN"
  }
  ```
</ResponseExample>
