Skip to main content

SDK Overview

The Invoica SDK (@invoica/sdk) is a comprehensive TypeScript toolkit for integrating with the Invoica platform. It includes API client wrappers, React hooks, UI components, and utility functions.

What’s Included

100 Modules

Utility functions for formatting, validation, data manipulation, and more.

26 Hooks

React hooks for state management, DOM interaction, and API integration.

19 Components

Pre-built UI components following the Invoica design system.

SDK Architecture

@invoica/sdk
├── client/           # API client (InvoicaClient)
│   ├── invoices      # Invoice CRUD operations
│   ├── settlements   # Settlement monitoring
│   ├── tax           # Tax calculation
│   ├── budget        # Budget enforcement
│   └── webhooks      # Webhook management
├── utils/            # 100 utility modules
│   ├── format-*      # Number, currency, date formatting
│   ├── validate-*    # Input validation helpers
│   ├── crypto-*      # Hashing, signing utilities
│   └── ...
├── hooks/            # 26 React hooks
│   ├── use-invoice   # Invoice state management
│   ├── use-debounce  # Input debouncing
│   └── ...
└── components/       # 19 React components
    ├── Button        # Styled button variants
    ├── Badge         # Status badges
    ├── Spinner       # Loading indicators
    └── ...

Quick Example

import { InvoicaClient } from '@invoica/sdk';
import { formatCurrency } from '@invoica/sdk/utils';

const client = new InvoicaClient({
  apiKey: process.env.INVOICA_API_KEY,
});

// Create an invoice
const invoice = await client.invoices.create({
  amount: 5000,
  currency: 'USD',
  description: 'Agent compute usage',
  buyer: { companyName: 'Acme AI' },
  seller: { name: 'My Platform', wallet: '0x...' },
});

console.log(`Created: ${formatCurrency(invoice.total, 'USD')}`);
// Output: Created: $54.12

TypeScript First

The SDK is written entirely in TypeScript with full type definitions:
import type { Invoice, InvoiceCreateParams } from '@invoica/sdk';

const params: InvoiceCreateParams = {
  amount: 5000,
  currency: 'USD',
  // TypeScript will enforce all required fields
};

Tree-Shakeable

Import only what you need — unused modules are removed during build:
// Only imports the formatCurrency function
import { formatCurrency } from '@invoica/sdk/utils/format-currency';

// Only imports the useDebounce hook
import { useDebounce } from '@invoica/sdk/hooks/use-debounce';

Next Steps

Installation

Install the SDK and configure your development environment.