> ## Documentation Index
> Fetch the complete documentation index at: https://conto.finance/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Examples

> Small SDK examples for the main Conto payment flows.

# SDK Examples

Use these examples as starting points. For setup, start with [Installation](/sdk/installation). For
copy-paste operational snippets, use [Recipes](/guides/recipes).

## One-call payment

Use `payments.pay()` when the agent has an executable wallet and you want Conto to request policy
authorization and execute in one call.

```typescript theme={null}
import { Conto } from '@conto_finance/sdk';

const conto = new Conto({ apiKey: process.env.CONTO_API_KEY! });

const result = await conto.payments.pay({
  amount: 50,
  recipientAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18',
  recipientName: 'OpenAI',
  purpose: 'API credits',
  category: 'AI_SERVICES',
});

console.log(result.receipt?.txHash);
console.log(result.receipt?.explorerUrl);
```

## Approval-aware payment

Use `request -> execute` when your app needs to handle denied or review-required outcomes before
execution.

```typescript theme={null}
import { Conto } from '@conto_finance/sdk';

const conto = new Conto({ apiKey: process.env.CONTO_API_KEY! });

const request = await conto.payments.request({
  amount: 100,
  recipientAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18',
  purpose: 'Infrastructure spend',
});

if (request.status === 'DENIED') {
  console.log(request.reasons);
}

if (request.status === 'REQUIRES_APPROVAL') {
  console.log('Awaiting approval:', request.requestId);
}

if (request.status === 'APPROVED') {
  const result = await conto.payments.execute(request.requestId);
  console.log(result.receipt?.txHash);
}
```

## Agent tool helper

Most framework integrations wrap the same helper in an OpenAI, Anthropic, LangChain, or custom tool
definition.

```typescript theme={null}
import { Conto } from '@conto_finance/sdk';

const conto = new Conto({ apiKey: process.env.CONTO_API_KEY! });

export async function makePayment(input: {
  amount: number;
  recipientAddress: string;
  recipientName?: string;
  purpose: string;
}) {
  const request = await conto.payments.request({
    category: 'OPERATIONS',
    ...input,
  });

  if (request.status !== 'APPROVED') {
    return {
      ok: false,
      status: request.status,
      reasons: request.reasons,
      requestId: request.requestId,
    };
  }

  const result = await conto.payments.execute(request.requestId);
  return {
    ok: true,
    txHash: result.receipt?.txHash,
    explorerUrl: result.receipt?.explorerUrl,
  };
}
```

## Setup check

Call `GET /api/sdk/setup` on agent startup when you need a customer-facing summary of the agent,
available wallets, spending controls, and granted scopes.

```typescript theme={null}
const setup = await fetch('https://conto.finance/api/sdk/setup', {
  headers: {
    Authorization: `Bearer ${process.env.CONTO_API_KEY}`,
  },
}).then((response) => response.json());

console.log(setup.agent.name);
console.log(setup.scopes);
console.log(setup.wallets);
```

## More examples

<CardGroup cols={2}>
  <Card title="Connecting agents" icon="plug" href="/quickstart/connecting-agents">
    OpenAI, Anthropic, LangChain, and Python wiring
  </Card>

  <Card title="Recipes" icon="terminal" href="/guides/recipes">
    Curl snippets for setup, payments, policies, x402, MPP, approvals, and monitoring
  </Card>

  <Card title="Payments API" icon="credit-card" href="/sdk/payments">
    Full payment method behavior and response shape
  </Card>

  <Card title="Webhooks" icon="webhook" href="/guides/webhooks">
    Receive approval and payment events
  </Card>
</CardGroup>
