SDKs

Typed clients for AGLedger in TypeScript and Python. Both SDKs wrap the REST API with ergonomic methods for the full mandate lifecycle.

TypeScript SDK

npm install @agledger/sdk
import { AgledgerClient } from '@agledger/sdk';

const client = new AgledgerClient({
  apiKey: process.env.AGLEDGER_API_KEY,
  // Optional:
  // baseUrl: 'https://agledger.your-company.com',
  // maxRetries: 3,
  // timeout: 30000,
});

// Create mandate
const mandate = await client.mandates.create({
  enterpriseId: 'your-enterprise-uuid',
  contractType: 'ACH-PROC-v1',
  contractVersion: '1',
  platform: 'your-app',
  agentId: 'your-agent-uuid',
  criteria: { item_spec: 'Widgets', quantity: { target: 100 } },
  tolerance: { quantity_pct: 10 },
});

// Activate
await client.mandates.transition(mandate.id, { action: 'register' });
await client.mandates.transition(mandate.id, { action: 'activate' });

// Submit receipt
await client.receipts.submit(mandate.id, {
  agentId: 'your-agent-uuid',
  evidence: { item_secured: 'Widgets', quantity: 100 },
});

// Check result
const result = await client.mandates.get(mandate.id);
console.log(result.status); // "FULFILLED"

Resources:


Python SDK

pip install agledger
from agledger import AgledgerClient

client = AgledgerClient(
    api_key="ach_ent_your_key_here",
    # base_url="https://agledger.your-company.com",  # optional
)

# Create mandate
mandate = client.mandates.create(
    enterprise_id="your-enterprise-uuid",
    contract_type="ACH-PROC-v1",
    contract_version="1",
    platform="your-app",
    agent_id="your-agent-uuid",
    criteria={"item_spec": "Widgets", "quantity": {"target": 100}},
    tolerance={"quantity_pct": 10},
)

# Activate
client.mandates.transition(mandate.id, action="register")
client.mandates.transition(mandate.id, action="activate")

# Submit receipt
client.receipts.submit(
    mandate_id=mandate.id,
    agent_id="your-agent-uuid",
    evidence={"item_secured": "Widgets", "quantity": 100},
)

# Check result
result = client.mandates.get(mandate.id)
print(result.status)  # "FULFILLED"

Resources:


Environment variables

Both SDKs read AGLEDGER_API_KEY from the environment if no api_key is passed explicitly. For self-hosted deployments, set AGLEDGER_API_URL (TypeScript) or pass base_url (Python).