Skip to main content
This guide walks you from zero to a working API call in under 5 minutes.

1. Install the package

2. Set your credentials

Don’t have credentials yet?Contact support@oaknetwork.org to get your sandbox CLIENT_ID and CLIENT_SECRET.
Create a .env file in your project root:

3. Create a client

createOakClient configures authentication and retry behavior. Each create*Service(client) factory returns a typed service instance — import only the services you need.

4. Make your first call

Save steps 3 and 4 together in a file (e.g. index.ts) and run it:
Every SDK method returns a Result<T, OakError> — a discriminated union that is either { ok: true, value: T } or { ok: false, error: OakError }. Check result.ok before accessing the value.
This pattern replaces try/catch for API calls. The SDK never throws on HTTP errors — it wraps them in the Result type. For the full breakdown, see Error Handling.

5. Create a customer

6. Create a payment

Steps 5 and 6 go inside the main() function, after the list call.

Adding more services

Import additional service factories as you need them:
All services share the same client — authentication and retry logic are handled once.
  • Authentication — how OAuth2 token management works under the hood
  • Payments — create, confirm, and cancel payments across providers
  • Webhooks — register endpoints and receive real-time event notifications
  • Error Handling — the Result<T> pattern, error types, and retry configuration