import { ContoAdmin } from '@conto_finance/sdk';
const admin = new ContoAdmin({
orgApiKey: process.env.CONTO_ORG_API_KEY!,
});
const { members } = await admin.team.listMembers();
const owner = members.find((member) => member.user?.email === 'ops@example.com');
const wallet = await admin.wallets.create({
name: 'ops-wallet',
chainType: 'EVM',
custodyMode: 'MANAGED',
controlModel: 'CONTO_MANAGED',
});
await admin.wallets.provision(wallet.id);
const agent = await admin.agents.create({
name: 'ops-agent',
agentType: 'CUSTOM',
externalId: 'erp-agent-42',
ownerMembershipId: owner?.id,
allowedContexts: ['supplier-payments'],
callbackUrl: 'https://agent.example.com/webhooks/conto',
});
await admin.agents.linkWallet(agent.id, {
walletId: wallet.id,
delegationType: 'LIMITED',
spendLimitPerTx: 100,
spendLimitDaily: 500,
});
// scope 'assigned' with agentIds limits the policy to this agent.
// Without them, the policy applies to every agent in the organization.
const policy = await admin.policies.create({
name: 'Daily $500 limit',
policyType: 'SPEND_LIMIT',
scope: 'assigned',
agentIds: [agent.id],
rules: [{ ruleType: 'DAILY_LIMIT', operator: 'LTE', value: '500' }],
});
const { key } = await admin.agents.createSdkKey(agent.id, {
name: 'Production',
keyType: 'standard',
expiresInDays: 90,
});