cURL
curl -X GET "https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate?merchantAccountNumber=35253486" \
--header "Authorization: Bearer your-jwt-token" \
--header "accept: application/json" \
--header "Accept-Language: en"import requests
url = "https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate', 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.onekhusa.com/sandbox/v1/security/apiKeys/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"key": "abcdefghijklmnopqrstuvwxyz1234",
"secret": "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789012345"
}Api Keys
Generate API Key
This endpoint generates a new API key and secret pair for a merchant. Note that the generated keys are not automatically saved to the database, use the Add API Key endpoint to persist the data.
WARNING: Do not expose API secret on a website or embed it in a mobile application and do not share API secret with anyone to avoid leaking your data to unauthorised users.
GET
/
security
/
apiKeys
/
generate
cURL
curl -X GET "https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate?merchantAccountNumber=35253486" \
--header "Authorization: Bearer your-jwt-token" \
--header "accept: application/json" \
--header "Accept-Language: en"import requests
url = "https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate', 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.onekhusa.com/sandbox/v1/security/apiKeys/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onekhusa.com/sandbox/v1/security/apiKeys/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"key": "abcdefghijklmnopqrstuvwxyz1234",
"secret": "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789012345"
}Authorizations
Bearer authentication header of the form Bearer Token, Where accessToken is the access token used to authenticate the request.
Headers
Preferred language for the response
Query Parameters
The unique identifier of the merchant account
Response
200 - application/json
Success - API key and secret pair generated