Payment Gateways
Connect a Gateway
Connect your own Stripe, Razorpay, or GoCardless account to process this workspace’s payments.
POST
/
v1
/
gateway-connections
Connect (or replace) a payment gateway
curl --request POST \
--url https://billing.example.com/v1/gateway-connections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"secret_key": "<string>",
"public_key": "<string>",
"webhook_secret": "<string>"
}
'import requests
url = "https://billing.example.com/v1/gateway-connections"
payload = {
"secret_key": "<string>",
"public_key": "<string>",
"webhook_secret": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({secret_key: '<string>', public_key: '<string>', webhook_secret: '<string>'})
};
fetch('https://billing.example.com/v1/gateway-connections', 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://billing.example.com/v1/gateway-connections",
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([
'secret_key' => '<string>',
'public_key' => '<string>',
'webhook_secret' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://billing.example.com/v1/gateway-connections"
payload := strings.NewReader("{\n \"secret_key\": \"<string>\",\n \"public_key\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://billing.example.com/v1/gateway-connections")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"secret_key\": \"<string>\",\n \"public_key\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/gateway-connections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"secret_key\": \"<string>\",\n \"public_key\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"provider": "stripe",
"mode": "test",
"public_key": "<string>",
"has_webhook_secret": true,
"webhook_path": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}Errors
| Status | Code | When | Fix |
|---|---|---|---|
400 | validation_failed | Unknown provider, or mode is neither test nor live | Use a supported provider; omit mode to default to test |
400 | validation_failed | secret_key missing, public_key (key_id) missing for Razorpay, or a credential contains non-ASCII/control characters | Re-copy the keys from the provider dashboard |
400 | validation_failed | GoCardless token/mode mismatch (live_ token in test mode or sandbox_ token in live mode) | Match the token to the mode — sandbox tokens come from manage-sandbox.gocardless.com |
403 | forbidden | The session user is not an owner or admin | Gateway credentials are money-path config — ask an owner/admin |
503 | internal_error | Credential vault unavailable (GATEWAY_ENCRYPTION_KEY not configured on the API) | Self-hosted: set GATEWAY_ENCRYPTION_KEY and restart |
Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Body
application/json
Response
Connected.
Secret-free projection of a BYO gateway connection.
Show child attributes
Show child attributes
⌘I
Connect (or replace) a payment gateway
curl --request POST \
--url https://billing.example.com/v1/gateway-connections \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"secret_key": "<string>",
"public_key": "<string>",
"webhook_secret": "<string>"
}
'import requests
url = "https://billing.example.com/v1/gateway-connections"
payload = {
"secret_key": "<string>",
"public_key": "<string>",
"webhook_secret": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({secret_key: '<string>', public_key: '<string>', webhook_secret: '<string>'})
};
fetch('https://billing.example.com/v1/gateway-connections', 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://billing.example.com/v1/gateway-connections",
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([
'secret_key' => '<string>',
'public_key' => '<string>',
'webhook_secret' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://billing.example.com/v1/gateway-connections"
payload := strings.NewReader("{\n \"secret_key\": \"<string>\",\n \"public_key\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://billing.example.com/v1/gateway-connections")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"secret_key\": \"<string>\",\n \"public_key\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/gateway-connections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"secret_key\": \"<string>\",\n \"public_key\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"provider": "stripe",
"mode": "test",
"public_key": "<string>",
"has_webhook_secret": true,
"webhook_path": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}