Sardis

SDK Reference

Official Python and TypeScript SDKs for Sardis. Typed resources and validated models for wallets, payments, cards, policies, and more.

Python SDK

Installation

pip install sardis

Quick Start

from sardis import SardisClient

client = SardisClient(api_key="sk_...")

# Create wallet
wallet = client.wallets.create(
    name="research-agent",
    chain="base",
    token="USDC",
    policy="Max $100/day, Max $25 per tx"
)

# Make payment
result = wallet.pay(
    to="openai.com",
    amount="20.00",
    purpose="GPT-4 API credits"
)

Client Configuration

client = SardisClient(
    api_key="sk_...",
    base_url="https://api.sardis.sh",  # default
    timeout=30,                         # seconds
)

Resources

ResourceMethods
client.walletscreate(), get(), list(), update_policy(), archive()
client.paymentsexecute(), get(), list()
client.transactionsget(), list()
client.cardscreate(), get(), list(), freeze(), cancel()
client.mandatescreate(), get(), list(), revoke(), check()
client.treasuryfund(), withdraw(), get_balances()
client.compliancescreen(), get_status()

Async Support

All methods support async/await:

async with SardisClient(api_key="sk_...") as client:
    wallet = await client.wallets.create(
        name="async-agent",
        chain="base",
        token="USDC",
    )
    result = await client.payments.execute({...})

TypeScript SDK

Installation

npm install @sardis/sdk

Quick Start

import { SardisClient } from '@sardis/sdk';

const client = new SardisClient({ apiKey: 'sk_...' });

// Create wallet
const wallet = await client.wallets.create({
  name: 'research-agent',
  chain: 'base',
  token: 'USDC',
  policy: 'Max $100/day, Max $25 per tx',
});

// Make payment
const result = await client.payments.execute({
  walletId: wallet.id,
  destination: '0x...',
  amountMinor: 20_000_000,
  token: 'USDC',
  chain: 'base',
  purpose: 'API subscription',
});

Client Configuration

const client = new SardisClient({
  apiKey: 'sk_...',
  baseUrl: 'https://api.sardis.sh', // default
  timeout: 30_000,                   // milliseconds
});

Resources

ResourceMethods
client.walletscreate(), get(), list(), updatePolicy(), archive()
client.paymentsexecute(), executeMandate(), get(), list()
client.transactionsget(), list()
client.cardscreate(), get(), list(), freeze(), cancel()
client.mandatescreate(), get(), list(), revoke(), check()
client.treasuryfund(), withdraw(), getBalances()

Zod Validation

All responses are validated with Zod schemas at runtime:

import { WalletSchema, PaymentResultSchema } from '@sardis/sdk';

// TypeScript types are inferred from Zod schemas
type Wallet = z.infer<typeof WalletSchema>;
type PaymentResult = z.infer<typeof PaymentResultSchema>;

Error Handling

import { SardisError, PolicyViolationError } from '@sardis/sdk';

try {
  await client.payments.execute({...});
} catch (error) {
  if (error instanceof PolicyViolationError) {
    console.log('Policy violated:', error.reason);
    console.log('Limit:', error.limit);
    console.log('Attempted:', error.attempted);
  }
}