Skip to main content

@planpoint/sdk

Official TypeScript SDK for the PlanPoint API.

Installation

npm install @planpoint/sdk

Quick Start

import { login, getMyProjects, createClient } from "@planpoint/sdk";
import { createClient } from "@hey-api/client-fetch";

// 1. Authenticate
const { data } = await login({
  body: { username: "you@example.com", password: "yourpassword" },
});

// 2. Create an authenticated client
const client = createClient({
  baseUrl: "https://app.planpoint.io",
  headers: { Authorization: `Bearer ${data.access_token}` },
});

// 3. Fetch your projects
const { data: projects } = await getMyProjects({ client });
console.log(projects); // ProjectSummary[]

API Reference

Authentication

login(options)

Authenticate and receive a JWT token.
ParamTypeRequiredDescription
body.usernamestringYesUser email
body.passwordstringNoUser password
body.impersonatebooleanNoImpersonate another user
Returns: LoginResponse{ message: string, access_token: string }

Projects

getMyProjects(options)

List all projects belonging to the authenticated user. Requires auth. Returns: ProjectSummary[]{ _id, name, namespace?, hostName?, status?, paused?, createdAt? }

findProject(options)

Find a public project by namespace and hostname. No auth required.
ParamTypeRequiredDescription
body.namespacestringYesProject namespace
body.hostNamestringYesAllowed hostname
Returns: Project — full project with floors, units, settings

getProject(options)

Get a project by ID. Requires auth.
ParamTypeRequiredDescription
path.idstringYesProject ObjectId
Returns: Project

updateProject(options)

Update project settings. Requires auth.
ParamTypeRequiredDescription
path.idstringYesProject ObjectId
bodyRecord<string, unknown>YesFields to update
Returns: Project

Groups

getGroups(options)

List all groups for the authenticated user. Returns: GroupsListResponse{ records: Group[], count: number }

getGroup(options)

Get a group by ID.
ParamTypeRequiredDescription
path.idstringYesGroup ObjectId
Returns: Group{ _id, name, namespace?, hostName?, type?, projects?, isOwner?, isAdmin?, isEditor? }

createGroup(options)

Create a new group.
ParamTypeRequiredDescription
body.namestringYesGroup name
body.namespacestringNoNamespace
body.hostNamestringNoHostname
body.typestringNoGroup type
body.propertyTypestringNoProperty type
Returns: Group

updateGroup(options)

Update a group.
ParamTypeRequiredDescription
path.idstringYesGroup ObjectId
bodyRecord<string, unknown>YesFields to update
Returns: Group

Floors

getFloors(options)

List all floors for a project.
ParamTypeRequiredDescription
query.pidstringYesProject ObjectId
Returns: FloorFull[]{ _id, name?, project, level?, position?, path?, image? }

getFloor(options)

Get a floor by ID.
ParamTypeRequiredDescription
path.idstringYesFloor ObjectId
Returns: FloorFull

createFloor(options)

Create a new floor.
ParamTypeRequiredDescription
body.project._idstringYesProject ObjectId
body.namestringYesFloor name
body.positionnumberNoDisplay order
body.pathstringNoSVG/image path
body.alternativePathsstring[]NoAdditional paths
Returns: FloorFull

updateFloor(options)

Update a floor.
ParamTypeRequiredDescription
path.idstringYesFloor ObjectId
bodyRecord<string, unknown>YesFields to update
Returns: FloorFull

Units

getUnits(options)

List all units for a project.
ParamTypeRequiredDescription
query.pidstringYesProject ObjectId
Returns: UnitsListResponse{ records: UnitFull[], count: number } UnitFull: { _id, floor, name?, unitNumber?, status?, price?, bed?, bath?, sqft?, model?, orientation?, parking? } status values: Available | OnHold | Sold | Leased | Unavailable

getUnit(options)

Get a unit by ID.
ParamTypeRequiredDescription
path.idstringYesUnit ObjectId
Returns: UnitFull

createUnit(options)

Create a new unit.
ParamTypeRequiredDescription
body.floor._idstringYesFloor ObjectId
Returns: UnitFull

updateUnit(options)

Update a unit.
ParamTypeRequiredDescription
path.idstringYesUnit ObjectId
bodyRecord<string, unknown>YesFields to update
Returns: UnitFull

deleteUnit(options)

Delete a unit.
ParamTypeRequiredDescription
path.idstringYesUnit ObjectId
Returns: { message: string }

batchUpdateUnits(options)

Update multiple units at once.
ParamTypeRequiredDescription
body.idsstring[]YesUnit ObjectIds to update
body.patchDataRecord<string, unknown>YesFields to apply to all
Returns: UnitFull[]

Leads

getLeads(options)

List all leads for a project.
ParamTypeRequiredDescription
query.pidstringYesProject ObjectId
Returns: Lead[]{ _id?, name?, email?, phone?, message?, unit?, createdAt? }

TypeScript Support

All methods are fully typed. Import types directly:
import type {
  Project,
  ProjectSummary,
  Group,
  GroupsListResponse,
  FloorFull,
  UnitFull,
  UnitsListResponse,
  Lead,
  LoginResponse,
} from "@planpoint/sdk";