We use cookies to improve your experience. Read more about how we handle your data in our GDPR policy.

    Back to Genju
    API Docsv1
    Docs

    JavaScript / Node.js SDK

    Installation

    bash
    npm install @genju/api

    Setup

    javascript
    import { GenjuClient } from '@genju/api';
    
    const genju = new GenjuClient({
      apiKey: process.env.GENJU_API_KEY
    });

    Examples

    Get account info

    javascript
    const account = await genju.me();
    console.log(account.business_name, account.credits_remaining);

    List contacts with filters

    javascript
    const { contacts, next_cursor } = await genju.contacts.list({
      tag: 'vip-client',
      limit: 20
    });

    Create a contact (deduplicates automatically)

    javascript
    const contact = await genju.contacts.create({
      full_name: 'Maria Borg',
      email: 'maria@example.com',
      phone: '+35699001234',
      source: 'website-form',
      tags: ['new-lead']
    });

    Create a booking

    javascript
    const booking = await genju.bookings.create({
      email: 'maria@example.com',
      service_id: 'svc_haircut_001',
      date: '2026-04-01',
      time: '10:00'
    });

    Send a WhatsApp message

    javascript
    await genju.messages.whatsapp({
      phone: '+35699001234',
      message_text: 'Your appointment is confirmed for tomorrow at 10am!'
    });

    Fire an automation

    javascript
    await genju.automations.trigger('new_lead_followup', {
      email: 'maria@example.com'
    });

    Register a webhook

    javascript
    const webhook = await genju.webhooks.create({
      url: 'https://my-server.com/genju-webhook',
      event: 'booking.confirmed'
    });
    console.log('Webhook secret:', webhook.secret); // Save this!

    Error handling

    javascript
    try {
      await genju.contacts.get('nonexistent-id');
    } catch (err) {
      if (err.code === 'CONTACT_NOT_FOUND') {
        console.log('Contact does not exist');
      }
    }