cpilot
v1.0.2
Published
Official TypeScript SDK for the cPilot Messaging API
Readme
cPilot SDK
The official SDK for interacting with the cPilot API. Integrate your internal systems or let your clients connect securely to your cPilot platform to dispatch emails, trigger WhatsApp notifications, and securely retrieve data using API Keys!
Prerequisites
Before using the SDK, you must generate an API Key from the cPilot platform:
- Log into your account at cpilot.space.
- Create or navigate to your Project.
- Inside your project dashboard, navigate to the API Keys tab and click Create API Key.
- Copy your API Key securely. You will use this key to initialize the SDK.
Installation
npm install cpilot(Or the equivalent install command for yarn/pnpm)
Quick Start
Initialize the SDK by providing your apiKey. By default, the SDK automatically points to the production cPilot API servers (https://api.cpilot.space/api/v1). You only need to pass the baseUrl option if you are testing locally.
import { CPilotClient } from 'cpilot';
// Initialize the client
const cpilot = new CPilotClient({
apiKey: "your_project_api_key_here"
});
async function run() {
// 1. Send an Email
const emailResponse = await cpilot.messages.sendEmail({
to: "[email protected]",
subject: "Welcome to our Platform!",
html: "<b>Welcome aboard!</b> We're thrilled to have you."
});
console.log('Email sent:', emailResponse);
// 2. Send a WhatsApp Notification
const whatsappResponse = await cpilot.messages.sendWhatsApp({
to: "+1234567890",
type: "text",
text: "Your order is ready for pickup!"
});
console.log('WhatsApp message sent:', whatsappResponse);
}
run();Features
- Lightweight wrapper: Automatically resolves standard Javascript Promises using native
fetch— meaning zero bloat in yournode_modules(no Axios, no massive dependencies). - TypeScript First: Comprehensive typings for requests and responses so your IDE gives you perfect autocomplete.
- Error Handling: Automatically parses standard cPilot HTTP errors for missing rate limits, authentication issues, or missing permissions.
License
MIT
