Skip to main content

Initialization

Initialize the client with your API key.
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.
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.
// 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.
import type { Contact, Task } from '@clientcommander/sdk';

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