OTP Code (Global) - Request and Send Code
curl --request POST \
--url https://api.crunchz.app/api/otp/code/global \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contact_id": "xxx@c.us",
"length": 4,
"useLetter": false,
"useNumber": true,
"allCapital": false,
"name": "Your Company Name",
"expires": 1800
}
'import requests
url = "https://api.crunchz.app/api/otp/code/global"
payload = {
"contact_id": "xxx@c.us",
"length": 4,
"useLetter": False,
"useNumber": True,
"allCapital": False,
"name": "Your Company Name",
"expires": 1800
}
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({
contact_id: 'xxx@c.us',
length: 4,
useLetter: false,
useNumber: true,
allCapital: false,
name: 'Your Company Name',
expires: 1800
})
};
fetch('https://api.crunchz.app/api/otp/code/global', 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://api.crunchz.app/api/otp/code/global",
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([
'contact_id' => 'xxx@c.us',
'length' => 4,
'useLetter' => false,
'useNumber' => true,
'allCapital' => false,
'name' => 'Your Company Name',
'expires' => 1800
]),
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://api.crunchz.app/api/otp/code/global"
payload := strings.NewReader("{\n \"contact_id\": \"xxx@c.us\",\n \"length\": 4,\n \"useLetter\": false,\n \"useNumber\": true,\n \"allCapital\": false,\n \"name\": \"Your Company Name\",\n \"expires\": 1800\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://api.crunchz.app/api/otp/code/global")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contact_id\": \"xxx@c.us\",\n \"length\": 4,\n \"useLetter\": false,\n \"useNumber\": true,\n \"allCapital\": false,\n \"name\": \"Your Company Name\",\n \"expires\": 1800\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.crunchz.app/api/otp/code/global")
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 \"contact_id\": \"xxx@c.us\",\n \"length\": 4,\n \"useLetter\": false,\n \"useNumber\": true,\n \"allCapital\": false,\n \"name\": \"Your Company Name\",\n \"expires\": 1800\n}"
response = http.request(request)
puts response.read_body{}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>"
}One Time Password - Global
Request - Code
Generate and send One-Time Password (OTP) codes globally across multiple channels with intelligent channel randomization for optimal delivery success.
POST
/
otp
/
code
/
global
OTP Code (Global) - Request and Send Code
curl --request POST \
--url https://api.crunchz.app/api/otp/code/global \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contact_id": "xxx@c.us",
"length": 4,
"useLetter": false,
"useNumber": true,
"allCapital": false,
"name": "Your Company Name",
"expires": 1800
}
'import requests
url = "https://api.crunchz.app/api/otp/code/global"
payload = {
"contact_id": "xxx@c.us",
"length": 4,
"useLetter": False,
"useNumber": True,
"allCapital": False,
"name": "Your Company Name",
"expires": 1800
}
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({
contact_id: 'xxx@c.us',
length: 4,
useLetter: false,
useNumber: true,
allCapital: false,
name: 'Your Company Name',
expires: 1800
})
};
fetch('https://api.crunchz.app/api/otp/code/global', 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://api.crunchz.app/api/otp/code/global",
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([
'contact_id' => 'xxx@c.us',
'length' => 4,
'useLetter' => false,
'useNumber' => true,
'allCapital' => false,
'name' => 'Your Company Name',
'expires' => 1800
]),
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://api.crunchz.app/api/otp/code/global"
payload := strings.NewReader("{\n \"contact_id\": \"xxx@c.us\",\n \"length\": 4,\n \"useLetter\": false,\n \"useNumber\": true,\n \"allCapital\": false,\n \"name\": \"Your Company Name\",\n \"expires\": 1800\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://api.crunchz.app/api/otp/code/global")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contact_id\": \"xxx@c.us\",\n \"length\": 4,\n \"useLetter\": false,\n \"useNumber\": true,\n \"allCapital\": false,\n \"name\": \"Your Company Name\",\n \"expires\": 1800\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.crunchz.app/api/otp/code/global")
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 \"contact_id\": \"xxx@c.us\",\n \"length\": 4,\n \"useLetter\": false,\n \"useNumber\": true,\n \"allCapital\": false,\n \"name\": \"Your Company Name\",\n \"expires\": 1800\n}"
response = http.request(request)
puts response.read_body{}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>"
}Overview
This endpoint allows you to request a one-time password (OTP) code for global use. GLOBAL means the system will randomize the channel to send or receive the message from or to the user. This endpoint generates a One-Time Password (OTP) with customizable validation settings.Request Parameters
string
required
The contact ID to send the OTP code to. Format:
xxx@c.usnumber
required
Length of the OTP code. Maximum value is 6.
boolean
required
Whether to include letters in the OTP code.
boolean
required
Whether to include numbers in the OTP code.
boolean
required
Whether to use uppercase letters for the OTP code.
string
required
Application name that will be displayed to the user.
number
required
Expiration time in seconds. For example, 1800 seconds (30 minutes).
Response
boolean
Indicates whether the request was successful.
string
A message describing the result of the operation.
object
Error Codes
object
Authorization Exception - Occurs when the request is not properly authorized.
object
Validation Exception - Occurs when the request parameters fail validation.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Contact ID .
Example:
"xxx@c.us"
Length OTP Code.
Required range:
x <= 6Example:
4
Using letter for Otp Code.
Example:
false
Using number for Otp Code.
Example:
true
Using uppercase for Otp Code.
Example:
false
Application Name.
Example:
"Your Company Name"
Expire time in second ( e.g 30 Minute )
Example:
1800
Response
- Option 1
- OtpCodeResource
The response is of type object.
Was this page helpful?