Skip to content

Quick start

You’ll go from nothing to a selected cyber quote, using the raw client against the mock API. This page follows examples/cyber.ts.

  1. Install the SDK.

    Terminal window
    npm install @partner-sdk/core
  2. Run the mock API. It replays a recorded cyber journey, so you don’t need credentials.

    Terminal window
    git clone git@github.com:simplybusiness/partner-sdk.git
    cd partner-sdk && bun install
    cd mock-api && bun start # http://localhost:3000
  3. Create a client and start a questionnaire.

    quote.ts
    import { apiKey, createClient } from '@partner-sdk/core';
    const client = createClient({
    baseUrl: 'http://localhost:3000',
    auth: apiKey('your-api-key'), // only needed behind the API Gateway
    });
    let q = await client.start('cyber'); // one POST

    q is a Questionnaire: an immutable snapshot. q.questions lists what the server wants next.

  4. Answer the first questions. Each call sends one PATCH and returns a new snapshot.

    q = await q.answer({ 'Business owner': 'yes', 'US state': 'Ohio' });
    console.log(q.errors); // [] — rejected values come back here, not as exceptions
  5. Answer the trade. Trade has no fixed options: search, then answer with a result’s value.

    const { results } = await q.searchTrade('handyman');
    q = await q.answer('Primary trade', results[0].value);
  6. Answer the rest. Send wire values: dates as YYYY-MM-DD, phones in E.164.

    q = await q.answer({
    'Policy effective date': '2026-10-20',
    'Policy start date': '2026-10-20',
    'Business name': 'Cleveland Handy Services',
    'Business street': '3201 West 140th Street',
    'Business city': 'Cleveland',
    'US zipcode': '44111',
    'Customer[first_name]': 'Sam',
    'Customer[last_name]': 'Smith',
    'Customer[email_address]': 'sam@example.com',
    'Customer[telephone_number]': '+12165550123',
    });
  7. Get quotes. ready narrows the type: only a ready snapshot has quotes.

    if (q.ready) {
    const quoteSet = await q.quotes.wait({ timeoutMs: 60_000 });
    const [first] = quoteSet.quotes;
    const detail = await first.detail(); // covers, insurer responses, reference
    await first.select(); // choose it
    // Send the customer here to buy:
    console.log(quoteSet.quoteComparisonUrl);
    }

The SDK repo runs every example against the mock:

Terminal window
bun run examples cyber