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: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:Local development (no authentication)
For a local Midaz stack with authentication disabled, build a client without the Access Manager: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 andcreateAssetBuilder.
Example:
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 andcreateAccountBuilder.
Example:
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 andcreateTransactionBuilder.
Example:
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.
Figure 1. The layered architecture of the Midaz SDK for TypeScript.
- 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.
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:assetInput to the corresponding create method in the SDK.
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.
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.
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.
Common error codes
Best practices
- Validate input before you call SDK methods, to avoid
invalid_input. - Check your auth when you get
unauthorizedorforbidden. - Retry on transient issues like
internal_errororservice_unavailable. - Use
statusCodeandmessageto show debug info in development logs.
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.

