Initialization
import { coss } from '@coss';coss.scheduling.init({apiKey: process.env.COSS_KEY,environment: 'production', // or 'sandbox'});
Users
// Create a userawait coss.scheduling.users.create({email: 'jane@example.com',name: 'Jane Doe',});// Retrieve a userawait coss.scheduling.users.retrieve('user_abc123');
Schedules
// Create a scheduleawait coss.scheduling.schedules.create({userId: 'user_abc123',availability: [{day: 'Monday',start: '09:00',end: '17:00',},// ... other days],});// Retrieve schedulesawait coss.scheduling.schedules.list({ userId: 'user_abc123' });
Event Types
// Create an event typeawait coss.scheduling.eventTypes.create({userId: 'user_abc123',name: 'Consultation',duration: 30,scheduleId: 'schedule_abc123',});// Retrieve event typesawait coss.scheduling.eventTypes.list({ userId: 'user_abc123' });
Bookings
// Create a bookingawait coss.scheduling.bookings.create({eventTypeId: 'eventType_abc123',attendee: {name: 'John Smith',email: 'john@example.com',},start: '2025-05-01T15:00:00Z',});// Retrieve bookingsawait coss.scheduling.bookings.list({ userId: 'user_abc123' });
Webhooks
// Webhook eventscoss.scheduling.webhooks.on('booking.created', (event) => {console.log('New booking:', event.data);});coss.scheduling.webhooks.on('booking.cancelled', (event) => {console.log('Booking cancelled:', event.data);});
Utilities
// Validate webhook signatureconst isValid = coss.scheduling.utils.verifySignature({payload: req.body,signature: req.headers['coss-scheduling-signature'],secret: 'whsec_scheduling_123',});