Invoke an outbound proxy connection
curl --request POST \
--url https://api.eu.staging.payrails.io/token/connections/{connectionId}/proxy \
--header 'Content-Type: application/json' \
--header 'Payrails-Authorization: <payrails-authorization>' \
--header 'Payrails-Destination: <payrails-destination>' \
--data '
{
"cards": {
"number": "9f7d2406-456d-401e-a77b-16b733d95414",
"securityCode": "e211808e-316f-4877-9899-a2fa711d5fb7",
"expiryMonth": "fe7a9af7-157f-4982-807d-ed32407e02fb",
"expiryYear": "d1a373d4-e681-460b-b6a8-e57b8e029d40"
}
}
'import requests
url = "https://api.eu.staging.payrails.io/token/connections/{connectionId}/proxy"
payload = { "cards": {
"number": "9f7d2406-456d-401e-a77b-16b733d95414",
"securityCode": "e211808e-316f-4877-9899-a2fa711d5fb7",
"expiryMonth": "fe7a9af7-157f-4982-807d-ed32407e02fb",
"expiryYear": "d1a373d4-e681-460b-b6a8-e57b8e029d40"
} }
headers = {
"Payrails-Authorization": "<payrails-authorization>",
"Payrails-Destination": "<payrails-destination>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Payrails-Authorization': '<payrails-authorization>',
'Payrails-Destination': '<payrails-destination>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
cards: {
number: '9f7d2406-456d-401e-a77b-16b733d95414',
securityCode: 'e211808e-316f-4877-9899-a2fa711d5fb7',
expiryMonth: 'fe7a9af7-157f-4982-807d-ed32407e02fb',
expiryYear: 'd1a373d4-e681-460b-b6a8-e57b8e029d40'
}
})
};
fetch('https://api.eu.staging.payrails.io/token/connections/{connectionId}/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://api.eu.staging.payrails.io/token/connections/{connectionId}/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([
'cards' => [
'number' => '9f7d2406-456d-401e-a77b-16b733d95414',
'securityCode' => 'e211808e-316f-4877-9899-a2fa711d5fb7',
'expiryMonth' => 'fe7a9af7-157f-4982-807d-ed32407e02fb',
'expiryYear' => 'd1a373d4-e681-460b-b6a8-e57b8e029d40'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Payrails-Authorization: <payrails-authorization>",
"Payrails-Destination: <payrails-destination>"
],
]);
$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.eu.staging.payrails.io/token/connections/{connectionId}/proxy"
payload := strings.NewReader("{\n \"cards\": {\n \"number\": \"9f7d2406-456d-401e-a77b-16b733d95414\",\n \"securityCode\": \"e211808e-316f-4877-9899-a2fa711d5fb7\",\n \"expiryMonth\": \"fe7a9af7-157f-4982-807d-ed32407e02fb\",\n \"expiryYear\": \"d1a373d4-e681-460b-b6a8-e57b8e029d40\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Payrails-Authorization", "<payrails-authorization>")
req.Header.Add("Payrails-Destination", "<payrails-destination>")
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.eu.staging.payrails.io/token/connections/{connectionId}/proxy")
.header("Payrails-Authorization", "<payrails-authorization>")
.header("Payrails-Destination", "<payrails-destination>")
.header("Content-Type", "application/json")
.body("{\n \"cards\": {\n \"number\": \"9f7d2406-456d-401e-a77b-16b733d95414\",\n \"securityCode\": \"e211808e-316f-4877-9899-a2fa711d5fb7\",\n \"expiryMonth\": \"fe7a9af7-157f-4982-807d-ed32407e02fb\",\n \"expiryYear\": \"d1a373d4-e681-460b-b6a8-e57b8e029d40\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.eu.staging.payrails.io/token/connections/{connectionId}/proxy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Payrails-Authorization"] = '<payrails-authorization>'
request["Payrails-Destination"] = '<payrails-destination>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cards\": {\n \"number\": \"9f7d2406-456d-401e-a77b-16b733d95414\",\n \"securityCode\": \"e211808e-316f-4877-9899-a2fa711d5fb7\",\n \"expiryMonth\": \"fe7a9af7-157f-4982-807d-ed32407e02fb\",\n \"expiryYear\": \"d1a373d4-e681-460b-b6a8-e57b8e029d40\"\n }\n}"
response = http.request(request)
puts response.read_body{
"cards": {
"number": "4111111111111111",
"securityCode": "111",
"expiryMonth": "01",
"expiryYear": "35"
}
}{
"errors": [
{
"id": "a24bc325-3929-4d9d-9c08-b3aa532685b7",
"code": "request.entity-too-large",
"detail": "The request entity is too large",
"docUrl": "https://docs.payrails.com/docs/resources/error-codes#requestentity-too-large"
}
]
}Invoke an outbound proxy connection
Proxy a request through an outbound Vault connection to the whitelisted URL in the Payrails-Destination header, using any HTTP method it allows.
POST
https://api.eu.staging.payrails.io
/
token
/
connections
/
{connectionId}
/
proxy
Invoke an outbound proxy connection
curl --request POST \
--url https://api.eu.staging.payrails.io/token/connections/{connectionId}/proxy \
--header 'Content-Type: application/json' \
--header 'Payrails-Authorization: <payrails-authorization>' \
--header 'Payrails-Destination: <payrails-destination>' \
--data '
{
"cards": {
"number": "9f7d2406-456d-401e-a77b-16b733d95414",
"securityCode": "e211808e-316f-4877-9899-a2fa711d5fb7",
"expiryMonth": "fe7a9af7-157f-4982-807d-ed32407e02fb",
"expiryYear": "d1a373d4-e681-460b-b6a8-e57b8e029d40"
}
}
'import requests
url = "https://api.eu.staging.payrails.io/token/connections/{connectionId}/proxy"
payload = { "cards": {
"number": "9f7d2406-456d-401e-a77b-16b733d95414",
"securityCode": "e211808e-316f-4877-9899-a2fa711d5fb7",
"expiryMonth": "fe7a9af7-157f-4982-807d-ed32407e02fb",
"expiryYear": "d1a373d4-e681-460b-b6a8-e57b8e029d40"
} }
headers = {
"Payrails-Authorization": "<payrails-authorization>",
"Payrails-Destination": "<payrails-destination>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Payrails-Authorization': '<payrails-authorization>',
'Payrails-Destination': '<payrails-destination>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
cards: {
number: '9f7d2406-456d-401e-a77b-16b733d95414',
securityCode: 'e211808e-316f-4877-9899-a2fa711d5fb7',
expiryMonth: 'fe7a9af7-157f-4982-807d-ed32407e02fb',
expiryYear: 'd1a373d4-e681-460b-b6a8-e57b8e029d40'
}
})
};
fetch('https://api.eu.staging.payrails.io/token/connections/{connectionId}/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://api.eu.staging.payrails.io/token/connections/{connectionId}/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([
'cards' => [
'number' => '9f7d2406-456d-401e-a77b-16b733d95414',
'securityCode' => 'e211808e-316f-4877-9899-a2fa711d5fb7',
'expiryMonth' => 'fe7a9af7-157f-4982-807d-ed32407e02fb',
'expiryYear' => 'd1a373d4-e681-460b-b6a8-e57b8e029d40'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Payrails-Authorization: <payrails-authorization>",
"Payrails-Destination: <payrails-destination>"
],
]);
$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.eu.staging.payrails.io/token/connections/{connectionId}/proxy"
payload := strings.NewReader("{\n \"cards\": {\n \"number\": \"9f7d2406-456d-401e-a77b-16b733d95414\",\n \"securityCode\": \"e211808e-316f-4877-9899-a2fa711d5fb7\",\n \"expiryMonth\": \"fe7a9af7-157f-4982-807d-ed32407e02fb\",\n \"expiryYear\": \"d1a373d4-e681-460b-b6a8-e57b8e029d40\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Payrails-Authorization", "<payrails-authorization>")
req.Header.Add("Payrails-Destination", "<payrails-destination>")
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.eu.staging.payrails.io/token/connections/{connectionId}/proxy")
.header("Payrails-Authorization", "<payrails-authorization>")
.header("Payrails-Destination", "<payrails-destination>")
.header("Content-Type", "application/json")
.body("{\n \"cards\": {\n \"number\": \"9f7d2406-456d-401e-a77b-16b733d95414\",\n \"securityCode\": \"e211808e-316f-4877-9899-a2fa711d5fb7\",\n \"expiryMonth\": \"fe7a9af7-157f-4982-807d-ed32407e02fb\",\n \"expiryYear\": \"d1a373d4-e681-460b-b6a8-e57b8e029d40\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.eu.staging.payrails.io/token/connections/{connectionId}/proxy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Payrails-Authorization"] = '<payrails-authorization>'
request["Payrails-Destination"] = '<payrails-destination>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cards\": {\n \"number\": \"9f7d2406-456d-401e-a77b-16b733d95414\",\n \"securityCode\": \"e211808e-316f-4877-9899-a2fa711d5fb7\",\n \"expiryMonth\": \"fe7a9af7-157f-4982-807d-ed32407e02fb\",\n \"expiryYear\": \"d1a373d4-e681-460b-b6a8-e57b8e029d40\"\n }\n}"
response = http.request(request)
puts response.read_body{
"cards": {
"number": "4111111111111111",
"securityCode": "111",
"expiryMonth": "01",
"expiryYear": "35"
}
}{
"errors": [
{
"id": "a24bc325-3929-4d9d-9c08-b3aa532685b7",
"code": "request.entity-too-large",
"detail": "The request entity is too large",
"docUrl": "https://docs.payrails.com/docs/resources/error-codes#requestentity-too-large"
}
]
}Headers
Response
Returns the response from the destination URL. Although it was demonstrated to return raw data, the raw response is passed to the proxy merchant, which aligns with the real-world use case. In a real scenario, the merchant would not return actual card data — this is just a sample response to demonstrate the proxy use case.