@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
Initialize the client
Pass your API key and, optionally, the target environment. The environment selects the base URL for you — use ask_test_ key with sandbox and a sk_live_ key with mainnet.
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.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 aSohoPayError 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, and5xxresponses are retried with exponential backoff (respectingRetry-After). Configure withmaxRetriesin the constructor; setmaxRetries: 0to disable. - Idempotency — the SDK generates a unique
Idempotency-Keyper POST request and reuses it across retries, so a retried payment can never settle twice. PassidempotencyKeyin 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.

