Quickstart
Keys → first payout → webhooks: build an end-to-end integration against the Storspay sandbox in minutes.
Sandbox access comes with the Enterprise plan. Storspay is a FINTRAC-registered money services business. Support: info@storsapp.com.
This quickstart guides you through the complete lifecycle of a Storspay integration: obtaining credentials, funding your test balance, adding a beneficiary, dispatching your first cross-border payout, and verifying incoming signed webhooks.
Payout lifecycle
%%{init: {"theme": "base", "themeVariables": {"primaryColor": "#6B3FA0", "primaryTextColor": "#FFFFFF", "primaryBorderColor": "#5A2D8C", "lineColor": "#6B3FA0", "textColor": "#1E1E2E", "background": "#F5F0E8"}}}%%
stateDiagram-v2
[*] --> created : POST /v1/payouts with clientRef
created --> processing : Dispatched to delivery network
processing --> paid : Funds delivered to recipient
processing --> failed : Delivery refused (auto-refunded to balance)
created --> cancelled : POST /v1/payouts/{id}/cancel (within 60s window)
paid --> [*]
failed --> [*]
cancelled --> [*]
1. Get credentials and access token
Create API keys in Developers → API keys on your dashboard. Use client credentials to generate a short-lived OAuth access token.
curl -X POST https://api.sandbox.storspay.com/v1/oauth/token \
-u "$STORSPAY_CLIENT_ID:$STORSPAY_CLIENT_SECRET" \
-d grant_type=client_credentials
const clientId = process.env.STORSPAY_CLIENT_ID;
const clientSecret = process.env.STORSPAY_CLIENT_SECRET;
const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString("base64");
const response = await fetch("https://api.sandbox.storspay.com/v1/oauth/token", {
method: "POST",
headers: {
"Authorization": `Basic ${basicAuth}`,
"Content-Type": "application/x-www-form-urlencoded",
},
body: "grant_type=client_credentials",
});
const { accessToken } = await response.json();
import os, requests
client_id = os.environ["STORSPAY_CLIENT_ID"]
client_secret = os.environ["STORSPAY_CLIENT_SECRET"]
resp = requests.post(
"https://api.sandbox.storspay.com/v1/oauth/token",
auth=(client_id, client_secret),
data={"grant_type": "client_credentials"},
)
access_token = resp.json()["accessToken"]
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
String clientId = System.getenv("STORSPAY_CLIENT_ID");
String clientSecret = System.getenv("STORSPAY_CLIENT_SECRET");
String auth = Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes(StandardCharsets.UTF_8));
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.sandbox.storspay.com/v1/oauth/token"))
.header("Authorization", "Basic " + auth)
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString("grant_type=client_credentials"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
200 OK
{
"accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9…",
"tokenType": "Bearer",
"expiresIn": 86400,
"scope": "create:payouts read:payouts create:quotes read:ledger manage:beneficiaries"
}
401 Unauthorized
{
"error": "INVALID_CLIENT",
"message": "Client authentication failed. Check your client ID and secret."
}
2. Add test balance in the sandbox
In the sandbox, add test funds directly to your workspace balance using the deposit simulation endpoint.
curl -X POST https://api.sandbox.storspay.com/v1/sandbox/deposits \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "amount": "500.00", "currency": "USD" }'
await fetch("https://api.sandbox.storspay.com/v1/sandbox/deposits", {
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ amount: "500.00", currency: "USD" }),
});
requests.post(
"https://api.sandbox.storspay.com/v1/sandbox/deposits",
headers={"Authorization": f"Bearer {access_token}"},
json={"amount": "500.00", "currency": "USD"},
)
HttpRequest depositReq = HttpRequest.newBuilder()
.uri(URI.create("https://api.sandbox.storspay.com/v1/sandbox/deposits"))
.header("Authorization", "Bearer " + accessToken)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("{\"amount\":\"500.00\",\"currency\":\"USD\"}"))
.build();
client.send(depositReq, HttpResponse.BodyHandlers.ofString());
201 Created
{
"id": "dep_test_01HK98ABC",
"amount": "500.00",
"currency": "USD",
"status": "credited",
"creditedAt": "2026-11-28T10:00:00Z"
}
400 Bad Request
{
"error": "INVALID_AMOUNT",
"message": "Amount must be a positive decimal string with two fraction digits."
}
3. Register a beneficiary
Create a beneficiary for your recipient. In the sandbox, account numbers ending in 00 (such as 9900000000) simulate successful delivery.
curl -X POST https://api.sandbox.storspay.com/v1/beneficiaries \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "individual",
"name": "Amina Okafor",
"country": "NGA",
"currency": "NGN",
"route": "bank",
"bankCode": "044",
"accountNumber": "9900000000"
}'
const beneficiaryRes = await fetch("https://api.sandbox.storspay.com/v1/beneficiaries", {
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "individual",
name: "Amina Okafor",
country: "NGA",
currency: "NGN",
route: "bank",
bankCode: "044",
accountNumber: "9900000000",
}),
});
const beneficiary = await beneficiaryRes.json();
ben_resp = requests.post(
"https://api.sandbox.storspay.com/v1/beneficiaries",
headers={"Authorization": f"Bearer {access_token}"},
json={
"type": "individual",
"name": "Amina Okafor",
"country": "NGA",
"currency": "NGN",
"route": "bank",
"bankCode": "044",
"accountNumber": "9900000000",
},
)
beneficiary = ben_resp.json()
HttpRequest benReq = HttpRequest.newBuilder()
.uri(URI.create("https://api.sandbox.storspay.com/v1/beneficiaries"))
.header("Authorization", "Bearer " + accessToken)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("""
{
"type": "individual",
"name": "Amina Okafor",
"country": "NGA",
"currency": "NGN",
"route": "bank",
"bankCode": "044",
"accountNumber": "9900000000"
}
"""))
.build();
HttpResponse<String> benRes = client.send(benReq, HttpResponse.BodyHandlers.ofString());
201 Created
{
"id": "ben_01J8F2KLM9",
"type": "individual",
"name": "Amina Okafor",
"country": "NGA",
"currency": "NGN",
"route": "bank",
"accountNumber": "9900000000",
"resolvedName": "Sandbox: paid",
"createdAt": "2026-11-28T10:01:00Z"
}
422 Unprocessable
{
"error": "INVALID_ACCOUNT_DETAILS",
"message": "Bank account number must be 10 digits for Nigerian bank transfers."
}
4. Get a quote
Quotes fix the foreign exchange rate and fees for 5 minutes. You never submit unquoted exchange rates or fees.
curl -X POST https://api.sandbox.storspay.com/v1/quotes \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"intent": "payout",
"sourceCurrency": "USD",
"destinationCurrency": "NGN",
"amount": "100.00",
"amountType": "send",
"country": "NGA",
"route": "bank",
"beneficiaryId": "ben_01J8F2KLM9"
}'
const quoteRes = await fetch("https://api.sandbox.storspay.com/v1/quotes", {
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
intent: "payout",
sourceCurrency: "USD",
destinationCurrency: "NGN",
amount: "100.00",
amountType: "send",
country: "NGA",
route: "bank",
beneficiaryId: beneficiary.id,
}),
});
const quote = await quoteRes.json();
quote_resp = requests.post(
"https://api.sandbox.storspay.com/v1/quotes",
headers={"Authorization": f"Bearer {access_token}"},
json={
"intent": "payout",
"sourceCurrency": "USD",
"destinationCurrency": "NGN",
"amount": "100.00",
"amountType": "send",
"country": "NGA",
"route": "bank",
"beneficiaryId": beneficiary["id"],
},
)
quote = quote_resp.json()
HttpRequest quoteReq = HttpRequest.newBuilder()
.uri(URI.create("https://api.sandbox.storspay.com/v1/quotes"))
.header("Authorization", "Bearer " + accessToken)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("""
{
"intent": "payout",
"sourceCurrency": "USD",
"destinationCurrency": "NGN",
"amount": "100.00",
"amountType": "send",
"country": "NGA",
"route": "bank",
"beneficiaryId": "ben_01J8F2KLM9"
}
"""))
.build();
HttpResponse<String> quoteRes = client.send(quoteReq, HttpResponse.BodyHandlers.ofString());
201 Created
{
"id": "qt_01HK987XYZ",
"intent": "payout",
"sourceCurrency": "USD",
"destinationCurrency": "NGN",
"sourceAmount": "100.00",
"destinationAmount": "132500.00",
"exchangeRate": "1325.00",
"fee": "2.00",
"total": "102.00",
"expiresAt": "2026-11-28T10:06:00Z"
}
400 Bad Request
{
"error": "CORRIDOR_UNAVAILABLE",
"message": "The selected corridor USD to NGN is currently disabled."
}
5. Send the payout with an idempotency key
Always supply your own unique clientRef. If a timeout or network interruption occurs, retrying with the same clientRef safely returns the existing payout without debiting twice.
curl -X POST https://api.sandbox.storspay.com/v1/payouts \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"quoteId": "qt_01HK987XYZ",
"beneficiaryId": "ben_01J8F2KLM9",
"clientRef": "quickstart-payout-001"
}'
const payoutRes = await fetch("https://api.sandbox.storspay.com/v1/payouts", {
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
quoteId: quote.id,
beneficiaryId: beneficiary.id,
clientRef: "quickstart-payout-001",
}),
});
const payout = await payoutRes.json();
payout_resp = requests.post(
"https://api.sandbox.storspay.com/v1/payouts",
headers={"Authorization": f"Bearer {access_token}"},
json={
"quoteId": quote["id"],
"beneficiaryId": beneficiary["id"],
"clientRef": "quickstart-payout-001",
},
)
payout = payout_resp.json()
HttpRequest payoutReq = HttpRequest.newBuilder()
.uri(URI.create("https://api.sandbox.storspay.com/v1/payouts"))
.header("Authorization", "Bearer " + accessToken)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("""
{
"quoteId": "qt_01HK987XYZ",
"beneficiaryId": "ben_01J8F2KLM9",
"clientRef": "quickstart-payout-001"
}
"""))
.build();
HttpResponse<String> payoutRes = client.send(payoutReq, HttpResponse.BodyHandlers.ofString());
201 Created
{
"id": "po_8F2K1M3QZ",
"clientRef": "quickstart-payout-001",
"status": "created",
"sourceAmount": "100.00",
"sourceCurrency": "USD",
"destinationAmount": "132500.00",
"destinationCurrency": "NGN",
"fee": "2.00",
"cancellable": true,
"createdAt": "2026-11-28T10:02:00Z"
}
400 Bad Request
{
"error": "QUOTE_EXPIRED",
"message": "The quote has expired. Please request a fresh quote."
}
403 Forbidden
{
"error": "INSUFFICIENT_FUNDS",
"message": "Available balance is insufficient for this payout and fee."
}
422 Unprocessable
{
"error": "BENEFICIARY_MISMATCH",
"message": "The beneficiaryId does not match the quote."
}
6. Receive and verify webhooks
Storspay signs every webhook with the Storspay-Signature header (HMAC-SHA256 using your endpoint secret whsec_…). Verify the signature on the raw request body before parsing JSON.
import { createHmac, timingSafeEqual } from "node:crypto";
export function handleWebhook(req, res, secret) {
const signature = req.headers["storspay-signature"];
const rawBody = req.body; // Raw unparsed Buffer / string
const parts = String(signature ?? "").split(",").map((p) => p.trim().split("="));
const t = parts.find(([k]) => k === "t")?.[1];
if (!t || Math.abs(Date.now() / 1000 - Number(t)) > 300) {
return res.status(400).send("Timestamp outside tolerance");
}
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const isValid = parts
.filter(([k]) => k === "v1")
.some(([, sig]) => sig.length === expected.length &&
timingSafeEqual(Buffer.from(sig), Buffer.from(expected)));
if (!isValid) return res.status(401).send("Invalid signature");
const event = JSON.parse(rawBody);
if (event.type === "payout.paid") {
console.log(`Payout ${event.data.id} delivered: ${event.data.destinationAmount} ${event.data.destinationCurrency}`);
}
res.status(200).send("OK");
}
import hmac, hashlib, time, json
def verify_and_handle_webhook(raw_body: bytes, signature_header: str, secret: str):
parts = [p.strip().split("=", 1) for p in signature_header.split(",") if "=" in p]
t = next((v for k, v in parts if k == "t"), "")
if not t or abs(time.time() - int(t)) > 300:
raise ValueError("Invalid timestamp")
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
if not any(hmac.compare_digest(v, expected) for k, v in parts if k == "v1"):
raise PermissionError("Signature mismatch")
event = json.loads(raw_body.decode("utf-8"))
if event.get("type") == "payout.paid":
payout_id = event["data"]["id"]
print(f"Payout {payout_id} delivered successfully")
return {"status": "ok"}
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HexFormat;
import java.util.List;
public class StorspayWebhook {
public static boolean verify(byte[] rawBody, String signatureHeader, String secret) throws Exception {
String t = null;
List<String> sigs = new ArrayList<>();
for (String part : signatureHeader.split(",")) {
String[] kv = part.trim().split("=", 2);
if (kv.length != 2) continue;
if (kv[0].equals("t")) t = kv[1];
if (kv[0].equals("v1")) sigs.add(kv[1]);
}
if (t == null || Math.abs(Instant.now().getEpochSecond() - Long.parseLong(t)) > 300) {
return false;
}
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
mac.update((t + ".").getBytes(StandardCharsets.UTF_8));
byte[] expected = HexFormat.of().formatHex(mac.doFinal(rawBody)).getBytes(StandardCharsets.UTF_8);
return sigs.stream().anyMatch(sig -> MessageDigest.isEqual(
sig.getBytes(StandardCharsets.UTF_8),
expected
));
}
}
# Test your webhook handler locally using a signed payload simulator
curl -X POST https://api.sandbox.storspay.com/v1/sandbox/webhook-deliveries \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"endpointId": "we_01HK987WEP",
"eventType": "payout.paid",
"resourceId": "po_8F2K1M3QZ"
}'
200 Webhook Received
{
"id": "evt_01HK98DELIV01",
"type": "payout.paid",
"createdAt": "2026-11-28T10:03:00Z",
"data": {
"id": "po_8F2K1M3QZ",
"clientRef": "quickstart-payout-001",
"status": "paid",
"sourceAmount": "100.00",
"sourceCurrency": "USD",
"destinationAmount": "132500.00",
"destinationCurrency": "NGN",
"fee": "2.00",
"paidAt": "2026-11-28T10:03:00Z"
}
}
Next steps
- Explore all magic values for testing error flows: Sandbox and magic values and Cheat sheet.
- Integrate AI agents using mandates: Agent payouts (MCP).
- Build escrow checkout for marketplace sellers: Marketplace with escrow.