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

# JavaScript SDK

> Official TXCloud SDK for JavaScript and TypeScript

## Installation

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

## Quick Start

```javascript theme={null}
import TXCloud from '@txcloud/sdk';

const txcloud = new TXCloud({
  apiKey: process.env.TXCLOUD_API_KEY,
  environment: 'production' // or 'sandbox'
});

// Verify identity
const verification = await txcloud.identity.verify({
  document_front: documentBase64,
  country: 'MA',
  document_type: 'national_id'
});

console.log(verification.status);
```

## Configuration

```javascript theme={null}
const txcloud = new TXCloud({
  apiKey: 'txc_live_xxx',
  environment: 'production',
  timeout: 30000, // 30 seconds
  maxRetries: 3
});
```

## TypeScript Support

Full TypeScript definitions included:

```typescript theme={null}
import TXCloud, { Verification, VerifyRequest } from '@txcloud/sdk';

const request: VerifyRequest = {
  document_front: '...',
  country: 'MA'
};

const verification: Verification = await txcloud.identity.verify(request);
```

## Error Handling

```javascript theme={null}
import { TXCloudError, ValidationError, RateLimitError } from '@txcloud/sdk';

try {
  const result = await txcloud.identity.verify({ ... });
} catch (error) {
  if (error instanceof ValidationError) {
    console.log('Validation failed:', error.message);
  } else if (error instanceof RateLimitError) {
    console.log('Rate limited, retry after:', error.retryAfter);
  } else if (error instanceof TXCloudError) {
    console.log('API error:', error.code);
  }
}
```

## Webhook Verification

```javascript theme={null}
import { verifyWebhookSignature } from '@txcloud/sdk';

app.post('/webhooks', (req, res) => {
  const isValid = verifyWebhookSignature(
    req.body,
    req.headers['x-txcloud-signature'],
    webhookSecret
  );
  
  if (!isValid) {
    return res.status(401).send('Invalid signature');
  }
  
  // Process webhook
});
```

## API Reference

All API methods are available:

```javascript theme={null}
// Identity
txcloud.identity.verify()
txcloud.identity.verifications.get()
txcloud.identity.verifications.list()

// Fraud
txcloud.fraud.devices.register()
txcloud.fraud.duplicates.search()
txcloud.fraud.rules.create()

// Transactions
txcloud.transactions.score()
txcloud.transactions.report()

// Lending
txcloud.lending.assess()
txcloud.lending.statements.upload()

// KYB
txcloud.kyb.verify()
txcloud.kyb.companies.getUBOs()

// Watchlist
txcloud.watchlist.screen()
txcloud.watchlist.screenBatch()

// Developers
txcloud.developers.webhooks.create()
txcloud.developers.usage.summary()
```
