Get the Switch public encryption key
curl --request GET \
--url https://staging-switch.yourflexpay.com/api/v1/keys/switchimport requests
url = "https://staging-switch.yourflexpay.com/api/v1/keys/switch"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://staging-switch.yourflexpay.com/api/v1/keys/switch', 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://staging-switch.yourflexpay.com/api/v1/keys/switch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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://staging-switch.yourflexpay.com/api/v1/keys/switch"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://staging-switch.yourflexpay.com/api/v1/keys/switch")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging-switch.yourflexpay.com/api/v1/keys/switch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"errorCode": "<string>",
"data": {},
"errors": [
"<string>"
],
"timestamp": "2023-11-07T05:31:56Z"
}Encryption
Get the Switch public encryption key
Returns the Switch EC P-256 public key in two formats:
jwk– JSON Web Key (JWK) format; import directly into any JOSE library.publicKeyBase64– Base64-encoded X.509 (SubjectPublicKeyInfo) DER; use withKeyFactory.getInstance("EC").generatePublic(new X509EncodedKeySpec(decoded))in Java.
Use this key to encrypt request payloads before sending them to Switch:
1. Serialize your JSON request body.
2. Encrypt with JWE (alg=ECDH-ES+A256KW, enc=A256GCM) using this public key.
3. Set header: Content-Encryption: JWE
4. Send the JWE compact string as the request body.
This endpoint is unauthenticated – public keys are safe to distribute. Cache the response; refresh only if you encounter a JWE decryption error (HTTP 400).
GET
/
v1
/
keys
/
switch
Get the Switch public encryption key
curl --request GET \
--url https://staging-switch.yourflexpay.com/api/v1/keys/switchimport requests
url = "https://staging-switch.yourflexpay.com/api/v1/keys/switch"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://staging-switch.yourflexpay.com/api/v1/keys/switch', 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://staging-switch.yourflexpay.com/api/v1/keys/switch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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://staging-switch.yourflexpay.com/api/v1/keys/switch"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://staging-switch.yourflexpay.com/api/v1/keys/switch")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging-switch.yourflexpay.com/api/v1/keys/switch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"errorCode": "<string>",
"data": {},
"errors": [
"<string>"
],
"timestamp": "2023-11-07T05:31:56Z"
}