Developers
Node.js SDK
Official Node.js SDK for Custom Agents with full TypeScript support.
Installation
npm install @customagents/sdkQuick start
import { CustomAgents } from '@customagents/sdk';
const client = new CustomAgents({
apiKey: process.env.CUSTOM_AGENTS_API_KEY,
});
// List all agents
const agents = await client.agents.list();
console.log(agents);
// Get a specific agent
const agent = await client.agents.get('agent_abc123');
console.log(agent.name, agent.email);
// Send a message
const message = await client.messages.send({
agentId: 'agent_abc123',
to: 'customer@example.com',
subject: 'Following up',
body: 'Hi! Just wanted to follow up on your inquiry...',
});
// List contacts
const contacts = await client.contacts.list('agent_abc123');Configuration
const client = new CustomAgents({
apiKey: 'your-api-key',
baseUrl: 'https://api.customagents.io/v1', // default
timeout: 30000, // 30 seconds
});Error handling
try {
const agent = await client.agents.get('invalid_id');
} catch (error) {
if (error.status === 404) {
console.log('Agent not found');
} else if (error.status === 429) {
console.log('Rate limited, retry after:', error.retryAfter);
}
}TypeScript support
The SDK includes full TypeScript definitions for all methods and response types:
import type { Agent, Message, Contact } from '@customagents/sdk';
const agent: Agent = await client.agents.get('agent_abc123');
const messages: Message[] = await client.messages.list(agent.id);Start building with the SDK
npm install @customagents/sdk — full TypeScript support included.