Skip to main content

TypeScript SDK

The official TypeScript SDK provides typed functions for every API endpoint with full autocomplete and compile-time type checking.

Installation

Published on npm — @journeybee/sdk:
npm install @journeybee/sdk

Quick start

import { client, listPartners, createLead } from "@journeybee/sdk";

// Configure once — all subsequent calls use this config
client.setConfig({
  baseUrl: "https://api.journeybee.io/v1",
  auth: "YOUR_API_KEY",
});

// List partners with search
const { data: partners } = await listPartners({
  query: { search: "acme", per_page: 10 },
});

// Create a lead
const { data: lead } = await createLead({
  body: {
    first_name: "Jane",
    last_name: "Smith",
    email: "jane@example.com",
    partnership_uuid: "partner-uuid-here",
  },
});

Authentication

Pass your API key to client.setConfig(). The SDK sends it as a Bearer token on every request automatically.
import { client } from "@journeybee/sdk";

client.setConfig({
  baseUrl: "https://api.journeybee.io/v1",
  auth: "jb_live_your_api_key",
});

Request patterns

Every SDK function accepts an options object with typed path, query, and body fields depending on the endpoint.

List with pagination and filters

import { listLeads } from "@journeybee/sdk";

const { data } = await listLeads({
  query: {
    page: 1,
    per_page: 50,
    status: "new",
    search: "acme",
  },
});

// data.data — array of leads
// data.pagination — { page, per_page, total, total_pages }

Get by UUID

import { getPartner } from "@journeybee/sdk";

const { data: partner } = await getPartner({
  path: { uuid: "partner-uuid" },
});

Create

import { createDeal } from "@journeybee/sdk";

const { data: deal } = await createDeal({
  body: {
    lead_uuid: "lead-uuid",
    value: 50000,
    currency_uuid: "currency-uuid",
  },
});

Update

import { updateLead } from "@journeybee/sdk";

const { data: lead } = await updateLead({
  path: { uuid: "lead-uuid" },
  body: { status: "converted" },
});

Delete

import { deleteLead } from "@journeybee/sdk";

await deleteLead({
  path: { uuid: "lead-uuid" },
});

Sub-resources

import { addLeadTag, removeLeadTag, listLeadNotes } from "@journeybee/sdk";

// Add a tag
await addLeadTag({
  path: { uuid: "lead-uuid" },
  body: { tag_uuid: "tag-uuid" },
});

// Remove a tag
await removeLeadTag({
  path: { uuid: "lead-uuid", subUuid: "tag-uuid" },
});

// List notes
const { data: notes } = await listLeadNotes({
  path: { uuid: "lead-uuid" },
});

Error handling

SDK functions return { data, error, response }. Check error for failures:
import { getLead } from "@journeybee/sdk";

const { data, error } = await getLead({
  path: { uuid: "nonexistent" },
});

if (error) {
  console.error("API error:", error);
  // error.code — "not_found", "unauthorized", etc.
  // error.message — human-readable description
} else {
  console.log("Lead:", data);
}

Available functions

The SDK exports one function per API endpoint. Function names match the operationId in the API Reference:
DomainFunctions
PartnerslistPartners, getPartner, createPartner, updatePartner
LeadslistLeads, getLead, createLead, updateLead, deleteLead
DealslistDeals, getDeal, createDeal, updateDeal, deleteDeal
TaskslistTasks, getTask, createTask, updateTask, deleteTask
ProductslistProducts, getProduct, createProduct, updateProduct, deleteProduct
ContactslistContacts, getContact
CommissionslistCommissions, getCommission, createCommission, updateCommission, deleteCommission
ResourceslistResources, getResource, createResource, updateResource, deleteResource
CertificationslistCertifications, getCertification, createCertification, enrollInCertification
RoomslistRooms, getRoom, createRoom, updateRoom, deleteRoom
FolderslistFolders, getFolder, createFolder, updateFolder, deleteFolder
ConfigurationlistPartnerStages, listDealStages, listTiers, listCategories, listTags, listCustomFields
Plus sub-resource functions like addLeadTag, listLeadNotes, createPartnerContact, getDealCommission, addResourceBlock, addRoomBlock, addRoomTier, and more. See the API Reference for the complete list.