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

# SDK Usage

> Common patterns and examples for the Client Commander SDK

## Initialization

Initialize the client with your API key.

```typescript theme={null}
import { ClientCommander } from '@clientcommander/sdk';

const cc = new ClientCommander({
  apiKey: process.env.CCMD_API_KEY,
});
```

## Error Handling

The SDK throws errors that contain useful debugging information.

```typescript theme={null}
try {
  await cc.people.getPerson('invalid_id');
} catch (error) {
  if (error.status === 404) {
    console.error('Contact not found');
  } else if (error.status === 429) {
    console.error('Rate limit exceeded. Retry in', error.response.headers['retry-after']);
  } else {
    console.error('API Error:', error.message);
  }
}
```

## Pagination

List endpoints return a `meta` object with pagination details.

```typescript theme={null}
// Fetch first page
const page1 = await cc.people.listPeople({ limit: 10 });

// Fetch next page if available
if (page1.meta.hasMore) {
  const page2 = await cc.people.listPeople({ 
    limit: 10, 
    cursor: page1.meta.nextCursor 
  });
}
```

## TypeScript Support

The SDK exports all types for full type safety.

```typescript theme={null}
import type { Contact, Task } from '@clientcommander/sdk';

const myContact: Contact = {
  firstName: 'Jane',
  lastName: 'Smith'
  // TypeScript will autocomplete available fields
};
```
