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 sardisQuick 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
| Resource | Methods |
|---|---|
client.wallets | create(), get(), list(), update_policy(), archive() |
client.payments | execute(), get(), list() |
client.transactions | get(), list() |
client.cards | create(), get(), list(), freeze(), cancel() |
client.mandates | create(), get(), list(), revoke(), check() |
client.treasury | fund(), withdraw(), get_balances() |
client.compliance | screen(), 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/sdkQuick 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
| Resource | Methods |
|---|---|
client.wallets | create(), get(), list(), updatePolicy(), archive() |
client.payments | execute(), executeMandate(), get(), list() |
client.transactions | get(), list() |
client.cards | create(), get(), list(), freeze(), cancel() |
client.mandates | create(), get(), list(), revoke(), check() |
client.treasury | fund(), 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);
}
}