By Elijah Skeirik, Payabli Docs
If you’re building a payments integration with TypeScript, you’ve probably hit the point where raw API calls start getting messy: hand-rolling request bodies, deciphering error responses, and having no type hints to tell you whether a field is required or what shape the response will be. The Payabli TypeScript SDK is the fix for that.
@payabli/sdk-node gives you type-safe access to the full Payabli API. That means autocomplete in your editor, TypeScript interfaces for every request and response, built-in retries, and structured error handling you don’t have to wire up yourself. You write less boilerplate and catch more mistakes before they hit production.
This post walks through two things: making your first payment transaction and setting up webhooks to receive real-time payment notifications. Both are covered in depth in the Payabli docs, but this post gives you a faster path from nothing to working code.
Before you start
You’ll need two things from Payabli before writing any code: your API key and an entrypoint value. If you don’t have these credentials set up, talk to your Payabli solutions engineer.
Install the SDK
You’ll need Node.js 20 or later and npm. If you’re not sure which version you have, run node --version to check. You can download the latest Node.js from nodejs.org. Start by creating a new project and installing the SDK:
mkdir my-payabli-app
cd my-payabli-app
npm init -y
npm pkg set type="module"
npm install @payabli/sdk-nodeThat’s it. The TypeScript SDK is now installed.
Make your first transaction
Instantiate the client with your API key and call moneyIn.getpaid. Never hardcode your API key directly in source code, load it from an environment variable instead:
import { PayabliClient } from "@payabli/sdk-node";
const client = new PayabliClient({ apiKey: process.env.PAYABLI_KEY! });A .env file with PAYABLI_KEY=your-key-here and a package like dotenv is the typical setup for local development. In production, inject it via your hosting platform’s secret management tooling. The webhook example app later in this post uses the same pattern.
With the client initialized, make a test transaction:
import { PayabliClient } from "@payabli/sdk-node";
const client = new PayabliClient({ apiKey: "YOUR_API_KEY" });
const result = await client.moneyIn.getpaid({
body: {
customerData: { customerId: 4440 },
entryPoint: "your-entrypoint",
paymentDetails: { serviceFee: 0, totalAmount: 100 },
paymentMethod: {
cardcvv: "999",
cardexp: "02/27",
cardHolder: "John Cassian",
cardnumber: "4111111111111111",
cardzip: "12345",
initiator: "payor",
method: "card",
},
},
});
console.log(result);Run it with npx tsx index.ts.
Sandbox and production environments
Payabli has two environments: sandbox for testing and production for live payments. The sandbox environment lets you make test transactions, simulate boarding, and experiment with webhooks without touching real money. When you’re ready to go live, you switch to production. You pass the environment explicitly when you instantiate the client using PayabliEnvironment:
import { PayabliClient, PayabliEnvironment } from "@payabli/sdk-node";
const client = new PayabliClient({
apiKey: "YOUR_API_KEY",
environment: PayabliEnvironment.Sandbox,
});Your API key is tied to a specific environment, so make sure the key you’re using matches the environment you’re targeting. See Environments in the docs for more detail.
One thing to know before you go live: the example above passes raw card data directly to the API. That works in the sandbox environment and is fine for testing, but in production, you’ll want to use a stored methodReferenceId instead. See Tokenization overview in the docs to learn how to use stored payment methods.
TypeScript SDK features worth knowing
Before moving on to webhooks, a couple of things about the SDK are worth pointing out:
Built-in retries
The SDK automatically retries failed requests on 408, 429, and 5xx responses with exponential backoff. The default retry limit is 2. You can override this per-request:
await client.moneyIn.getpaid(..., { maxRetries: 0 });Typed errors
When the API returns a non-success status code, the SDK throws a PayabliError. Catching it gives you structured access to the status code and response body:
import { PayabliError } from "@payabli/sdk-node";
try {
await client.moneyIn.getpaid(...);
} catch (err) {
if (err instanceof PayabliError) {
console.log(err.statusCode);
console.log(err.body);
}
}Typed request interfaces
The SDK exports every request and response type under the Payabli namespace, so you can construct payloads with full type safety before passing them to the client. This is useful when you’re building up a request object across multiple steps, or when you want your editor to catch shape errors early:
import { PayabliClient, Payabli } from "@payabli/sdk-node";
const payment: Payabli.RequestPayment = {
body: {
customerData: { customerId: 4440 },
entryPoint: "your-entrypoint",
paymentDetails: { serviceFee: 0, totalAmount: 100 },
paymentMethod: {
cardHolder: "John Cassian",
cardnumber: "4111111111111111",
cardexp: "02/27",
cardcvv: "999",
cardzip: "12345",
initiator: "payor",
method: "card",
},
},
};
const result = await client.moneyIn.getpaid(payment);Tree-shakeable subpackage imports
If bundle size matters, you can import individual subpackage clients instead of the top-level PayabliClient:
import { MoneyInClient } from "@payabli/sdk-node/money-in";This lets bundlers include only the code your app actually uses.
Set up webhooks
Once payments are flowing, you’ll want to know about them in real time. Payabli’s webhook system sends HTTP POST requests to your server whenever payment events occur.
The fastest way to get webhooks working with the TypeScript SDK is the webhook example app. Clone the examples repo and navigate to the TypeScript webhook app:
git clone https://github.com/payabli/examples.git
cd examples/webhooks/ts-sdkCopy the environment template and fill in your credentials:
cp .env.example .envYou’ll need to set PAYABLI_KEY, PAYABLI_ENTRY, and OWNER_ID in the .env file. The OWNER_ID is the same as your organization’s ID in Payabli.
Install the dependencies and start the app:
npm install
npm startThe app starts a local server on port 3000. To receive webhooks, that server needs to be reachable from the internet, so you need to tunnel it. The easiest option is localhost.run, which requires no account. It does require SSH, the Secure Shell program that handles encrypted connections between machines. SSH comes pre-installed on macOS and most Linux systems. On Windows, it’s available through the built-in OpenSSH client (included since Windows 10).
Run this in a new terminal window while your app is running:
ssh -R 80:localhost:3000 nokey@localhost.runYou’ll get a public HTTPS URL. Paste it into the original terminal window when the app prompts you.
If you’d prefer more visibility into webhook traffic (request inspection, replay, and so on), ngrok is a popular alternative that requires a free account and a small install step. The Webhook quickstart in the Payabli docs covers both tools in detail.
From there, the app does the rest: it registers an ApprovedPayment notification with Payabli pointing to your tunnel URL, then waits for you to press Enter. Hit Enter, and the app fires a test $1.00 transaction and prints the incoming webhook payload to your terminal.
That’s the full loop: a transaction goes through, Payabli fires a webhook, and your server receives it.
See the Webhook quickstart in the Payabli docs for more details, including how to build a webhook server from scratch and how to register notifications for other event types beyond ApprovedPayment.
Keep going
Here’s a quick map of where to go next, depending on what you’re working on:
| If you want to… | Go here |
|---|---|
| Understand the Payabli platform as a developer | Getting started for developers |
| See every available SDK method | SDK reference on GitHub |
| Work through a full example app (customers, temp tokens) | TypeScript SDK guide |
| Build a production-safe payment flow with stored methods | Tokenization overview |
| Register webhooks for other event types | Webhook quickstart |
Your Payabli solutions engineer is also a resource if you get stuck or need help scoping your integration.
Learn about our developer tools and server SDKs in the Payabli Docs.


