Skip to main content

What is the Mandate SDK?

The @mandate.md/sdk package is a TypeScript SDK for the Mandate policy layer. It provides two main classes: MandateClient for low-level API calls, and MandateWallet for a high-level flow that validates, signs, broadcasts, and confirms transactions in one call. The SDK throws typed errors for every failure mode, so your agent can react to policy blocks, approval requests, and circuit breaker trips.

Installation

Quick start

Create a MandateClient and validate a transaction against your policies.
The validate() method sends an action-based request to the Mandate API. If the transaction passes all 14 policy checks, you get back a PreflightResult with allowed: true and an intentId. If it fails, the SDK throws a typed error with the specific block reason.

Exports

The SDK exposes the following from its main entry point.

Sub-path import

If you only need MandateClient and want a smaller bundle, import from the /client sub-path. This skips the viem dependency that MandateWallet requires.
Use the sub-path import when your agent framework already handles signing and broadcasting. You get the same validate(), register(), and status() methods without pulling in viem.

How does the SDK handle errors?

Every failure mode has a dedicated error class. Your agent catches PolicyBlockedError for policy violations, ApprovalRequiredError when human review is needed, CircuitBreakerError when the agent is emergency-stopped, and RiskBlockedError when the risk scanner flags the transaction. All extend MandateError, so you can catch the base class as a fallback. See Error Handling for patterns and examples.

Next Steps

MandateClient

Low-level API methods: validate, register, poll status.

MandateWallet

High-level signing and broadcast flow with viem.

Error Handling

Typed error classes and recommended catch patterns.