Examples

Practical examples showing common operations with the Felloh Node.js SDK. Each example assumes you have already created a client instance.

Client Setup

import { FellohClient } from '@felloh-org/node-sdk';

const client = new FellohClient({
  publicKey: process.env.FELLOH_PUBLIC_KEY,
  privateKey: process.env.FELLOH_PRIVATE_KEY,
});

Bookings

Create a booking, then list and retrieve bookings. Amounts should be in the lowest currency denomination (e.g. pence for GBP).

Create a Booking

const created = await client.bookings.create({
  organisation: 'org-id',
  booking_reference: 'REF-001',
  customer_name: 'James Dean',
  email: 'james@example.com',
  currency: 'GBX',
  gross_amount: 100000,
  departure_date: '2025-08-01',
  return_date: '2025-08-15',
});

console.log('Booking ID:', created.data.id);

List & Search Bookings

const bookings = await client.bookings.list({
  organisation: 'org-id',
  keyword: 'james@example.com',
  take: 20,
});

console.log(`Found ${bookings.meta.count} bookings`);

Update a Booking

await client.bookings.update('booking-id', {
  customer_name: 'Jane Dean',
  departure_date: '2025-09-01',
});

Delete a Booking

await client.bookings.delete('booking-id');

Booking Components

Add and remove components (e.g. flights, hotels) on a booking.

Add a Component

const component = await client.bookingComponents.create('booking-id', {
  supplier: 'supplier-id',
  amount: 50000,
  currency: 'GBX',
  booking_reference: 'REF-001',
  destination_air: 'AMS',
  type: 'flights',
});

Remove a Component

await client.bookingComponents.delete('booking-id', 'component-id');

Transactions

List transactions, issue refunds, and manage pre-authorisations.

List Transactions

const transactions = await client.transactions.list({
  organisation: 'org-id',
  statuses: ['COMPLETE'],
  date_from: '2025-01-01',
  date_to: '2025-12-31',
});

Refund a Transaction

// Amount in lowest denomination (e.g. pence)
await client.transactions.refund('transaction-id', {
  amount: 5000,
  description: 'Customer requested refund',
});

Complete Pre-Auth

// Capture held funds on a pre-authorised transaction
await client.transactions.complete('transaction-id');

Reverse Pre-Auth

// Release held funds on a pre-authorised transaction
await client.transactions.reverse('transaction-id');

Re-assign to Different Booking

await client.transactions.reassign('transaction-id', {
  booking_id: 'new-booking-id',
});

Create payment links to send to customers for card or open banking payments.

Create a Payment Link

const link = await client.paymentLinks.create({
  customer_name: 'John Doe',
  email: 'john@example.com',
  organisation: 'org-id',
  amount: 50000,
  type: 'CARD',
  booking_id: 'booking-id',
  open_banking_enabled: true,
  card_enabled: true,
  description: 'Holiday deposit',
  currency: 'GBX',
});

Assign a Payment Link to a Booking

await client.paymentLinks.assign('payment-link-id', {
  organisation: 'org-id',
  customer_name: 'John Doe',
  email: 'john@example.com',
  booking_reference: 'REF-002',
});

Ecommerce Sessions

Create ecommerce sessions for use with the browser-side JavaScript SDK.

Create an Ecommerce Session

const session = await client.ecommerce.create({
  customer_name: 'Jane Smith',
  email: 'jane@example.com',
  organisation: 'org-id',
  amount: 75000,
  booking_id: 'booking-id',
  open_banking_enabled: true,
  card_enabled: true,
});

// Pass session.data.id to the browser SDK
console.log('Ecommerce ID:', session.data.id);

Customers

Create and list customer records.

Create a Customer

const customer = await client.customers.create({
  organisation: 'org-id',
  customer_name: 'Jane Smith',
  email: 'jane@example.com',
  address_1: '123 High Street',
  city: 'London',
  county: 'Greater London',
  post_code: 'SW1A 1AA',
});

Search Customers

const customers = await client.customers.list({
  organisation: 'org-id',
  keyword: 'jane@example.com',
});

Refunds

List pending refunds and authorise or decline them.

List and Authorise Refunds

const refunds = await client.refunds.list({
  organisation: 'org-id',
});

// Authorise a pending refund
await client.refunds.authorise('authorisation-code');

// Or decline it
await client.refunds.decline('authorisation-code');

Scheduled Payments

Manage stored-card (MOTO) payments and generate customer approval links.

Fetch Available Tokens

// Get stored card tokens for a booking
const tokens = await client.scheduledPayments.availableTokens(
  'booking-id'
);

console.log(tokens.data);
// [{ id, cardholder_name, bin, card_brand, ... }]

Create a Scheduled Payment

const payment = await client.scheduledPayments.createPayment(
  'booking-id',
  {
    token: 'token-id',
    amount: 25000,
    date: '2025-09-01',  // optional: schedule for future
  }
);

Generate an Approval Link

const approval = await client.scheduledPayments.approvalLink(
  'booking-id',
  {
    amount: 25000,
    token: 'token-id',
  }
);

console.log('Send to customer:', approval.data.url);

Credit Notes

Create credit notes and assign them to bookings.

Create and Assign a Credit Note

const note = await client.creditNotes.create({
  organisation: 'org-id',
  customer_name: 'James Dean',
  amount: 15000,
  currency: 'GBX',
});

// Assign to a booking
await client.creditNotes.assign(note.data.id, {
  organisation: 'org-id',
  customer_name: 'James Dean',
  email: 'james@example.com',
  booking_reference: 'REF-003',
});

Suppliers & Beneficiaries

Manage suppliers for booking components and beneficiary bank accounts for disbursements.

Suppliers

// Create a supplier
const supplier = await client.suppliers.create({
  organisation: 'org-id',
  supplier_name: 'Felloh Airlines',
});

// List suppliers
const suppliers = await client.suppliers.list({
  organisation: 'org-id',
  keyword: 'airlines',
});

Beneficiaries

// Create a beneficiary bank account
const beneficiary = await client.beneficiaries.create({
  organisation: 'org-id',
  account_name: 'Felloh Travel Ltd',
  account_number: '12345678',
  sort_code: '112233',
});

// Activate a beneficiary
await client.beneficiaries.activate('beneficiary-id');

Organisations & API Keys

List accessible organisations and manage API keys programmatically.

Organisations

const orgs = await client.organisations.list();

for (const org of orgs.data) {
  console.log(org.id, org.name);
}

API Keys

// Create a new API key pair
const key = await client.apiKeys.create({
  organisation: 'org-id',
  name: 'Production Server',
});

// Store these securely — secret_key is only returned once
console.log('Public:', key.data.public_key);
console.log('Secret:', key.data.secret_key);

// List existing keys
const keys = await client.apiKeys.list({
  organisation: 'org-id',
});

// Delete a key
await client.apiKeys.delete('key-id');

Logging

Pass a logger callback to observe every HTTP request made by the SDK.

Each LogEntry includes:

  • Name
    method
    Type
    string
    Description

    HTTP method (GET, POST, PUT, DELETE).

  • Name
    url
    Type
    string
    Description

    Full request URL including query string.

  • Name
    statusCode
    Type
    integer
    Description

    HTTP status code, or undefined if the request failed before receiving a response.

  • Name
    durationMs
    Type
    integer
    Description

    Request duration in milliseconds.

  • Name
    attempt
    Type
    integer
    Description

    Retry attempt number (0 for the first attempt).

Request Logging

const client = new FellohClient({
  publicKey: 'your-public-key',
  privateKey: 'your-private-key',
  logger: (entry) => {
    console.log(JSON.stringify({
      method: entry.method,
      url: entry.url,
      status: entry.statusCode,
      duration: entry.durationMs,
      attempt: entry.attempt,
    }));
  },
});