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

# TypeScript SDK Reference

> Complete reference for the Devdraft TypeScript SDK with all available methods and examples

## Overview

The Devdraft TypeScript SDK provides a complete client library for integrating payment processing, customer management, and webhook functionality into your TypeScript or JavaScript applications.

<CardGroup cols={2}>
  <Card title="Type-Safe" icon="shield-check">
    Full TypeScript support with comprehensive type definitions
  </Card>

  <Card title="Promise-Based" icon="code">
    Modern async/await API for clean, readable code
  </Card>

  <Card title="Comprehensive" icon="boxes-stacked">
    Access to all Devdraft API endpoints and features
  </Card>

  <Card title="Easy Integration" icon="plug">
    Simple configuration and intuitive method names
  </Card>
</CardGroup>

## Installation

```bash theme={null}
npm i @devdraft/sdk
# or
yarn add @devdraft/sdk
# or
pnpm add @devdraft/sdk
```

## Quick Start

```typescript theme={null}
import { Configuration, TransfersApi, WebhooksApi } from 'devdraft';

// Configure the SDK
const configuration = new Configuration({
  basePath: 'https://api.devdraft.ai',
  apiKey: (name: string) => {
    const keys: Record<string, string> = {
      'x-client-key': process.env.DEVDRAFT_CLIENT_KEY!,
      'x-client-secret': process.env.DEVDRAFT_CLIENT_SECRET!
    };
    return keys[name];
  }
});

// Initialize API clients
const transfersApi = new TransfersApi(configuration);
const webhooksApi = new WebhooksApi(configuration);

// Use the APIs
const transfer = await transfersApi.transferControllerCreateDirectWalletTransfer({
  createDirectWalletTransferDto: {
    walletId: 'your-wallet-id',
    network: 'solana',
    stableCoinCurrency: 'usdc',
    amount: 100.00
  }
});
```

## API Classes

The SDK is organized into API classes, each handling a specific domain:

| API Class                                         | Description                                     |
| ------------------------------------------------- | ----------------------------------------------- |
| [APIHealthApi](#api-health)                       | Service health checks and status monitoring     |
| [AppBalancesApi](#app-balances)                   | Query application balances across stablecoins   |
| [CustomersApi](#customers)                        | Customer management and KYC operations          |
| [ExchangeRatesApi](#exchange-rates)               | Real-time currency exchange rates               |
| [InvoicesApi](#invoices)                          | Invoice creation and management                 |
| [LiquidationAddressesApi](#liquidation-addresses) | Cryptocurrency liquidation addresses            |
| [PaymentIntentsApi](#payment-intents)             | Payment intent creation for bank and stablecoin |
| [PaymentLinksApi](#payment-links)                 | Generate and manage payment links               |
| [ProductsApi](#products)                          | Product catalog management                      |
| [TaxesApi](#taxes)                                | Tax configuration and management                |
| [TestPaymentsApi](#test-payments)                 | Test payment processing in sandbox              |
| [TransfersApi](#transfers)                        | Initiate and manage fund transfers              |
| [WalletsApi](#wallets)                            | Wallet management and balances                  |
| [WebhooksApi](#webhooks)                          | Webhook configuration and management            |

***

## API Health

Monitor service health and availability.

### Methods

#### `healthControllerCheckV0()`

Authenticated health check endpoint requiring API credentials.

```typescript theme={null}
import { APIHealthApi } from 'devdraft';

const healthApi = new APIHealthApi(configuration);

try {
  await healthApi.healthControllerCheckV0();
  console.log('Service is healthy and authenticated');
} catch (error) {
  console.error('Health check failed:', error);
}
```

**Returns:** `Promise<void>`

#### `healthControllerPublicHealthCheckV0()`

Public health check endpoint (no authentication required).

```typescript theme={null}
const status = await healthApi.healthControllerPublicHealthCheckV0();
console.log('Service status:', status);
```

**Returns:** `Promise<PublicHealthResponseDto>`

***

## App Balances

Query your application's stablecoin balances.

### Methods

#### `balanceControllerGetAllBalances()`

Get all stablecoin balances for your application.

```typescript theme={null}
import { AppBalancesApi } from 'devdraft';

const balancesApi = new AppBalancesApi(configuration);

const balances = await balancesApi.balanceControllerGetAllBalances();
console.log('USDC Balance:', balances.usdc);
console.log('EURC Balance:', balances.eurc);
```

**Returns:** `Promise<AllBalancesResponse>`

#### `balanceControllerGetUSDCBalance()`

Get USDC balance only.

```typescript theme={null}
const usdcBalance = await balancesApi.balanceControllerGetUSDCBalance();
console.log('USDC:', usdcBalance.amount);
```

**Returns:** `Promise<AggregatedBalanceResponse>`

#### `balanceControllerGetEURCBalance()`

Get EURC balance only.

```typescript theme={null}
const eurcBalance = await balancesApi.balanceControllerGetEURCBalance();
console.log('EURC:', eurcBalance.amount);
```

**Returns:** `Promise<AggregatedBalanceResponse>`

***

## Customers

Manage customer records and KYC information.

### Methods

#### `customerControllerCreate(params)`

Create a new customer.

```typescript theme={null}
import { CustomersApi, CreateCustomerDto } from 'devdraft';

const customersApi = new CustomersApi(configuration);

const newCustomer = await customersApi.customerControllerCreate({
  createCustomerDto: {
    firstName: 'John',
    lastName: 'Doe',
    email: 'john.doe@example.com',
    type: 'INDIVIDUAL',
    country: 'US'
  }
});

console.log('Customer created:', newCustomer.id);
```

**Parameters:**

* `createCustomerDto: CreateCustomerDto` - Customer details

**Returns:** `Promise<Customer>`

#### `customerControllerFindAll(params?)`

Get all customers with optional filters.

```typescript theme={null}
const customers = await customersApi.customerControllerFindAll({
  page: 1,
  limit: 20,
  status: 'ACTIVE'
});

customers.forEach(customer => {
  console.log(`${customer.firstName} ${customer.lastName} - ${customer.email}`);
});
```

**Parameters:**

* `page?: number` - Page number (default: 1)
* `limit?: number` - Items per page (default: 20)
* `status?: CustomerStatus` - Filter by status

**Returns:** `Promise<Customer[]>`

#### `customerControllerFindOne(params)`

Get a customer by ID.

```typescript theme={null}
const customer = await customersApi.customerControllerFindOne({
  id: 'customer-id-here'
});

console.log('Customer:', customer.firstName, customer.lastName);
```

**Parameters:**

* `id: string` - Customer ID

**Returns:** `Promise<Customer>`

#### `customerControllerUpdate(params)`

Update a customer's information.

```typescript theme={null}
const updated = await customersApi.customerControllerUpdate({
  id: 'customer-id-here',
  updateCustomerDto: {
    phone: '+1234567890',
    address: '123 Main St'
  }
});

console.log('Customer updated:', updated.id);
```

**Parameters:**

* `id: string` - Customer ID
* `updateCustomerDto: UpdateCustomerDto` - Fields to update

**Returns:** `Promise<Customer>`

***

## Exchange Rates

Get real-time currency exchange rates.

### Methods

#### `exchangeRateControllerGetExchangeRate(params)`

Get exchange rate between any two supported currencies.

```typescript theme={null}
import { ExchangeRatesApi } from 'devdraft';

const ratesApi = new ExchangeRatesApi(configuration);

const rate = await ratesApi.exchangeRateControllerGetExchangeRate({
  from: 'USD',
  to: 'EUR'
});

console.log(`1 USD = ${rate.rate} EUR`);
console.log(`Rate expires at: ${rate.expiresAt}`);
```

**Parameters:**

* `from: string` - Source currency code
* `to: string` - Target currency code

**Returns:** `Promise<ExchangeRateResponseDto>`

#### `exchangeRateControllerGetUSDToEURRate()`

Get USD to EUR exchange rate.

```typescript theme={null}
const usdToEur = await ratesApi.exchangeRateControllerGetUSDToEURRate();
console.log('USD to EUR:', usdToEur.rate);
```

**Returns:** `Promise<ExchangeRateResponseDto>`

#### `exchangeRateControllerGetEURToUSDRate()`

Get EUR to USD exchange rate.

```typescript theme={null}
const eurToUsd = await ratesApi.exchangeRateControllerGetEURToUSDRate();
console.log('EUR to USD:', eurToUsd.rate);
```

**Returns:** `Promise<ExchangeRateResponseDto>`

***

## Invoices

Create and manage invoices for your customers.

### Methods

#### `invoiceControllerCreate(params)`

Create a new invoice.

```typescript theme={null}
import { InvoicesApi, CreateInvoiceDto } from 'devdraft';

const invoicesApi = new InvoicesApi(configuration);

const invoice = await invoicesApi.invoiceControllerCreate({
  createInvoiceDto: {
    customerId: 'customer-id',
    items: [
      {
        description: 'Premium Subscription',
        quantity: 1,
        price: 99.99,
        currency: 'USD'
      }
    ],
    dueDate: '2024-12-31'
  }
});

console.log('Invoice created:', invoice.id);
console.log('Total:', invoice.total);
```

**Parameters:**

* `createInvoiceDto: CreateInvoiceDto` - Invoice details

**Returns:** `Promise<Invoice>`

#### `invoiceControllerFindAll(params?)`

Get all invoices.

```typescript theme={null}
const invoices = await invoicesApi.invoiceControllerFindAll({
  page: 1,
  limit: 50,
  status: 'UNPAID'
});
```

**Parameters:**

* `page?: number` - Page number
* `limit?: number` - Items per page
* `status?: string` - Filter by status

**Returns:** `Promise<Invoice[]>`

#### `invoiceControllerFindOne(params)`

Get an invoice by ID.

```typescript theme={null}
const invoice = await invoicesApi.invoiceControllerFindOne({
  id: 'invoice-id'
});
```

**Parameters:**

* `id: string` - Invoice ID

**Returns:** `Promise<Invoice>`

#### `invoiceControllerUpdate(params)`

Update an invoice.

```typescript theme={null}
const updated = await invoicesApi.invoiceControllerUpdate({
  id: 'invoice-id',
  updateInvoiceDto: {
    status: 'PAID',
    paidAt: new Date().toISOString()
  }
});
```

**Parameters:**

* `id: string` - Invoice ID
* `updateInvoiceDto: UpdateInvoiceDto` - Fields to update

**Returns:** `Promise<Invoice>`

***

## Liquidation Addresses

Manage cryptocurrency liquidation addresses for customers.

### Methods

#### `liquidationAddressControllerCreateLiquidationAddress(params)`

Create a new liquidation address for a customer.

```typescript theme={null}
import { LiquidationAddressesApi } from 'devdraft';

const liquidationApi = new LiquidationAddressesApi(configuration);

const address = await liquidationApi.liquidationAddressControllerCreateLiquidationAddress({
  customerId: 'customer-id',
  createLiquidationAddressDto: {
    network: 'solana',
    currency: 'usdc'
  }
});

console.log('Liquidation address:', address.address);
console.log('Network:', address.network);
```

**Parameters:**

* `customerId: string` - Customer ID
* `createLiquidationAddressDto: CreateLiquidationAddressDto` - Address details

**Returns:** `Promise<LiquidationAddressResponseDto>`

#### `liquidationAddressControllerGetLiquidationAddresses(params)`

Get all liquidation addresses for a customer.

```typescript theme={null}
const addresses = await liquidationApi.liquidationAddressControllerGetLiquidationAddresses({
  customerId: 'customer-id'
});

addresses.forEach(addr => {
  console.log(`${addr.network}: ${addr.address}`);
});
```

**Parameters:**

* `customerId: string` - Customer ID

**Returns:** `Promise<LiquidationAddressResponseDto[]>`

#### `liquidationAddressControllerGetLiquidationAddress(params)`

Get a specific liquidation address.

```typescript theme={null}
const address = await liquidationApi.liquidationAddressControllerGetLiquidationAddress({
  customerId: 'customer-id',
  liquidationAddressId: 'address-id'
});
```

**Parameters:**

* `customerId: string` - Customer ID
* `liquidationAddressId: string` - Address ID

**Returns:** `Promise<LiquidationAddressResponseDto>`

***

## Payment Intents

Create payment intents for bank and stablecoin payments.

### Methods

#### `paymentIntentControllerCreateBankPaymentIntent(params)`

Create a bank payment intent.

```typescript theme={null}
import { PaymentIntentsApi } from 'devdraft';

const intentApi = new PaymentIntentsApi(configuration);

const intent = await intentApi.paymentIntentControllerCreateBankPaymentIntent({
  createBankPaymentIntentDto: {
    customerId: 'customer-id',
    amount: 1000.00,
    currency: 'USD',
    paymentRail: 'wire'
  }
});

console.log('Payment intent:', intent.id);
console.log('Status:', intent.status);
```

**Parameters:**

* `createBankPaymentIntentDto: CreateBankPaymentIntentDto` - Intent details

**Returns:** `Promise<PaymentIntent>`

#### `paymentIntentControllerCreateStablePaymentIntent(params)`

Create a stablecoin payment intent.

```typescript theme={null}
const stableIntent = await intentApi.paymentIntentControllerCreateStablePaymentIntent({
  createStablePaymentIntentDto: {
    customerId: 'customer-id',
    amount: 500.00,
    currency: 'usdc',
    network: 'solana'
  }
});
```

**Parameters:**

* `createStablePaymentIntentDto: CreateStablePaymentIntentDto` - Intent details

**Returns:** `Promise<PaymentIntent>`

***

## Payment Links

Generate and manage payment links for easy customer payments.

### Methods

#### `paymentLinksControllerCreate(params)`

Create a new payment link.

```typescript theme={null}
import { PaymentLinksApi } from 'devdraft';

const linksApi = new PaymentLinksApi(configuration);

const link = await linksApi.paymentLinksControllerCreate({
  createPaymentLinkDto: {
    name: 'Product Purchase',
    amount: 99.99,
    currency: 'USD',
    products: [
      {
        name: 'Premium Plan',
        quantity: 1,
        price: 99.99
      }
    ]
  }
});

console.log('Payment link:', link.url);
console.log('Share this link with customers:', link.shortUrl);
```

**Parameters:**

* `createPaymentLinkDto: CreatePaymentLinkDto` - Link details

**Returns:** `Promise<PaymentLink>`

#### `paymentLinksControllerFindAll(params?)`

Get all payment links.

```typescript theme={null}
const links = await linksApi.paymentLinksControllerFindAll({
  page: 1,
  limit: 20,
  active: true
});
```

**Parameters:**

* `page?: number` - Page number
* `limit?: number` - Items per page
* `active?: boolean` - Filter by active status

**Returns:** `Promise<PaymentLink[]>`

#### `paymentLinksControllerFindOne(params)`

Get a payment link by ID.

```typescript theme={null}
const link = await linksApi.paymentLinksControllerFindOne({
  id: 'link-id'
});
```

**Parameters:**

* `id: string` - Payment link ID

**Returns:** `Promise<PaymentLink>`

#### `paymentLinksControllerUpdate(params)`

Update a payment link.

```typescript theme={null}
const updated = await linksApi.paymentLinksControllerUpdate({
  id: 'link-id',
  updatePaymentLinkDto: {
    active: false,
    expiresAt: '2024-12-31T23:59:59Z'
  }
});
```

**Parameters:**

* `id: string` - Payment link ID
* `updatePaymentLinkDto: UpdatePaymentLinkDto` - Fields to update

**Returns:** `Promise<PaymentLink>`

***

## Products

Manage your product catalog.

### Methods

#### `productControllerCreate(params)`

Create a new product.

```typescript theme={null}
import { ProductsApi } from 'devdraft';

const productsApi = new ProductsApi(configuration);

const product = await productsApi.productControllerCreate({
  createProductDto: {
    name: 'Premium Subscription',
    description: 'Access to all premium features',
    price: 99.99,
    currency: 'USD',
    category: 'subscriptions'
  }
});

console.log('Product created:', product.id);
```

**Parameters:**

* `createProductDto: CreateProductDto` - Product details

**Returns:** `Promise<Product>`

#### `productControllerFindAll(params?)`

Get all products.

```typescript theme={null}
const products = await productsApi.productControllerFindAll({
  category: 'subscriptions',
  active: true
});
```

**Parameters:**

* `category?: string` - Filter by category
* `active?: boolean` - Filter by active status

**Returns:** `Promise<Product[]>`

#### `productControllerFindOne(params)`

Get a product by ID.

```typescript theme={null}
const product = await productsApi.productControllerFindOne({
  id: 'product-id'
});
```

**Parameters:**

* `id: string` - Product ID

**Returns:** `Promise<Product>`

#### `productControllerUpdate(params)`

Update a product.

```typescript theme={null}
const updated = await productsApi.productControllerUpdate({
  id: 'product-id',
  updateProductDto: {
    price: 89.99,
    description: 'Updated description'
  }
});
```

**Parameters:**

* `id: string` - Product ID
* `updateProductDto: UpdateProductDto` - Fields to update

**Returns:** `Promise<Product>`

#### `productControllerRemove(params)`

Delete a product.

```typescript theme={null}
await productsApi.productControllerRemove({
  id: 'product-id'
});
```

**Parameters:**

* `id: string` - Product ID

**Returns:** `Promise<void>`

#### `productControllerUploadImage(params)`

Upload images for a product.

```typescript theme={null}
await productsApi.productControllerUploadImage({
  id: 'product-id',
  images: [file1, file2] // File objects
});
```

**Parameters:**

* `id: string` - Product ID
* `images: File[]` - Image files

**Returns:** `Promise<Product>`

***

## Taxes

Configure and manage tax settings.

### Methods

#### `taxControllerCreate(params)`

Create a new tax configuration.

```typescript theme={null}
import { TaxesApi } from 'devdraft';

const taxesApi = new TaxesApi(configuration);

const tax = await taxesApi.taxControllerCreate({
  createTaxDto: {
    name: 'Sales Tax',
    percentage: 8.5,
    country: 'US',
    state: 'CA'
  }
});

console.log('Tax created:', tax.id);
```

**Parameters:**

* `createTaxDto: CreateTaxDto` - Tax details

**Returns:** `Promise<Tax>`

#### `taxControllerFindAll(params?)`

Get all tax configurations.

```typescript theme={null}
const taxes = await taxesApi.taxControllerFindAll({
  country: 'US'
});
```

**Parameters:**

* `country?: string` - Filter by country

**Returns:** `Promise<Tax[]>`

#### `taxControllerFindOne(params)`

Get a tax configuration by ID.

```typescript theme={null}
const tax = await taxesApi.taxControllerFindOne({
  id: 'tax-id'
});
```

**Parameters:**

* `id: string` - Tax ID

**Returns:** `Promise<Tax>`

#### `taxControllerUpdate(params)`

Update a tax configuration.

```typescript theme={null}
const updated = await taxesApi.taxControllerUpdate({
  id: 'tax-id',
  updateTaxDto: {
    percentage: 9.0
  }
});
```

**Parameters:**

* `id: string` - Tax ID
* `updateTaxDto: UpdateTaxDto` - Fields to update

**Returns:** `Promise<Tax>`

#### `taxControllerRemove(params)`

Delete a tax configuration.

```typescript theme={null}
await taxesApi.taxControllerRemove({
  id: 'tax-id'
});
```

**Parameters:**

* `id: string` - Tax ID

**Returns:** `Promise<void>`

***

## Test Payments

Process test payments in sandbox environment.

### Methods

#### `testPaymentControllerCreatePaymentV0(params)`

Create a test payment.

```typescript theme={null}
import { TestPaymentsApi } from 'devdraft';

const testApi = new TestPaymentsApi(configuration);

const payment = await testApi.testPaymentControllerCreatePaymentV0({
  paymentRequestDto: {
    amount: 100.00,
    currency: 'USD',
    customerId: 'test-customer-id',
    idempotencyKey: 'unique-key-123'
  }
});

console.log('Test payment:', payment.id);
console.log('Status:', payment.status);
```

**Parameters:**

* `paymentRequestDto: PaymentRequestDto` - Payment details

**Returns:** `Promise<PaymentResponseDto>`

#### `testPaymentControllerGetPaymentV0(params)`

Get test payment details by ID.

```typescript theme={null}
const payment = await testApi.testPaymentControllerGetPaymentV0({
  id: 'payment-id'
});

console.log('Payment status:', payment.status);
```

**Parameters:**

* `id: string` - Payment ID

**Returns:** `Promise<PaymentResponseDto>`

#### `testPaymentControllerRefundPaymentV0(params)`

Refund a test payment.

```typescript theme={null}
const refund = await testApi.testPaymentControllerRefundPaymentV0({
  id: 'payment-id',
  refundAmount: 50.00
});

console.log('Refund processed:', refund.id);
```

**Parameters:**

* `id: string` - Payment ID
* `refundAmount?: number` - Amount to refund (optional, defaults to full amount)

**Returns:** `Promise<RefundResponseDto>`

***

## Transfers

Initiate and manage fund transfers between different payment rails.

### Methods

#### `transferControllerCreateDirectBankTransfer(params)`

Create a direct bank transfer.

```typescript theme={null}
import { TransfersApi } from 'devdraft';

const transfersApi = new TransfersApi(configuration);

const transfer = await transfersApi.transferControllerCreateDirectBankTransfer({
  createDirectBankTransferDto: {
    walletId: 'wallet-id',
    paymentRail: 'wire',
    sourceCurrency: 'usd',
    destinationCurrency: 'usdc',
    amount: 1000.00
  }
});

console.log('Transfer created:', transfer.id);
console.log('Bank instructions:', transfer.source_deposit_instructions);
```

**Parameters:**

* `createDirectBankTransferDto: CreateDirectBankTransferDto` - Transfer details

**Returns:** `Promise<Transfer>`

**See also:** [Direct Bank Transfer Guide](/docs/developers/transfers/direct-bank-transfer)

#### `transferControllerCreateDirectWalletTransfer(params)`

Create a direct wallet transfer.

```typescript theme={null}
const transfer = await transfersApi.transferControllerCreateDirectWalletTransfer({
  createDirectWalletTransferDto: {
    walletId: 'wallet-id',
    network: 'solana',
    stableCoinCurrency: 'usdc',
    amount: 500.00
  }
});

console.log('Transfer created:', transfer.id);
console.log('Deposit address:', transfer.source_deposit_instructions.to_address);
```

**Parameters:**

* `createDirectWalletTransferDto: CreateDirectWalletTransferDto` - Transfer details

**Returns:** `Promise<Transfer>`

**See also:** [Direct Wallet Transfer Guide](/docs/developers/transfers/direct-wallet-transfer)

#### `transferControllerCreateExternalBankTransfer(params)`

Create an external bank transfer (from your wallet to external bank).

```typescript theme={null}
const transfer = await transfersApi.transferControllerCreateExternalBankTransfer({
  createExternalBankTransferDto: {
    sourceWalletId: 'wallet-id',
    destinationBankAccountId: 'bank-account-id',
    amount: 1000.00,
    currency: 'USD'
  }
});
```

**Parameters:**

* `createExternalBankTransferDto: CreateExternalBankTransferDto` - Transfer details

**Returns:** `Promise<Transfer>`

#### `transferControllerCreateExternalStablecoinTransfer(params)`

Create an external stablecoin transfer (from your wallet to external wallet).

```typescript theme={null}
const transfer = await transfersApi.transferControllerCreateExternalStablecoinTransfer({
  createExternalStablecoinTransferDto: {
    sourceWalletId: 'wallet-id',
    destinationAddress: '0x742d35Cc6Ff82a8C2D8D1Da9da17c7eDfD5bE0a3',
    network: 'ethereum',
    currency: 'usdc',
    amount: 250.00
  }
});
```

**Parameters:**

* `createExternalStablecoinTransferDto: CreateExternalStablecoinTransferDto` - Transfer details

**Returns:** `Promise<Transfer>`

#### `transferControllerCreateStablecoinConversion(params)`

Convert between different stablecoins or networks.

```typescript theme={null}
const conversion = await transfersApi.transferControllerCreateStablecoinConversion({
  createStablecoinConversionDto: {
    sourceWalletId: 'wallet-id',
    destinationWalletId: 'wallet-id',
    sourceNetwork: 'ethereum',
    destinationNetwork: 'solana',
    sourceCurrency: 'usdc',
    destinationCurrency: 'usdc',
    amount: 1000.00
  }
});

console.log('Conversion ID:', conversion.id);
console.log('Exchange rate:', conversion.exchange_rate.rate);
console.log('Estimated completion:', conversion.estimated_completion);
```

**Parameters:**

* `createStablecoinConversionDto: CreateStablecoinConversionDto` - Conversion details

**Returns:** `Promise<Conversion>`

**See also:** [Stablecoin Conversion Guide](/docs/developers/transfers/stablecoin-conversion)

***

## Wallets

Manage wallets and query balances.

### Methods

#### `walletControllerGetWallets()`

Get all wallets for your application.

```typescript theme={null}
import { WalletsApi } from 'devdraft';

const walletsApi = new WalletsApi(configuration);

await walletsApi.walletControllerGetWallets();
// Returns wallet information for your application
```

**Returns:** `Promise<void>`

<Info>
  The response contains wallet IDs that you can use for transfers and other operations. In a future SDK version, this will return typed wallet objects.
</Info>

***

## Webhooks

Configure webhooks to receive real-time event notifications.

### Methods

#### `webhookControllerCreate(params)`

Create a new webhook.

```typescript theme={null}
import { WebhooksApi } from 'devdraft';

const webhooksApi = new WebhooksApi(configuration);

const webhook = await webhooksApi.webhookControllerCreate({
  createWebhookDto: {
    url: 'https://your-app.com/webhooks/devdraft',
    name: 'Production Webhook',
    isActive: true,
    encrypted: false
  }
});

console.log('Webhook ID:', webhook.id);
console.log('Signing secret:', webhook.signingSecret);
```

**Parameters:**

* `createWebhookDto: CreateWebhookDto` - Webhook configuration

**Returns:** `Promise<WebhookResponseDto>`

**See also:** [Webhooks Overview](/docs/developers/webhooks/overview)

#### `webhookControllerFindAll(params?)`

Get all webhooks.

```typescript theme={null}
const webhooks = await webhooksApi.webhookControllerFindAll({
  page: 1,
  limit: 20,
  active: true
});

webhooks.forEach(webhook => {
  console.log(`${webhook.name}: ${webhook.url}`);
  console.log(`Active: ${webhook.isActive}`);
});
```

**Parameters:**

* `page?: number` - Page number
* `limit?: number` - Items per page
* `active?: boolean` - Filter by active status

**Returns:** `Promise<WebhookResponseDto[]>`

#### `webhookControllerFindOne(params)`

Get a webhook by ID.

```typescript theme={null}
const webhook = await webhooksApi.webhookControllerFindOne({
  id: 'webhook-id'
});

console.log('Webhook:', webhook.name);
console.log('URL:', webhook.url);
console.log('Delivery stats:', webhook.delivery_stats);
```

**Parameters:**

* `id: string` - Webhook ID

**Returns:** `Promise<WebhookResponseDto>`

#### `webhookControllerUpdate(params)`

Update a webhook.

```typescript theme={null}
const updated = await webhooksApi.webhookControllerUpdate({
  id: 'webhook-id',
  updateWebhookDto: {
    url: 'https://your-app.com/webhooks/new-endpoint',
    isActive: true
  }
});
```

**Parameters:**

* `id: string` - Webhook ID
* `updateWebhookDto: UpdateWebhookDto` - Fields to update

**Returns:** `Promise<WebhookResponseDto>`

#### `webhookControllerRemove(params)`

Delete a webhook.

```typescript theme={null}
await webhooksApi.webhookControllerRemove({
  id: 'webhook-id'
});

console.log('Webhook deleted');
```

**Parameters:**

* `id: string` - Webhook ID

**Returns:** `Promise<void>`

***

## Error Handling

All SDK methods may throw errors. Handle them appropriately:

```typescript theme={null}
import { ResponseError } from 'devdraft';

try {
  await transfersApi.transferControllerCreateDirectWalletTransfer({
    createDirectWalletTransferDto: transferData
  });
} catch (error) {
  if (error instanceof ResponseError) {
    const status = error.response.status;
    const body = await error.response.json();
    
    switch (status) {
      case 400:
        console.error('Invalid request:', body.message);
        break;
      case 401:
        console.error('Authentication failed');
        break;
      case 404:
        console.error('Resource not found:', body.message);
        break;
      case 422:
        console.error('Validation error:', body.message);
        break;
      case 429:
        console.error('Rate limited');
        break;
      default:
        console.error('API error:', status, body);
    }
  } else {
    console.error('Unexpected error:', error);
  }
}
```

## Type Definitions

The SDK includes comprehensive TypeScript types for all requests and responses. Import them as needed:

```typescript theme={null}
import type {
  CreateDirectWalletTransferDto,
  CreateDirectBankTransferDto,
  CreateWebhookDto,
  WebhookResponseDto,
  PaymentResponseDto,
  Customer,
  Invoice,
  // ... and many more
} from 'devdraft';
```

## Best Practices

<Steps>
  <Step title="Use Environment Variables">
    Store API credentials in environment variables, never in source code.

    ```typescript theme={null}
    const configuration = new Configuration({
      basePath: process.env.DEVDRAFT_API_URL || 'https://api.devdraft.ai',
      apiKey: (name: string) => {
        const keys: Record<string, string> = {
          'x-client-key': process.env.DEVDRAFT_CLIENT_KEY!,
          'x-client-secret': process.env.DEVDRAFT_CLIENT_SECRET!
        };
        return keys[name];
      }
    });
    ```
  </Step>

  <Step title="Implement Proper Error Handling">
    Always wrap API calls in try-catch blocks and handle errors appropriately.
  </Step>

  <Step title="Use TypeScript">
    Leverage TypeScript's type system to catch errors at compile time.

    ```typescript theme={null}
    // TypeScript will catch type errors
    const transfer: CreateDirectWalletTransferDto = {
      walletId: 'wallet-id',
      network: 'solana', // TypeScript ensures this is a valid network
      stableCoinCurrency: 'usdc',
      amount: 100.00
    };
    ```
  </Step>

  <Step title="Reuse Configuration">
    Create a single Configuration instance and reuse it across multiple API clients.

    ```typescript theme={null}
    const config = new Configuration({ /* ... */ });

    const transfersApi = new TransfersApi(config);
    const webhooksApi = new WebhooksApi(config);
    const customersApi = new CustomersApi(config);
    ```
  </Step>

  <Step title="Handle Async Operations">
    Use async/await for clean, readable code.

    ```typescript theme={null}
    async function processPayment() {
      try {
        const payment = await testApi.testPaymentControllerCreatePaymentV0({
          paymentRequestDto: paymentData
        });
        
        const status = await testApi.testPaymentControllerGetPaymentV0({
          id: payment.id
        });
        
        return status;
      } catch (error) {
        handleError(error);
      }
    }
    ```
  </Step>
</Steps>

## Next Steps

<CardGroup cols={2}>
  <Card title="SDK Quickstart" icon="rocket" href="/docs/developers/sdk-quickstart">
    Complete integration guide with examples
  </Card>

  <Card title="Transfers" icon="arrow-right-arrow-left" href="/docs/developers/transfers/direct-wallet-transfer">
    Learn about initiating transfers
  </Card>

  <Card title="Webhooks" icon="bell" href="/docs/developers/webhooks/overview">
    Set up webhook notifications
  </Card>

  <Card title="API Reference" icon="book" href="/docs/developers/api-reference">
    Complete REST API documentation
  </Card>
</CardGroup>
