Send OTP
curl --request POST \
--url https://webhook.cocoonmail.com/webhook/otp/send \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template_uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": [
"jsmith@example.com"
],
"whatsapp_number": [
"<string>"
]
},
"otp_channel": "whatsapp",
"otp": 123,
"sender": {
"email_sender": "jsmith@example.com",
"whatsapp_sender": "<string>"
}
}
'import requests
url = "https://webhook.cocoonmail.com/webhook/otp/send"
payload = {
"template_uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": ["jsmith@example.com"],
"whatsapp_number": ["<string>"]
},
"otp_channel": "whatsapp",
"otp": 123,
"sender": {
"email_sender": "jsmith@example.com",
"whatsapp_sender": "<string>"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
template_uuid: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
to: {email: ['jsmith@example.com'], whatsapp_number: ['<string>']},
otp_channel: 'whatsapp',
otp: 123,
sender: {email_sender: 'jsmith@example.com', whatsapp_sender: '<string>'}
})
};
fetch('https://webhook.cocoonmail.com/webhook/otp/send', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://webhook.cocoonmail.com/webhook/otp/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template_uuid' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'to' => [
'email' => [
'jsmith@example.com'
],
'whatsapp_number' => [
'<string>'
]
],
'otp_channel' => 'whatsapp',
'otp' => 123,
'sender' => [
'email_sender' => 'jsmith@example.com',
'whatsapp_sender' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://webhook.cocoonmail.com/webhook/otp/send"
payload := strings.NewReader("{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://webhook.cocoonmail.com/webhook/otp/send")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://webhook.cocoonmail.com/webhook/otp/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://webhook.cocoonmail.com/webhook/otp/send");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);using RestSharp;
var options = new RestClientOptions("https://webhook.cocoonmail.com/webhook/otp/send");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);{
"success": true,
"message": "OTP sent successfully"
}
Send OTP
Send OTP
This endpoint sends an OTP via WhatsApp or Email using a template.
POST
/
webhook
/
otp
/
send
Send OTP
curl --request POST \
--url https://webhook.cocoonmail.com/webhook/otp/send \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template_uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": [
"jsmith@example.com"
],
"whatsapp_number": [
"<string>"
]
},
"otp_channel": "whatsapp",
"otp": 123,
"sender": {
"email_sender": "jsmith@example.com",
"whatsapp_sender": "<string>"
}
}
'import requests
url = "https://webhook.cocoonmail.com/webhook/otp/send"
payload = {
"template_uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": ["jsmith@example.com"],
"whatsapp_number": ["<string>"]
},
"otp_channel": "whatsapp",
"otp": 123,
"sender": {
"email_sender": "jsmith@example.com",
"whatsapp_sender": "<string>"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
template_uuid: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
to: {email: ['jsmith@example.com'], whatsapp_number: ['<string>']},
otp_channel: 'whatsapp',
otp: 123,
sender: {email_sender: 'jsmith@example.com', whatsapp_sender: '<string>'}
})
};
fetch('https://webhook.cocoonmail.com/webhook/otp/send', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://webhook.cocoonmail.com/webhook/otp/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template_uuid' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'to' => [
'email' => [
'jsmith@example.com'
],
'whatsapp_number' => [
'<string>'
]
],
'otp_channel' => 'whatsapp',
'otp' => 123,
'sender' => [
'email_sender' => 'jsmith@example.com',
'whatsapp_sender' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://webhook.cocoonmail.com/webhook/otp/send"
payload := strings.NewReader("{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://webhook.cocoonmail.com/webhook/otp/send")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://webhook.cocoonmail.com/webhook/otp/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://webhook.cocoonmail.com/webhook/otp/send");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);using RestSharp;
var options = new RestClientOptions("https://webhook.cocoonmail.com/webhook/otp/send");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"template_uuid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": [\n \"jsmith@example.com\"\n ],\n \"whatsapp_number\": [\n \"<string>\"\n ]\n },\n \"otp_channel\": \"whatsapp\",\n \"otp\": 123,\n \"sender\": {\n \"email_sender\": \"jsmith@example.com\",\n \"whatsapp_sender\": \"<string>\"\n }\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);{
"success": true,
"message": "OTP sent successfully"
}
Send OTP
Use this endpoint to send an One-Time Password (OTP) to a user via WhatsApp or Email. This endpoint requires a template UUID and recipient details.Request Body
to: An object containing the recipient’s information.email: A list of recipient email addresses.whatsapp_number: A list of recipient WhatsApp numbers.
otp_channel: The channel through which the OTP should be sent (emailorwhatsapp).template_uuid: The unique identifier of the template to be used for the OTP.subject: The subject line for the OTP message.otp: The One-Time Password to send.sender: An object containing sender details.email_sender: The sender’s email address.whatsapp_sender: The sender’s WhatsApp number.
Response
The API will return a success message if the OTP is queued for sending.{
"success": true,
"message": "OTP sent successfully"
}
Authorizations
Use your API key with the 'Bearer ' prefix
Body
application/json
Recipient information. Use 'email' for Email channel or 'whatsapp_number' for WhatsApp channel.
Show child attributes
Show child attributes
Channel for OTP. email or whatsapp.
Available options:
email, whatsapp The One-Time Password to send.
Sender information for email and whatsapp.
Show child attributes
Show child attributes
⌘I