Get Token
curl --request POST \
--url https://sandbox.cashfree.com/gc/authorize \
--header 'x-api-version: <x-api-version>' \
--header 'x-partner-api-key: <x-partner-api-key>' \
--header 'x-partner-merchantid: <x-partner-merchantid>'import requests
url = "https://sandbox.cashfree.com/gc/authorize"
headers = {
"x-partner-api-key": "<x-partner-api-key>",
"x-partner-merchantid": "<x-partner-merchantid>",
"x-api-version": "<x-api-version>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-partner-api-key': '<x-partner-api-key>',
'x-partner-merchantid': '<x-partner-merchantid>',
'x-api-version': '<x-api-version>'
}
};
fetch('https://sandbox.cashfree.com/gc/authorize', 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://sandbox.cashfree.com/gc/authorize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-api-version: <x-api-version>",
"x-partner-api-key: <x-partner-api-key>",
"x-partner-merchantid: <x-partner-merchantid>"
],
]);
$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://sandbox.cashfree.com/gc/authorize"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-partner-api-key", "<x-partner-api-key>")
req.Header.Add("x-partner-merchantid", "<x-partner-merchantid>")
req.Header.Add("x-api-version", "<x-api-version>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.cashfree.com/gc/authorize")
.header("x-partner-api-key", "<x-partner-api-key>")
.header("x-partner-merchantid", "<x-partner-merchantid>")
.header("x-api-version", "<x-api-version>")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.cashfree.com/gc/authorize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-partner-api-key"] = '<x-partner-api-key>'
request["x-partner-merchantid"] = '<x-partner-merchantid>'
request["x-api-version"] = '<x-api-version>'
response = http.request(request)
puts response.read_body{
"status": "SUCCESS",
"subCode": "200",
"message": "success_message",
"data": {
"token": "eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9...",
"expiry": 1697611541
}
}{
"type": "authentication_error",
"message": "failed to authenticate",
"code": "authentication_failed"
}Authorization
Get Auth Token
Use this API to authenticate with the Cashfree system and obtain the authorization bearer token.
POST
/
gc
/
authorize
Get Token
curl --request POST \
--url https://sandbox.cashfree.com/gc/authorize \
--header 'x-api-version: <x-api-version>' \
--header 'x-partner-api-key: <x-partner-api-key>' \
--header 'x-partner-merchantid: <x-partner-merchantid>'import requests
url = "https://sandbox.cashfree.com/gc/authorize"
headers = {
"x-partner-api-key": "<x-partner-api-key>",
"x-partner-merchantid": "<x-partner-merchantid>",
"x-api-version": "<x-api-version>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-partner-api-key': '<x-partner-api-key>',
'x-partner-merchantid': '<x-partner-merchantid>',
'x-api-version': '<x-api-version>'
}
};
fetch('https://sandbox.cashfree.com/gc/authorize', 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://sandbox.cashfree.com/gc/authorize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-api-version: <x-api-version>",
"x-partner-api-key: <x-partner-api-key>",
"x-partner-merchantid: <x-partner-merchantid>"
],
]);
$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://sandbox.cashfree.com/gc/authorize"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-partner-api-key", "<x-partner-api-key>")
req.Header.Add("x-partner-merchantid", "<x-partner-merchantid>")
req.Header.Add("x-api-version", "<x-api-version>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.cashfree.com/gc/authorize")
.header("x-partner-api-key", "<x-partner-api-key>")
.header("x-partner-merchantid", "<x-partner-merchantid>")
.header("x-api-version", "<x-api-version>")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.cashfree.com/gc/authorize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-partner-api-key"] = '<x-partner-api-key>'
request["x-partner-merchantid"] = '<x-partner-merchantid>'
request["x-api-version"] = '<x-api-version>'
response = http.request(request)
puts response.read_body{
"status": "SUCCESS",
"subCode": "200",
"message": "success_message",
"data": {
"token": "eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9...",
"expiry": 1697611541
}
}{
"type": "authentication_error",
"message": "failed to authenticate",
"code": "authentication_failed"
}Based on who you are, consider the below values in the API requests
| Cashfree Merchant | Cashfree Partner |
|---|---|
| x-client-id | x-partner-api-key |
| x-client-secret | x-partner-merchantid |
Headers
Enter partner API keygit
Enter the merchant reference id used while creating merchant during onboarding
API version
Was this page helpful?
āI