AI Agent Payouts with Mandates
Give AI agents permission-bounded payout capabilities using Model Context Protocol (MCP) and Storspay mandates.
Enterprise feature. Available behind PLAN_FEATURES.agentPayouts. Storspay is a FINTRAC-registered money services business. Support: info@storsapp.com.
Autonomous AI agents can disburse cross-border supplier and contractor payments through the Storspay Model Context Protocol (MCP) server. To ensure financial safety, every agent action executes strictly within a human-governed mandate.
What is an agent mandate?
A mandate (mnd_…) is a set of programmatic boundaries configured in the Storspay dashboard or API. It governs what an AI agent is allowed to do without human intervention:
- Approved recipients: Explicit list of pre-vetted beneficiary IDs (
ben_…). The agent cannot pay unlisted recipients. - Allowed corridors: Permitted origin and destination currency pairs (e.g.
USDtoNGN,USDtoKES). - Single-transaction limit: Maximum amount allowed per individual payout (e.g.
"500.00"USD). - Monthly spend cap: Cumulative expenditure ceiling for the calendar month (e.g.
"25000.00"USD). - Approval threshold (
requireApprovalAbove): Payments at or below this threshold (e.g."250.00"USD) execute immediately. Any payout exceeding this amount is not rejected; it is paused aspending_approvalfor human one-click sign-off in the dashboard.
Mandates are the customer's own rules for their agent. An agent can never widen its own mandate limits. Storspay's core rule remains "no holds on live" — the mandate is your company's internal control.
Agent payout lifecycle
%%{init: {"theme": "base", "themeVariables": {"primaryColor": "#6B3FA0", "primaryTextColor": "#FFFFFF", "primaryBorderColor": "#5A2D8C", "lineColor": "#6B3FA0", "textColor": "#1E1E2E", "background": "#F5F0E8"}}}%%
stateDiagram-v2
[*] --> MandateCheck: Agent calls storspay_create_payout
MandateCheck --> Refused: Recipient or corridor not in mandate
MandateCheck --> Refused: Exceeds single limit or monthly cap
Refused --> [*]: 403 Forbidden (Refusal logged)
MandateCheck --> DirectExecute: Amount <= requireApprovalAbove
MandateCheck --> HumanApprovalQueue: Amount > requireApprovalAbove
DirectExecute --> Processing: 200 Executed (Payout created)
HumanApprovalQueue --> Processing: Human Approver approves in app
HumanApprovalQueue --> Refused: Human Approver declines in app
Processing --> Paid: Delivered to recipient
Processing --> Failed: Delivery network error (auto-refunded)
Paid --> [*]
Failed --> [*]
MCP tools reference
The Storspay MCP server is available at https://app.storspay.com/mcp (Sandbox: https://sandbox.storspay.com/mcp). It provides four tools:
1. storspay_create_payout
Dispatches a payout within a mandate.
| Parameter | Type | Required | Description |
|---|---|---|---|
mandate_id | string | Yes | The mandate identifier (mnd_…) |
beneficiary_id | string | Yes | Pre-approved beneficiary ID (ben_…) |
amount | string | Yes | Decimal string amount in source currency (e.g. "150.00") |
currency | string | Yes | Source currency (USD, EUR, GBP, CAD) |
client_ref | string | Yes | Unique idempotency reference generated by the agent |
reason | string | No | Business narration or invoice note |
Response tabs by status
200 Executed
{
"payoutId": "po_8F2K1M3QZ",
"status": "executed",
"sourceAmount": "150.00",
"sourceCurrency": "USD",
"destinationAmount": "199375.50",
"destinationCurrency": "NGN",
"fee": "3.00",
"mandateId": "mnd_7hf2KL9",
"mandateRemaining": "24850.00",
"humanActionRequired": false
}
202 Pending Approval
{
"payoutId": "po_9G3L2N4RA",
"status": "pending_approval",
"sourceAmount": "400.00",
"sourceCurrency": "USD",
"mandateId": "mnd_7hf2KL9",
"humanActionRequired": true,
"reason": "Amount exceeds auto-approval threshold ($250.00). Queued in Pending Approvals for human review."
}
403 Mandate Refusal
{
"error": "MANDATE_RECIPIENT_NOT_PERMITTED",
"message": "Beneficiary ben_999 is not in the mandate's approved recipient list.",
"mandateId": "mnd_7hf2KL9",
"refusalLogged": true
}
2. storspay_get_mandate
Inspects mandate boundaries, permitted corridors, and remaining budget for the current month.
{
"mandateId": "mnd_7hf2KL9",
"name": "Weekly contractor payouts",
"status": "active",
"currency": "USD",
"singleTransactionLimit": "500.00",
"monthlyCap": "25000.00",
"usedThisMonth": "150.00",
"remainingThisMonth": "24850.00",
"requireApprovalAbove": "250.00",
"allowedCorridors": ["USD->NGN", "USD->KES", "USD->GHA"],
"approvedRecipientsCount": 14
}
3. storspay_list_recipients
Lists approved beneficiaries associated with the mandate.
4. storspay_get_payout
Checks execution and delivery status of a previously dispatched payout.
Sample integrations
The examples below illustrate how to invoke storspay_create_payout inside a mandate across three popular AI agent frameworks.
import os
from langchain.tools import tool
from langchain_openai import ChatOpenAI
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate
import requests
STORSPAY_API_URL = "https://api.sandbox.storspay.com/v1"
STORSPAY_TOKEN = os.environ["STORSPAY_ACCESS_TOKEN"]
MANDATE_ID = "mnd_7hf2KL9"
@tool
def storspay_create_payout(beneficiary_id: str, amount: str, currency: str, client_ref: str) -> dict:
"""Execute a cross-border payout using the Storspay MCP tool inside the company mandate.
Amounts must be formatted as two-decimal strings, e.g. '150.00'.
"""
headers = {
"Authorization": f"Bearer {STORSPAY_TOKEN}",
"Content-Type": "application/json",
}
payload = {
"mandateId": MANDATE_ID,
"beneficiaryId": beneficiary_id,
"amount": amount,
"currency": currency,
"clientRef": client_ref,
}
response = requests.post(f"{STORSPAY_API_URL}/mcp/tools/create-payout", json=payload, headers=headers)
return response.json()
prompt = ChatPromptTemplate.from_messages([
("system", "You are a financial operations agent. You pay approved annotators using the Storspay mandate. "
"Amounts must always be decimal strings. Check whether actions require human approval."),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
])
llm = ChatOpenAI(model="gpt-4o", temperature=0)
agent = create_tool_calling_agent(llm, [storspay_create_payout], prompt)
executor = AgentExecutor(agent=agent, tools=[storspay_create_payout], verbose=True)
# Run agent
result = executor.invoke({
"input": "Pay contractor ben_01J8F2KLM9 an amount of 150.00 USD for milestone 3 with reference task-441."
})
print(result["output"])
import os, json
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
MANDATE_ID = "mnd_7hf2KL9"
tools = [
{
"type": "function",
"function": {
"name": "storspay_create_payout",
"description": "Dispatches a cross-border payment within a Storspay mandate. Amounts are decimal strings.",
"parameters": {
"type": "object",
"properties": {
"mandate_id": {"type": "string", "description": "The mandate identifier"},
"beneficiary_id": {"type": "string", "description": "Beneficiary ID, e.g. ben_01J8F2KLM9"},
"amount": {"type": "string", "description": "Amount as decimal string, e.g. '150.00'"},
"currency": {"type": "string", "enum": ["USD", "EUR", "GBP", "CAD"]},
"client_ref": {"type": "string", "description": "Unique idempotency reference"},
},
"required": ["mandate_id", "beneficiary_id", "amount", "currency", "client_ref"],
},
},
}
]
messages = [
{"role": "system", "content": f"You are an accounts payable AI agent. Always use mandate '{MANDATE_ID}'. "
"Never invent unapproved beneficiaries. If amount exceeds 250.00 USD, "
"notify the user that human approval will be required."},
{"role": "user", "content": "Disburse 150.00 USD to contractor ben_01J8F2KLM9 for data tagging ref tag-099."},
]
response = client.chat.completions.create(model="gpt-4o", messages=messages, tools=tools)
tool_call = response.choices[0].message.tool_calls[0]
arguments = json.loads(tool_call.function.arguments)
print(f"Agent invoked tool {tool_call.function.name} with arguments:")
print(json.dumps(arguments, indent=2))
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic();
const MANDATE_ID = "mnd_7hf2KL9";
const storspayTool: Anthropic.Tool = {
name: "storspay_create_payout",
description: "Execute a cross-border contractor payout inside a Storspay mandate. Amounts must be decimal strings.",
input_schema: {
type: "object",
properties: {
mandate_id: { type: "string" },
beneficiary_id: { type: "string" },
amount: { type: "string" },
currency: { type: "string" },
client_ref: { type: "string" },
},
required: ["mandate_id", "beneficiary_id", "amount", "currency", "client_ref"],
},
};
async function runAgent() {
const response = await anthropic.messages.create({
model: "claude-3-5-sonnet-20241022",
max_tokens: 1024,
system: `You are an automated payroll agent. You operate within Storspay mandate ${MANDATE_ID}. ` +
"Amounts must always be two-decimal strings. Notify the user if a payout enters pending_approval.",
messages: [
{
role: "user",
content: "Please pay contractor ben_01J8F2KLM9 an amount of 150.00 USD for translation tasks. Ref: trans-082.",
},
],
tools: [storspayTool],
});
for (const block of response.content) {
if (block.type === "tool_use" && block.name === "storspay_create_payout") {
console.log("Claude requested tool execution with input:", block.input);
}
}
}
runAgent();
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
// Calling the Storspay MCP tool endpoint from Java
String payload = """
{
"mandateId": "mnd_7hf2KL9",
"beneficiaryId": "ben_01J8F2KLM9",
"amount": "150.00",
"currency": "USD",
"clientRef": "agent-inv-992"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.sandbox.storspay.com/v1/mcp/tools/create-payout"))
.header("Authorization", "Bearer " + System.getenv("STORSPAY_ACCESS_TOKEN"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response status: " + response.statusCode());
System.out.println("Body: " + response.body());
Safety and audit trail
- Idempotency: Agents must supply a unique
client_reffor each action. Re-trying a call with the sameclient_refreturns the existing execution record without duplicating transactions. - Refusal audit log: Any attempt by an AI agent to call an unapproved recipient, use an unauthorized corridor, or exceed transaction caps produces an append-only audit record and sends a notification to company admins.
- Emergency pause: Company admins can pause all AI agent mandates at once with a single button in the Storspay dashboard.