The @sohopay/sdk package is the official TypeScript client for the SohoPay API. It ships full type definitions, automatic retries, and per-request idempotency, so you can integrate agents, orders, and payments without hand-rolling HTTP calls.

Installation

The SDK supports Node.js 18+ and works in any TypeScript or plain JavaScript project. Source and issues live at github.com/sohopay/sohopay-node; releases are published to npm.

Initialize the client

Pass your API key and, optionally, the target environment. The environment selects the base URL for you — use a sk_test_ key with sandbox and a sk_live_ key with mainnet.
Never embed API keys in client-side code or commit them to git. Load them from environment variables or a secrets manager. See Authentication & Security.

Quick example

The canonical flow: create an agent with a credit line, create an order, submit the payment, and verify the settlement webhook when it arrives.
To confirm settlement, verify the payment.settled webhook instead of polling. The SDK validates the HMAC-SHA256 signature and timestamp for you:

Method reference

All methods are camelCase and return typed promises. Parameters mirror the API Reference with camelCase field names.

Error handling

Every non-2xx response throws a SohoPayError carrying the API’s error code, the HTTP status, and the requestId to quote in support tickets. See Errors for the full code list.

Advanced

  • Automatic retries — network failures, 429, and 5xx responses are retried with exponential backoff (respecting Retry-After). Configure with maxRetries in the constructor; set maxRetries: 0 to disable.
  • Idempotency — the SDK generates a unique Idempotency-Key per POST request and reuses it across retries, so a retried payment can never settle twice. Pass idempotencyKey in the per-request options to control it yourself.
  • TypeScript types — every request and response shape is exported: import type { Agent, Order, Payment, Settlement, WebhookEvent } from "@sohopay/sdk".
A Go SDK and a sohopay CLI are on the roadmap but not yet shipped. Until then, generate a Go client from the OpenAPI spec — see OpenAPI Tools.

Next steps

Python SDK

The same client surface in Python idiom.

Code Examples

Runnable, CI-tested examples for every core flow.

Webhooks Guide

Signature verification, retries, and event handling in depth.