Proxy
curl --request POST \
--url https://sandbox.hyperswitch.io/v1/proxy \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'X-Profile-Id: <x-profile-id>' \
--data '
{
"destination_url": "https://api.example.com/payments",
"headers": {
"Authorization": "Bearer sk_test_example",
"Content-Type": "application/json"
},
"method": "POST",
"request_body": {
"amount": 6540,
"capture": true,
"currency": "USD",
"reference": "ORD-5023-4E89",
"source": {
"billing_address": {
"address_line1": "123 High St.",
"city": "London",
"country": "GB"
},
"expiry_month": "{{$card_exp_month}}",
"expiry_year": "{{$card_exp_year}}",
"number": "{{$card_number}}",
"type": "card"
}
},
"token": "pm_0196ea5a42a67583863d5b1253d62931",
"token_type": "PaymentMethodId"
}
'import requests
url = "https://sandbox.hyperswitch.io/v1/proxy"
payload = {
"destination_url": "https://api.example.com/payments",
"headers": {
"Authorization": "Bearer sk_test_example",
"Content-Type": "application/json"
},
"method": "POST",
"request_body": {
"amount": 6540,
"capture": True,
"currency": "USD",
"reference": "ORD-5023-4E89",
"source": {
"billing_address": {
"address_line1": "123 High St.",
"city": "London",
"country": "GB"
},
"expiry_month": "{{$card_exp_month}}",
"expiry_year": "{{$card_exp_year}}",
"number": "{{$card_number}}",
"type": "card"
}
},
"token": "pm_0196ea5a42a67583863d5b1253d62931",
"token_type": "PaymentMethodId"
}
headers = {
"X-Profile-Id": "<x-profile-id>",
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Profile-Id': '<x-profile-id>',
Authorization: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
destination_url: 'https://api.example.com/payments',
headers: {Authorization: 'Bearer sk_test_example', 'Content-Type': 'application/json'},
method: 'POST',
request_body: {
amount: 6540,
capture: true,
currency: 'USD',
reference: 'ORD-5023-4E89',
source: {
billing_address: {address_line1: '123 High St.', city: 'London', country: 'GB'},
expiry_month: '{{$card_exp_month}}',
expiry_year: '{{$card_exp_year}}',
number: '{{$card_number}}',
type: 'card'
}
},
token: 'pm_0196ea5a42a67583863d5b1253d62931',
token_type: 'PaymentMethodId'
})
};
fetch('https://sandbox.hyperswitch.io/v1/proxy', 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.hyperswitch.io/v1/proxy",
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([
'destination_url' => 'https://api.example.com/payments',
'headers' => [
'Authorization' => 'Bearer sk_test_example',
'Content-Type' => 'application/json'
],
'method' => 'POST',
'request_body' => [
'amount' => 6540,
'capture' => true,
'currency' => 'USD',
'reference' => 'ORD-5023-4E89',
'source' => [
'billing_address' => [
'address_line1' => '123 High St.',
'city' => 'London',
'country' => 'GB'
],
'expiry_month' => '{{$card_exp_month}}',
'expiry_year' => '{{$card_exp_year}}',
'number' => '{{$card_number}}',
'type' => 'card'
]
],
'token' => 'pm_0196ea5a42a67583863d5b1253d62931',
'token_type' => 'PaymentMethodId'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json",
"X-Profile-Id: <x-profile-id>"
],
]);
$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://sandbox.hyperswitch.io/v1/proxy"
payload := strings.NewReader("{\n \"destination_url\": \"https://api.example.com/payments\",\n \"headers\": {\n \"Authorization\": \"Bearer sk_test_example\",\n \"Content-Type\": \"application/json\"\n },\n \"method\": \"POST\",\n \"request_body\": {\n \"amount\": 6540,\n \"capture\": true,\n \"currency\": \"USD\",\n \"reference\": \"ORD-5023-4E89\",\n \"source\": {\n \"billing_address\": {\n \"address_line1\": \"123 High St.\",\n \"city\": \"London\",\n \"country\": \"GB\"\n },\n \"expiry_month\": \"{{$card_exp_month}}\",\n \"expiry_year\": \"{{$card_exp_year}}\",\n \"number\": \"{{$card_number}}\",\n \"type\": \"card\"\n }\n },\n \"token\": \"pm_0196ea5a42a67583863d5b1253d62931\",\n \"token_type\": \"PaymentMethodId\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Profile-Id", "<x-profile-id>")
req.Header.Add("Authorization", "<api-key>")
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://sandbox.hyperswitch.io/v1/proxy")
.header("X-Profile-Id", "<x-profile-id>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"destination_url\": \"https://api.example.com/payments\",\n \"headers\": {\n \"Authorization\": \"Bearer sk_test_example\",\n \"Content-Type\": \"application/json\"\n },\n \"method\": \"POST\",\n \"request_body\": {\n \"amount\": 6540,\n \"capture\": true,\n \"currency\": \"USD\",\n \"reference\": \"ORD-5023-4E89\",\n \"source\": {\n \"billing_address\": {\n \"address_line1\": \"123 High St.\",\n \"city\": \"London\",\n \"country\": \"GB\"\n },\n \"expiry_month\": \"{{$card_exp_month}}\",\n \"expiry_year\": \"{{$card_exp_year}}\",\n \"number\": \"{{$card_number}}\",\n \"type\": \"card\"\n }\n },\n \"token\": \"pm_0196ea5a42a67583863d5b1253d62931\",\n \"token_type\": \"PaymentMethodId\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.hyperswitch.io/v1/proxy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Profile-Id"] = '<x-profile-id>'
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"destination_url\": \"https://api.example.com/payments\",\n \"headers\": {\n \"Authorization\": \"Bearer sk_test_example\",\n \"Content-Type\": \"application/json\"\n },\n \"method\": \"POST\",\n \"request_body\": {\n \"amount\": 6540,\n \"capture\": true,\n \"currency\": \"USD\",\n \"reference\": \"ORD-5023-4E89\",\n \"source\": {\n \"billing_address\": {\n \"address_line1\": \"123 High St.\",\n \"city\": \"London\",\n \"country\": \"GB\"\n },\n \"expiry_month\": \"{{$card_exp_month}}\",\n \"expiry_year\": \"{{$card_exp_year}}\",\n \"number\": \"{{$card_number}}\",\n \"type\": \"card\"\n }\n },\n \"token\": \"pm_0196ea5a42a67583863d5b1253d62931\",\n \"token_type\": \"PaymentMethodId\"\n}"
response = http.request(request)
puts response.read_body{
"response": "<unknown>",
"status_code": 1,
"response_headers": {}
}Proxy
Proxy
Create a proxy request
POST
/
v1
/
proxy
Proxy
curl --request POST \
--url https://sandbox.hyperswitch.io/v1/proxy \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--header 'X-Profile-Id: <x-profile-id>' \
--data '
{
"destination_url": "https://api.example.com/payments",
"headers": {
"Authorization": "Bearer sk_test_example",
"Content-Type": "application/json"
},
"method": "POST",
"request_body": {
"amount": 6540,
"capture": true,
"currency": "USD",
"reference": "ORD-5023-4E89",
"source": {
"billing_address": {
"address_line1": "123 High St.",
"city": "London",
"country": "GB"
},
"expiry_month": "{{$card_exp_month}}",
"expiry_year": "{{$card_exp_year}}",
"number": "{{$card_number}}",
"type": "card"
}
},
"token": "pm_0196ea5a42a67583863d5b1253d62931",
"token_type": "PaymentMethodId"
}
'import requests
url = "https://sandbox.hyperswitch.io/v1/proxy"
payload = {
"destination_url": "https://api.example.com/payments",
"headers": {
"Authorization": "Bearer sk_test_example",
"Content-Type": "application/json"
},
"method": "POST",
"request_body": {
"amount": 6540,
"capture": True,
"currency": "USD",
"reference": "ORD-5023-4E89",
"source": {
"billing_address": {
"address_line1": "123 High St.",
"city": "London",
"country": "GB"
},
"expiry_month": "{{$card_exp_month}}",
"expiry_year": "{{$card_exp_year}}",
"number": "{{$card_number}}",
"type": "card"
}
},
"token": "pm_0196ea5a42a67583863d5b1253d62931",
"token_type": "PaymentMethodId"
}
headers = {
"X-Profile-Id": "<x-profile-id>",
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Profile-Id': '<x-profile-id>',
Authorization: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
destination_url: 'https://api.example.com/payments',
headers: {Authorization: 'Bearer sk_test_example', 'Content-Type': 'application/json'},
method: 'POST',
request_body: {
amount: 6540,
capture: true,
currency: 'USD',
reference: 'ORD-5023-4E89',
source: {
billing_address: {address_line1: '123 High St.', city: 'London', country: 'GB'},
expiry_month: '{{$card_exp_month}}',
expiry_year: '{{$card_exp_year}}',
number: '{{$card_number}}',
type: 'card'
}
},
token: 'pm_0196ea5a42a67583863d5b1253d62931',
token_type: 'PaymentMethodId'
})
};
fetch('https://sandbox.hyperswitch.io/v1/proxy', 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.hyperswitch.io/v1/proxy",
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([
'destination_url' => 'https://api.example.com/payments',
'headers' => [
'Authorization' => 'Bearer sk_test_example',
'Content-Type' => 'application/json'
],
'method' => 'POST',
'request_body' => [
'amount' => 6540,
'capture' => true,
'currency' => 'USD',
'reference' => 'ORD-5023-4E89',
'source' => [
'billing_address' => [
'address_line1' => '123 High St.',
'city' => 'London',
'country' => 'GB'
],
'expiry_month' => '{{$card_exp_month}}',
'expiry_year' => '{{$card_exp_year}}',
'number' => '{{$card_number}}',
'type' => 'card'
]
],
'token' => 'pm_0196ea5a42a67583863d5b1253d62931',
'token_type' => 'PaymentMethodId'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json",
"X-Profile-Id: <x-profile-id>"
],
]);
$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://sandbox.hyperswitch.io/v1/proxy"
payload := strings.NewReader("{\n \"destination_url\": \"https://api.example.com/payments\",\n \"headers\": {\n \"Authorization\": \"Bearer sk_test_example\",\n \"Content-Type\": \"application/json\"\n },\n \"method\": \"POST\",\n \"request_body\": {\n \"amount\": 6540,\n \"capture\": true,\n \"currency\": \"USD\",\n \"reference\": \"ORD-5023-4E89\",\n \"source\": {\n \"billing_address\": {\n \"address_line1\": \"123 High St.\",\n \"city\": \"London\",\n \"country\": \"GB\"\n },\n \"expiry_month\": \"{{$card_exp_month}}\",\n \"expiry_year\": \"{{$card_exp_year}}\",\n \"number\": \"{{$card_number}}\",\n \"type\": \"card\"\n }\n },\n \"token\": \"pm_0196ea5a42a67583863d5b1253d62931\",\n \"token_type\": \"PaymentMethodId\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Profile-Id", "<x-profile-id>")
req.Header.Add("Authorization", "<api-key>")
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://sandbox.hyperswitch.io/v1/proxy")
.header("X-Profile-Id", "<x-profile-id>")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"destination_url\": \"https://api.example.com/payments\",\n \"headers\": {\n \"Authorization\": \"Bearer sk_test_example\",\n \"Content-Type\": \"application/json\"\n },\n \"method\": \"POST\",\n \"request_body\": {\n \"amount\": 6540,\n \"capture\": true,\n \"currency\": \"USD\",\n \"reference\": \"ORD-5023-4E89\",\n \"source\": {\n \"billing_address\": {\n \"address_line1\": \"123 High St.\",\n \"city\": \"London\",\n \"country\": \"GB\"\n },\n \"expiry_month\": \"{{$card_exp_month}}\",\n \"expiry_year\": \"{{$card_exp_year}}\",\n \"number\": \"{{$card_number}}\",\n \"type\": \"card\"\n }\n },\n \"token\": \"pm_0196ea5a42a67583863d5b1253d62931\",\n \"token_type\": \"PaymentMethodId\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.hyperswitch.io/v1/proxy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Profile-Id"] = '<x-profile-id>'
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"destination_url\": \"https://api.example.com/payments\",\n \"headers\": {\n \"Authorization\": \"Bearer sk_test_example\",\n \"Content-Type\": \"application/json\"\n },\n \"method\": \"POST\",\n \"request_body\": {\n \"amount\": 6540,\n \"capture\": true,\n \"currency\": \"USD\",\n \"reference\": \"ORD-5023-4E89\",\n \"source\": {\n \"billing_address\": {\n \"address_line1\": \"123 High St.\",\n \"city\": \"London\",\n \"country\": \"GB\"\n },\n \"expiry_month\": \"{{$card_exp_month}}\",\n \"expiry_year\": \"{{$card_exp_year}}\",\n \"number\": \"{{$card_number}}\",\n \"type\": \"card\"\n }\n },\n \"token\": \"pm_0196ea5a42a67583863d5b1253d62931\",\n \"token_type\": \"PaymentMethodId\"\n}"
response = http.request(request)
puts response.read_body{
"response": "<unknown>",
"status_code": 1,
"response_headers": {}
}Authorizations
Format: api-key=<api_key>
Use the API key created under your merchant account from the HyperSwitch dashboard. API key is used to authenticate API requests from your merchant server only. Don't expose this key on a website or embed it in a mobile application.
Headers
Profile ID for authentication
Body
application/json
The request body that needs to be forwarded
The non-empty HTTP or HTTPS destination URL. Configured proxy bypass hosts are rejected. IP literals must be publicly routable.
Minimum string length:
1Example:
"https://api.example.com/endpoint"
The headers that need to be forwarded
Available options:
GET, POST, PUT, DELETE, PATCH The vault token that is used to fetch sensitive data from the vault
Available options:
tokenization_id, payment_method_id, volatile_payment_method_id, payment_method_token Was this page helpful?