Parameter API untuk Verifikasi Sekarang
Parameter berikut perlu dikirim saat menggunakan API VerifyNow.
RCS/SAUTH
URL Dasar API Rest
Semua titik akhir API Platform di bawah ini harus diawali dengan URL berikut:
https://cpaas.messagecentral.com
Menghasilkan Token
Saat menggunakan API verifikasi SMS Verify Now untuk mengirim kode verifikasi SMS, panggilan awal harus ke API pembuatan token.
API ini mengembalikan token yang harus disertakan dalam semua panggilan berikutnya. Token otentikasi diperlukan untuk memvalidasi pengguna dan harus dimasukkan dalam bagian header dari setiap permintaan.
Meminta Jalur URL:
/auth/v1/authentication/token
cURL
1curl --location 'https://cpaas.messagecentral.com/auth/v1/authentication/token?
2customerId=%3CCustomerId%3E&key=%3CBase64%20Encrypted%20password%3E&scope=NEW&country=91
3&email=test%40messagecentral.com' \
4--header 'accept: */*'
CATATAN: Untuk mengubah perintah cURL menjadi kode menggunakan Postman, buka Postman, impor perintah cURL melalui tombol “Impor”, lalu buat kode dalam bahasa pilihan Anda dengan mengklik tombol “Kode” di sisi kanan permintaan.
Tanggapan JSON
1{
2 "status": Integer,
3 "token": "String"
4}
Code Example
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://cpaas.messagecentral.com/auth/v1/authentication/token?customerId=<CustomerId>&key=<Base64 Encrypted password>&scope=NEW&country=91&email=test@messagecentral.com")
.method("GET", body)
.addHeader("accept", "*/*")
.build();
Response response = client.newCall(request).execute();
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://cpaas.messagecentral.com/auth/v1/authentication/token?customerId=<CustomerId>&key=<Base64 Encrypted password>&scope=NEW&country=91&email=test@messagecentral.com',
'headers': {
'accept': '*/*'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://cpaas.messagecentral.com/auth/v1/authentication/token?customerId=<CustomerId>&key=<Base64 Encrypted password>&scope=NEW&country=91&email=test@messagecentral.com');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'accept' => '*/*'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
import requests
url = "https://cpaas.messagecentral.com/auth/v1/authentication/token?customerId=<CustomerId>&key=<Base64 Encrypted password>&scope=NEW&country=91&email=test@messagecentral.com"
payload = {}
headers = {
'accept': '*/*'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
require "uri"
require "net/http"
url = URI("https://cpaas.messagecentral.com/auth/v1/authentication/token?customerId=<CustomerId>&key=<Base64 Encrypted password>&scope=NEW&country=91&email=test@messagecentral.com")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["accept"] = "*/*"
response = https.request(request)
puts response.read_body
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://cpaas.messagecentral.com/auth/v1/authentication/token?customerId=<CustomerId>&key=<Base64 Encrypted password>&scope=NEW&country=91&email=test@messagecentral.com");
request.Headers.Add("accept", "*/*");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Kirim OTP
Untuk SendOTP pada nomor ponsel di bawah ini adalah parameter permintaan. Token otentikasi diperlukan untuk mengirim OTP yang dihasilkan oleh token API yang dihasilkan (yang dapat Anda temukan di atas di bagian Pendahuluan).
Meminta Jalur URL:
Respons yang berhasil akan mengembalikan kode status 200.
/verification/v3/send
Parameter URL Minta:
cURL
1curl --location --request POST 'https://cpaas.messagecentral.com/verification/v3/send?
2countryCode=91&flowType=SMS&mobileNumber=9999999999' \
3--header 'authToken:
4eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJDLTMzNDMyQTVGNDIGNzQwNCI6ImIhdCI6MTcxMjExOTA0MCwiZXhwIjo'
CATATAN: Untuk mengubah perintah cURL menjadi kode menggunakan Postman, buka Postman, impor perintah cURL melalui tombol “Impor”, lalu buat kode dalam bahasa pilihan Anda dengan mengklik tombol “Kode” di sisi kanan permintaan. Anda dapat mengubah basis FlowType saluran pilihan Anda.
Tanggapan JSON
1{
2 "responseCode": 200,
3 "message": "SUCCESS",
4 "data": {
5 "verificationId": "xxxx",
6 "mobileNumber": "xxxx",
7 "responseCode": "200",
8 "errorMessage": null,
9 "timeout": "60",
10 "smCLI": null,
11 "transactionId": "xxxx"
12 }
13}
Code Example
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=9999999999")
.method("POST", body)
.addHeader("authToken", "eyJhbGciOiJIUzUxMiJ9.eyJzdWOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOTA0MCwiZXhw")
.build();
Response response = client.newCall(request).execute();
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=9999999999',
'headers': {
'authToken': 'eyJhbGciOiJIUzUxMiJ9.eyJzdWOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOTA0MCwiZXhw'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=9999999999');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'authToken' => 'eyJhbGciOiJIUzUxMiJ9.eyJzdWOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOTA0MCwiZXhw'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
import requests
url = "https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=9999999999"
payload = {}
headers = {
'authToken': 'eyJhbGciOiJIUzUxMiJ9.eyJzdWOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOTA0MCwiZXhw'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
require "uri"
require "net/http"
url = URI("https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=9999999999")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authToken"] = "eyJhbGciOiJIUzUxMiJ9.eyJzdWOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOTA0MCwiZXhw"
response = https.request(request)
puts response.read_body
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=9999999999");
request.Headers.Add("authToken", "eyJhbGciOiJIUzUxMiJ9.eyJzdWOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOTA0MCwiZXhw");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Validasi OTP
Metode validateOTP adalah titik akhir REST API untuk memvalidasi kata sandi satu kali (OTP) untuk pelanggan.
Meminta Jalur URL:
Respons yang berhasil akan mengembalikan kode status 200.
/verification/v3/validateOtp/
- Untuk dukungan beberapa bahasa
- secara default adalah bahasa Inggris
- Untuk saat ini kami hanya mendukung bahasa Inggris
cURL
1curl --location 'https://cpaas.messagecentral.com/verification/v3/validateOtp?
2&verificationId=2949&code=1476' \
3--header 'authToken:
4eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJDLTMzNDMyQTVGNDIGNzQwNCI6ImIhdCI6MTcxMjExOTA0MC'
CATATAN: Untuk mengubah perintah cURL menjadi kode menggunakan Postman, buka Postman, impor perintah cURL melalui tombol “Impor”, lalu buat kode dalam bahasa pilihan Anda dengan mengklik tombol “Kode” di sisi kanan permintaan.
Tanggapan JSON
Respons yang berhasil akan mengembalikan kode status 200.
1{
2 "responseCode": 200,
3 "message": "SUCCESS",
4 "data": {
5 "verficationId": "xxxx",
6 "mobileNumber": "xxxx",
7 "responseCode": "200",
8 "errorMessage": null,
9 "verificationStatus": "VERIFICATION_COMPLETED",
10 "authToken": null,
11 "transactionId": "xxxx"
12 }
13}
Code Example
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://cpaas.messagecentral.com/verification/v3/validateOtp?&verificationId=2949&code=1476")
.method("GET", body)
.addHeader("authToken", "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOT")
.build();
Response response = client.newCall(request).execute();
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://cpaas.messagecentral.com/verification/v3/validateOtp?&verificationId=2949&code=1476',
'headers': {
'authToken': 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOT'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://cpaas.messagecentral.com/verification/v3/validateOtp?&verificationId=2949&code=1476');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'authToken' => 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOT'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://cpaas.messagecentral.com/verification/v3/validateOtp?&verificationId=2949&code=1476");
request.Headers.Add("authToken", "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOT");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
require "uri"
require "net/http"
url = URI("https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=9999999999")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authToken"] = "eyJhbGciOiJIUzUxMiJ9.eyJzdWOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOTA0MCwiZXhw"
response = https.request(request)
puts response.read_body
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=9999999999");
request.Headers.Add("authToken", "eyJhbGciOiJIUzUxMiJ9.eyJzdWOiJDLTMzNDMyQTVGNDlGNzQwNCIsImlhdCI6MTcxMjExOTA0MCwiZXhw");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Kode Respon
Bantuan dan Dukungan
Untuk dukungan implementasi dan umpan balik apa pun, silakan hubungi kami di: support@messagecentral.com
Pertanyaan yang Sering Diajukan
1. How can I implement with custom code?
You can use postman to rewrite API calls in your preferred programming language. You’d need to use: -
- POST method for sending SMS
- GET method for validating OTP SMS
2. Why am I getting the error “Method not Allowed” or error code 405?
You’d need to ensure that the endpoint URL for the Token API matches the one defined in the documentation. The same has been mentioned below: -
You can also refer to our video on API integration which explains the entire integration process in detail.
a. Token API using GET method
b. Send API using POST method
c. Validate API using GET method
3. How do I test the SMS verification APIs?
You can use Postman to test Message Central’s SMS verification APIs.
4. Why am I getting “Whitelabel Error” page?
If you are getting Whitelabel Error page, you should check for the following errors: -
a. You are using incorrect API packet
b. You have not replaced placeholders with the actual values
c. API curl is incorrect
d. Curl location has not been changed to ‘production’ instead of ‘staging’
5. Why am I getting error code 401?
This could be because of incorrect API or token. Make sure you have followed our API documentation for the right token values.
6. Why am I getting the error code 400 or “Bad Request” in Postman?
There are multiple reasons for a “Bad Request” in Postman. You can check for the following probable reasons: -
a. Check if the authToken is correct
b. Check if any parameter is missing in API
c. Header should be passed in this format - application-x-www-form-urlencoded
7. How do I generate authToken?
In order to generate the authToken in Postman, you’d:-
a. Find a ‘key’ in GET API
b. You’d need to copy that key and encode the same using Base64 -
https://www.base64encode.org/
c. Put the encoded password in ‘Key’ placeholder
d. Hit the GET API
You’d get an authToken.
8. Where do I use the authToken?
You’d need to put the authToken in the header of SEND API.
9. What all parameters do I need to change in GET API to generate token?
You’d need to change country, customerid, email and key. Scope will always remain = “NEW”
10. What all parameters do I need to change in SEND API?
You’d need to change country code, customerid, otplength, and mobilenumber.