RailPay
DocsOpen app
Open app

Developers

Build on RailPay.SDK, MCP server and API.

Charge for your API per request, let an agent pay for others, or wire invoices into your product. The SDKs, MCP server, agent tools and facilitator are open source and MIT licensed.

agent.ts · withPayment

import { RailPay, withPayment, readPaymentResponse } from "railpay-sdk";

const railpay = new RailPay({ apiKey: process.env.RAILPAY_AGENT_KEY });
const paidFetch = withPayment(railpay, { maxAmount: "0.05" });

const res = await paidFetch("https://dapp.railpay.app/x402/time");
console.log(await res.json());
console.log(readPaymentResponse(res)?.transaction); // settlement tx hash

From the railpay-sdk and railpay-mcp READMEs. Hosts and keys are placeholders.

Docs

Start where you are.Every guide, one click away.

railpay-sdk

Pay a 402, or send one.One TypeScript package.

withPayment answers a 402 from an agent wallet and retries once. createPaywall answers 402 with your price, settles through an x402 facilitator and reads the transfer back from the chain before your handler runs.

Not on npm yet: install the GitHub release
pnpm add https://github.com/railpayapp/railpay-sdk/releases/download/v0.3.0/railpay-sdk-0.3.0.tgz

Not on npm yet

Install from GitHub. The one runtime dependency is viem. Runs on Node 20+, Bun, Deno and Cloudflare Workers.

Keep agent keys on a server

An agent key can spend from the agent wallet within its policy. Never put it in a browser bundle or a shared repo. Pause the agent or delete the key to cut access at once.

agent.ts · withPayment

import { RailPay, withPayment, readPaymentResponse } from "railpay-sdk";

const railpay = new RailPay({ apiKey: process.env.RAILPAY_AGENT_KEY });
const paidFetch = withPayment(railpay, { maxAmount: "0.05" });

const res = await paidFetch("https://dapp.railpay.app/x402/time");
console.log(await res.json());
console.log(readPaymentResponse(res)?.transaction); // settlement tx hash

railpay-mcp

A wallet for your AI agent.In Claude Code or any MCP client.

Three limits apply to every payment and the tightest wins: the agent policy enforced by RailPay, RAILPAY_MAX_PER_CALL (default 0.1 USDG) enforced by the MCP server, and an optional max_amount per call.

ToolToolWhat it doesSpends
railpay_agentrailpay_agentThe agent wallet: address, USDG balance, ETH, spent today, policy.No
railpay_fetchrailpay_fetchHTTP request that pays a 402 automatically, then returns the body and the payment with its transaction link.Yes
railpay_pay_requirementrailpay_pay_requirementSigns a payment for a 402 the agent already has and returns the PAYMENT-SIGNATURE header to retry with.Yes
railpay_sendrailpay_sendPays another RailPay agent (agt_…).Yes
railpay_networkrailpay_networkPublic facts: chain, USDG, x402 settings, facilitators, relayer status. No key needed.No

Clone both repos side by side

git clone https://github.com/railpayapp/railpay-sdk.git
git clone https://github.com/railpayapp/railpay-mcp.git
cd railpay-sdk && pnpm install && pnpm build && cd ..
cd railpay-mcp && pnpm install && pnpm build

REST API

Plain HTTP and JSON.Two kinds of key.

Base URL https://dapp.railpay.app. Request bodies take USDG as decimal strings; amounts in responses are integers in base units (1 USDG = 1,000,000).

Account keyrp_sk_…

Everything for the owning account: invoices, transfers, paywalls, agents and their policies, and agent withdrawals to the owner's wallet. Created on the Developers page in the app.

Agent keyrp_sk_…

Returned when you create an agent. Only the agent endpoints (pay, send, me), always inside the agent's policy. Cannot touch the owner account or withdraw.

Send keys as Authorization: Bearer rp_sk_…. Keys are shown once; RailPay stores only a SHA-256 hash.

POST /v1/invoices

curl -X POST https://dapp.railpay.app/v1/invoices \
  -H "Authorization: Bearer $RAILPAY_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "amount": "120", "memo": "Design work" }'

Open source

Read the code.MIT licensed, on GitHub.

TypeScript and Python SDKs, an MCP server, agent tools for AI frameworks and a self-hosted x402 facilitator, under the railpayapp organization on GitHub.

Ship a paid endpoint today.Or give an agent a wallet.

Settled in USDG on Robinhood Chain. Every payment is its own transaction, open on the explorer.