Skip to main content
The Midaz SDK for TypeScript helps you build financial integrations. It gives you a typed, developer-friendly interface over the Midaz financial services platform. You focus on your business logic, not on the transport code. The SDK works with Organizations, Ledgers, Accounts, Transactions, and more. Use it for a simple workflow or for complex operations. A layered, modular architecture supports performance, extensibility, and the developer experience.

Why use the Midaz SDK for TypeScript?

  • Type-safe by design: Full TypeScript support with precise type definitions.
  • Builder pattern: Fluent, readable interfaces to construct complex objects.
  • Robust error handling: Recovery strategies and clear error signals.
  • Observability included: Tracing, metrics, and logs, ready to use.
  • Layered architecture: Clean separation between client, entities, API, and models.
  • Automatic retries: Configurable retry policies for transient failures.
  • Concurrency controls: Built-in tools to run tasks in parallel with controlled throughput.
  • Fast with caching: In-memory caching for better performance.
  • Strict validation: Catch invalid input early with clear error messages.

Getting started


Prerequisite

  • The Midaz SDK for TypeScript requires TypeScript v5.8 or later.

Installing the SDK

Install the Midaz SDK for TypeScript with one of the following commands:
After you install it, follow the Quick Start Guide to learn how to use the SDK.

Authentication


The Midaz SDK for TypeScript authenticates through the Lerian Access Manager (OAuth). For a local stack with authentication disabled, you can build a client without it. You never call a createClient factory — build a configuration with createClientConfigWithAccessManager() (or createClientConfigBuilder() for a no-auth local stack) and pass it to new MidazClient(config).

Access Manager authentication

To integrate with external identity providers over OAuth:
The Access Manager handles tokens for you: acquisition, caching, and renewal. You do not manage tokens manually.

Local development (no authentication)

For a local Midaz stack with authentication disabled, build a client without the Access Manager:
We offer an Access Manager plugin that you can use. If you’d like to know more about it, contact us.

Quick start guide


The following sections give practical code examples for the Midaz SDK for TypeScript.

Create a client

This is the first step. The client is your main entry point to the SDK. It handles authentication and gives you access to all entity services. Example:

Create an Asset

Create assets with the builder pattern and createAssetBuilder. Example:
In this code, you add the required name and assetCode fields to the builder const assetInput = createAssetBuilder('US Dollar', 'USD'). Then you add any other properties with with* methods.

Create an Account

Create accounts with the builder pattern and createAccountBuilder. Example:
In this code, you add the required name and assetCode fields to the builder const accountInput = createAccountBuilder('Savings Account', 'USD'). Then you add any other properties with with* methods.

Create a Transaction

Create transactions with the builder pattern and createTransactionBuilder. Example:
In this code, you add all properties with with* methods.

Error recovery

Use enhanced error recovery for critical operations.

Clean up resources

Using Access Manager for authentication

SDK architecture


The Midaz SDK uses a multi-layered service architecture for a clean, modular, and scalable developer experience. It has three layers, shown in Figure 1. Each layer serves a distinct purpose.
  • Client interface: This is the main entry point for SDK users. It manages configuration such as API keys and environments. It initializes services lazily and exposes all SDK functionality.
  • Entity services layer: This layer holds domain-specific services, such as Accounts, Assets, and Transactions. Each service offers consistent methods: create, get, update, delete, and list. Each service also adds specialized operations for its entity.
  • Core services layer: All entity services use these foundational utilities. They handle HTTP requests, input validation, error processing, observability, configuration, and caching.
Layered architecture of the Midaz SDK for TypeScript, with the client interface over the entity services layer over the shared core services layer

Figure 1. The layered architecture of the Midaz SDK for TypeScript.

The SDK architecture emphasizes:
  • Consistency through shared patterns across services.
  • Scalability via dependency injection and service factories.
  • Reliability through enhanced error handling and typed responses.
  • Testability with support for mocking, integration, and contract testing.
Want to dive Deeper? Check the following pages for more information about the Architecture:

Builder pattern


The Midaz SDK for TypeScript uses a builder pattern to help you assemble complex objects in a safe, adaptable way. Instead of a fixed set of inputs, it gives you a step-by-step, fluent, chainable interface. Builder functions in the SDK:
  • Tell you the parameters in advance.
  • Let you set optional fields with .with*() methods and chain them.
  • Prevent invalid states through a guided structure.
  • Hide internal complexity for better readability.

Example

Here’s a quick example:
You can then pass this assetInput to the corresponding create method in the SDK.
Want to dive deeper? Check the Builder Pattern in Midaz SDK page for more information.

Working with entities


Each entity service covers a distinct part of the financial domain, such as accounts, assets, or transactions. These services create, retrieve, update, and delete data for each type of entity. They also offer specialized features for each use case, so you handle financial data with confidence. You access each service through the SDK client. They follow a consistent structure, so you build and maintain financial features more easily.
Want to dive deeper? Check the Entities pages for more information.

Using utilities


The SDK provides utility modules for common operations: performance, error handling, configuration, and observability. These tools work with the rest of the SDK and help you build financial applications with less effort.
Want to dive deeper? Check the Utilities pages for more information.

Error handling


The Midaz SDK for TypeScript helps you handle errors clearly and consistently. When an error occurs during an SDK operation, the SDK throws a structured error. The error includes key fields:
  • code: A short, consistent identifier for the error type.
  • message: A human-readable description.
  • statusCode: The HTTP status code, when available.
Handle an error like this:

Common error codes

Best practices

  • Validate input before you call SDK methods, to avoid invalid_input.
  • Check your auth when you get unauthorized or forbidden.
  • Retry on transient issues like internal_error or service_unavailable.
  • Use statusCode and message to show debug info in development logs.
The SDK keeps errors predictable and actionable.
TipWant to dive deeper? Check the following pages for more information:

CI/CD pipeline


We use GitHub Actions for automated, production-ready builds:
  • Runs tests across multiple Node.js versions.
  • Enforces code quality with ESLint and Prettier.
  • Keeps dependencies up to date with Dependabot.
  • Handles releases automatically with semantic versioning.
  • Generates changelogs.

Want to contribute?


To contribute to the Midaz SDK for TypeScript, start with our contributing guide on GitHub. It covers what you need to get started.

License


This project is licensed under the Apache License 2.0. For details, see the License page.