SDK

TypeScript SDK

A typed TypeScript client for the Pixelbase API. Token exchange, refresh, pagination, retries and errors are handled for you, so your code deals in customers and orders rather than in requests.

Install

Node 18.17 or newer, or any runtime with a global fetch. The package ships its own types — there is no @types package to add.

bash
npm install @pixelbase/sdk

Quick start

Create an API client on the Dev Tools page and pass its credentials. The client exchanges them for an access token on the first call and mints a new one before it expires, so there is no token handling in your code.

typescript
import { Pixelbase } from '@pixelbase/sdk';

const pxb = new Pixelbase({
  clientId: process.env.PXB_CLIENT_ID,
  clientSecret: process.env.PXB_CLIENT_SECRET
});

const { customers } = await pxb.customers.list({
  locationId: 'loc_abc123',
  limit: 20
});

for (const customer of customers) {
  console.log(customer.fullname, customer.email);
}

Every method returns the response's content — the { message, content } envelope is unwrapped for you.

Configuration

clientIdThe client_id of an API client. Defaults to PXB_CLIENT_ID.
clientSecretIts client_secret. Defaults to PXB_CLIENT_SECRET. Read it from the environment — never commit it.
accessTokenInstead of client credentials: a token you already hold, such as one from an OAuth connection. Pass a function to be asked on every request — and again after a 401 — so you can refresh it yourself.
baseUrlDefaults to PXB_BASE_URL, then https://www.pxb.app. Point it at a preview deployment or a local server when testing.
companyIdSent as X-Company-Id on every request. Only needed for a token that reaches more than one company — an API client belongs to exactly one.
maxRetriesDefaults to 2. See Retries.
timeoutMilliseconds per attempt. Defaults to 60000.
fetchA fetch to use instead of the global one — for a proxy, a test double, or an older runtime.

Every method also takes an options object last, for one call only: companyId, signal, timeout, maxRetries and headers.

typescript
await pxb.products.get('prod_1', { companyId: 'co_2', signal: AbortSignal.timeout(5000) });

Pagination

A list method returns one page plus its pagination block. When you want everything, listAll walks the pages for you — as large as the API serves them — and stops when they run out.

typescript
for await (const order of pxb.orders.listAll({ locationId })) {
  await handle(order);
}

Errors

Anything that isn't a 2xx throws a PxbError carrying the status, the server's message and — for a scope failure — exactly which scopes were missing, so you can tell a misconfigured client from a genuine failure without parsing prose. A request that never got a response has status 0, with the underlying failure on cause.

typescript
import { PxbError } from '@pixelbase/sdk';

try {
  await pxb.products.create({ locationId, name: 'Espresso', description: '', price: 400 });
} catch (err) {
  if (err instanceof PxbError && err.status === 403) {
    console.error('Missing scopes:', err.missingScopes);
    return;
  }
  throw err;
}

A rejected client secret throws before any request is sent, with code set to invalid_client.

Retries

  • A 429 is always retried, after the Retry-After the server sent. It was refused before anything ran, so even a create is safe to send again.
  • A 5xx or a dropped connection is retried with exponential backoff — except on a POST, which might have landed. Read it back before trying again.
  • A 401 mints a fresh token and tries once more, in case the old one was revoked early.

Methods

One namespace per collection, each with the operations the API implements for it. This table is generated from the same spec as the package, and each method links to the endpoint it calls.

MethodDoesScope
pxb.agents.list(params?)List agentsagents:read
pxb.agents.get(agentId)Get an agentagents:read
pxb.agents.create(params)Hire an agentagents:write
pxb.agents.update(agentId, params?)Update an agentagents:write
pxb.agents.delete(agentId)Fire an agentagents:admin
pxb.analyticsReport.get(params?)Get the analytics reportanalytics:read
pxb.appointmentAvailability.list(params)List availability windowsappointments:read
pxb.appointmentAvailability.create(params)Create availability windowappointments:write
pxb.appointmentAvailability.delete(availabilityId)Delete availability windowappointments:write
pxb.appointments.list(params)List appointmentsappointments:read
pxb.appointments.get(appointmentId)Get an appointmentappointments:read
pxb.appointments.updateStatus(appointmentId, params)Update appointment statusappointments:write
pxb.appointmentServices.list(params)List appointment servicesappointments:read
pxb.appointmentServices.create(params)Create appointment serviceappointments:write
pxb.appointmentServices.update(serviceId, params?)Update appointment serviceappointments:write
pxb.appointmentServices.delete(serviceId)Delete appointment serviceappointments:write
pxb.auditLogs.list(params?)List audit logssecurity:read
pxb.benefits.list(params?)List benefitshr:read
pxb.benefits.get(benefitId)Get a benefithr:read
pxb.benefits.create(params)Create a benefithr:write
pxb.benefits.update(benefitId, params?)Update a benefithr:write
pxb.benefits.delete(benefitId)Delete a benefithr:write
pxb.blogPosts.list(params)List blog postsblog:read
pxb.blogPosts.get(postId)Get a blog postblog:read
pxb.blogPosts.create(params)Create a blog postblog:write
pxb.blogPosts.update(postId, params?)Update a blog postblog:write
pxb.blogPosts.delete(postId)Delete a blog postblog:write
pxb.buildDeployments.list()List recent deploymentsbuilder:engineer
pxb.builderUsage.get()Get Builder usagebuilder:read
pxb.buildSessions.list(params?)List build sessionsbuilder:read
pxb.buildSessions.get(sessionId)Get a build sessionbuilder:read
pxb.buildSessions.create(params)Start a build sessionbuilder:write
pxb.buildSessions.delete(sessionId)Delete a build sessionbuilder:engineer
pxb.buildSessions.messages(sessionId, params?)Read a session’s transcriptbuilder:read
pxb.buildSessions.message(sessionId, params)Message the agentbuilder:write
pxb.buildSessions.interrupt(sessionId)Stop the agentbuilder:write
pxb.buildSessions.retryStart(sessionId)Retry starting the agentbuilder:write
pxb.buildSessions.archive(sessionId)Archive a build sessionbuilder:write
pxb.buildSessions.reopen(sessionId)Reopen an archived sessionbuilder:engineer
pxb.buildSessions.approvePlan(sessionId)Approve the planbuilder:write
pxb.buildSessions.setAutoMode(sessionId, params)Set auto modebuilder:write
pxb.calendarEvents.list(params?)List calendar eventscalendar:read
pxb.calendarEvents.get(eventId)Get a calendar eventcalendar:read
pxb.calendarEvents.create(params)Create a calendar eventcalendar:write
pxb.calendarEvents.update(eventId, params?)Update a calendar eventcalendar:write
pxb.calendarEvents.delete(eventId, params?)Delete a calendar eventcalendar:write
pxb.calendarEvents.rsvp(eventId, params)Answer a calendar invitationcalendar:write
pxb.callScripts.list(params)List call scriptscall-scripts:read
pxb.callScripts.get(scriptId)Get a call scriptcall-scripts:read
pxb.callScripts.create(params)Create a call scriptcall-scripts:write
pxb.callScripts.update(scriptId, params?)Update a call scriptcall-scripts:write
pxb.callScripts.delete(scriptId)Delete a call scriptcall-scripts:write
pxb.campaigns.list(params)List campaignscampaigns:read
pxb.campaigns.get(campaignId)Get a campaigncampaigns:read
pxb.campaigns.create(params)Create a campaigncampaigns:write
pxb.campaigns.update(campaignId, params?)Update a campaigncampaigns:write
pxb.campaigns.delete(campaignId)Delete a campaigncampaigns:write
pxb.campaigns.send(campaignId, params)Send, pause or cancel a campaigncampaigns:write
pxb.companyChart.get()Get the company chartcompany-structure:read
pxb.companySettings.get()Get company settingssettings:read
pxb.companySettings.update(params?)Update company settingssettings:write
pxb.contactInquiries.create(params)Send the Pixelbase team a requestinquiries:write
pxb.conversations.list(params?)List conversationsthreads:read
pxb.conversations.get(conversationId)Get a conversationthreads:read
pxb.conversations.messages(conversationId, params?)List messages in a conversationthreads:read
pxb.conversations.thread(conversationId, messageId)Read a threadthreads:read
pxb.conversations.send(conversationId, params)Send a messagethreads:write
pxb.conversations.read(conversationId)Mark a conversation readthreads:write
pxb.conversations.unread(conversationId)Mark a conversation unreadthreads:write
pxb.conversations.readThread(conversationId, messageId)Mark a thread readthreads:write
pxb.customerCustomFields.list(params)List customer custom fieldscustomer:custom-fields:read
pxb.customerCustomFields.create(params)Create a customer custom fieldcustomer:custom-fields:write
pxb.customerCustomFields.update(customFieldId, params?)Update a customer custom fieldcustomer:custom-fields:write
pxb.customerCustomFields.delete(customFieldId)Delete a customer custom fieldcustomer:custom-fields:write
pxb.customers.list(params)List customerscustomers:read
pxb.customers.get(accountId)Get a customercustomers:read
pxb.customers.create(params)Create a customercustomers:write
pxb.customers.update(accountId, params?)Update a customercustomers:write
pxb.customers.customFields(accountId)Get customer custom field valuescustomer:custom-fields:read
pxb.customers.setCustomFields(accountId, params)Set customer custom field valuescustomer:custom-fields:write
pxb.deals.list(params)List dealsdeals:read
pxb.deals.get(dealId)Get a dealdeals:read
pxb.deals.create(params)Create a dealdeals:write
pxb.deals.update(dealId, params?)Update a dealdeals:write
pxb.deals.delete(dealId)Archive a dealdeals:write
pxb.deals.move(dealId, params)Move a deal to another stagedeals:write
pxb.deals.close(dealId, params)Win, lose or re-open a dealdeals:write
pxb.departments.list()List departmentscompany-structure:read
pxb.departments.create(params)Create a departmentcompany-structure:write
pxb.departments.update(departmentId, params)Update a departmentcompany-structure:write
pxb.departments.delete(departmentId)Delete a departmentcompany-structure:write
pxb.domains.list(params?)List domainsdomains:read
pxb.domains.get(domainId)Get a domaindomains:read
pxb.domains.create(params)Buy a domaindomains:write
pxb.emailAddresses.list(params?)List email addressesemail:addresses:read
pxb.emailAddresses.create(params)Create an email addressemail:addresses:write
pxb.emailAddresses.delete(emailAddressId)Delete an email addressemail:addresses:write
pxb.emailDrafts.list(params?)List email draftsemail:messages:read
pxb.emailDrafts.get(draftId)Get an email draftemail:messages:read
pxb.emailDrafts.create(params?)Create an email draftemail:messages:write
pxb.emailDrafts.update(draftId, params?)Update an email draftemail:messages:write
pxb.emailDrafts.delete(draftId)Delete an email draftemail:messages:write
pxb.emailDrafts.send(draftId)Send an email draftemail:messages:write
pxb.emailFolders.list()List email folders and mailboxesemail:messages:read
pxb.emailFolders.create(params)Create an email folderemail:messages:write
pxb.emails.list(params?)List emailsemail:messages:read
pxb.emails.get(emailId, params?)Get an emailemail:messages:read
pxb.emails.create(params)Send an emailemail:messages:write
pxb.emails.update(emailId, params?)Update an emailemail:messages:write
pxb.emailThreads.get(threadId, params?)Get an email threademail:messages:read
pxb.employeeInvitations.list(params?)List employee invitationsemployee:invitations:read
pxb.employeeInvitations.create(params)Invite an employeeemployee:invitations:write
pxb.employeeInvitations.delete(invitationId)Revoke an invitationemployee:invitations:write
pxb.employeeOnboardings.list(params?)List employees in onboardingemployee:onboardings:read
pxb.employeeOnboardings.get(employeeId)Get an onboarding employeeemployee:onboardings:read
pxb.employees.list(params?)List employeesemployees:read
pxb.galleryPhotos.list(params)List gallery photosgallery:read
pxb.galleryPhotos.delete(photoId)Delete a gallery photogallery:write
pxb.invoices.list(params?)List invoicesinvoices:read
pxb.invoices.get(invoiceId)Get an invoiceinvoices:read
pxb.invoices.create(params)Create an invoiceinvoices:write
pxb.invoices.delete(invoiceId)Delete an invoiceinvoices:write
pxb.invoices.void(invoiceId)Void an invoiceinvoices:write
pxb.invoices.sendEmail(invoiceId)Email an invoiceinvoices:write
pxb.ipWhitelistEntries.list()List IP whitelistsecurity:read
pxb.ipWhitelistEntries.create(params)Add IP to whitelistsecurity:write
pxb.ipWhitelistEntries.delete(id)Remove IP from whitelistsecurity:write
pxb.jobTitles.list(params?)List job titlescompany-structure:read
pxb.jobTitles.create(params)Create a job titlecompany-structure:write
pxb.jobTitles.update(jobTitleId, params?)Update a job titlecompany-structure:write
pxb.jobTitles.delete(jobTitleId)Delete a job titlecompany-structure:write
pxb.leads.list(params)List leadsleads:read
pxb.leads.get(leadId)Get a leadleads:read
pxb.leads.create(params)Create a leadleads:write
pxb.leads.update(leadId, params?)Update a leadleads:write
pxb.leads.delete(leadId)Delete a leadleads:write
pxb.leads.convert(leadId)Convert a lead to a customerleads:write
pxb.legalEntities.list(params?)List legal entitiessettings:read
pxb.legalEntities.get(legalEntityId)Get a legal entitysettings:read
pxb.legalEntities.create(params)Create a legal entitysettings:write
pxb.legalEntities.amend(legalEntityId, params)File an amendmentsettings:write
pxb.locationHours.list(params)Get location hourslocation:hours:read
pxb.locationHours.set(params)Update location hourslocation:hours:write
pxb.locations.list(params?)List locationslocations:read
pxb.locations.get(locationId)Get a locationlocations:read
pxb.locations.create(params)Create a locationlocations:write
pxb.locations.update(locationId, params?)Update a locationlocations:write
pxb.locations.archive(locationId)Archive a locationlocations:admin
pxb.meetingRecordings.list(params?)List meeting recordingsmeetings:read
pxb.meetingRooms.list(params?)List meeting roomsmeetings:read
pxb.meetingRooms.get(roomId)Get a meeting roommeetings:read
pxb.meetingRooms.create(params)Create a meeting roommeetings:write
pxb.meetingRooms.update(roomId, params?)Update a meeting roommeetings:write
pxb.meetingRooms.delete(roomId)Delete a meeting roommeetings:write
pxb.milestones.list(params?)List milestonesprojects:read
pxb.milestones.get(milestoneId)Get a milestoneprojects:read
pxb.milestones.create(params)Create a milestoneprojects:write
pxb.milestones.update(milestoneId, params?)Update a milestoneprojects:write
pxb.milestones.delete(milestoneId)Delete a milestoneprojects:admin
pxb.newsletterSubscriptions.list(params)List newsletter subscriptionsnewsletter:subscriptions:read
pxb.newsletterSubscriptions.delete(subscriptionId)Remove a newsletter subscriptionnewsletter:subscriptions:write
pxb.notificationPreferences.get()Get notification preferencesnotifications:read
pxb.notificationPreferences.update(params?)Update notification preferencesnotifications:write
pxb.notifications.list(params?)List notificationsnotifications:read
pxb.notifications.handle(notificationId)Mark notification as handlednotifications:write
pxb.orders.list(params)List ordersorders:read
pxb.orders.get(orderId)Get an orderorders:read
pxb.payables.list(params?)List payablespayables:read
pxb.paymentMethods.list()List payment methodsbilling:read
pxb.paymentMethods.setDefault(params)Set default payment methodbilling:write
pxb.payouts.list(params)List payoutspayouts:read
pxb.payouts.create(params)Create a payoutpayouts:write
pxb.performanceReviews.list(params?)List performance reviewshr:read
pxb.performanceReviews.get(reviewId)Get a performance reviewhr:read
pxb.performanceReviews.create(params)Write a performance reviewhr:write
pxb.pipeline.get(params)Get a location’s pipelinedeals:read
pxb.products.list(params)List productsproducts:read
pxb.products.get(productId)Get a productproducts:read
pxb.products.create(params)Create a productproducts:write
pxb.products.update(productId, params?)Update a productproducts:write
pxb.products.delete(productId)Delete a productproducts:write
pxb.projectLabels.list(params?)List project labelsprojects:read
pxb.projectLabels.create(params)Create a project labelprojects:admin
pxb.projectLabels.delete(labelId)Delete a project labelprojects:admin
pxb.projects.list(params?)List projectsprojects:read
pxb.projects.get(projectId)Get a projectprojects:read
pxb.projects.create(params)Create a projectprojects:admin
pxb.projects.update(projectId, params?)Update a projectprojects:admin
pxb.projects.delete(projectId)Delete a projectprojects:admin
pxb.qaChecks.list(params)List QA line checksquality:checks:read
pxb.qaChecks.create(params)Record a QA line checkquality:checks:write
pxb.qaCorrectiveActions.list(params)List QA corrective actionsquality:actions:read
pxb.qaCorrectiveActions.create(params)Open or update a corrective actionquality:actions:write
pxb.qaShiftSessions.list(params)List QA shift sessionsquality:checks:read
pxb.qaSpecs.list(params)List QA product specsquality:specs:read
pxb.qaSpecs.create(params)Create or update a QA product specquality:specs:write
pxb.shifts.list(params?)List shiftsschedule:read
pxb.shifts.get(shiftId)Get a shiftschedule:read
pxb.shifts.create(params)Create a shiftschedule:write
pxb.shifts.update(shiftId, params?)Update a shiftschedule:write
pxb.shifts.delete(shiftId)Delete a shiftschedule:write
pxb.sso.get()Get the SSO configurationsso:read
pxb.supportConversations.list(params?)List support conversationsinternal:support:read
pxb.supportConversations.get(conversationId)Get a support conversationinternal:support:read
pxb.taxFilings.list(params?)List tax filingstaxes:read
pxb.taxFilings.get(filingId)Get a tax filingtaxes:read
pxb.taxFilings.update(filingId, params)Update a tax filingtaxes:write
pxb.taxLiability.get(params)Get tax liabilitytaxes:read
pxb.tickets.list(params?)List ticketsprojects:read
pxb.tickets.get(ticketId)Get a ticketprojects:read
pxb.tickets.create(params)Create a ticketprojects:write
pxb.tickets.update(ticketId, params?)Update a ticketprojects:write
pxb.tickets.delete(ticketId)Delete a ticketprojects:admin
pxb.tickets.comments(ticketId)List comments on a ticketprojects:read
pxb.tickets.comment(ticketId, params)Comment on a ticketprojects:write
pxb.timeClockEntries.list(params?)List time clock entrieshr:read
pxb.timeClockEntries.create()Clock inhr:write
pxb.timeClockEntries.clockOut(entryId)Clock outhr:write
pxb.timeOffRequests.list(params?)List time-off requestshr:read
pxb.timeOffRequests.get(requestId)Get a time-off requesthr:read
pxb.timeOffRequests.create(params)Request time offhr:write
pxb.timeOffRequests.review(requestId, params)Approve or deny time offhr:write
pxb.timeOffRequests.cancel(requestId)Withdraw a time-off requesthr:write
pxb.transactions.list(params?)List transactionstransactions:read
pxb.transactions.get(transactionId)Get a transactiontransactions:read
pxb.transactions.create(params)Record a transactiontransactions:write
pxb.transactions.update(transactionId, params?)Update a transactiontransactions:write
pxb.transactions.delete(transactionId)Void a transactiontransactions:admin
pxb.transactions.markPaid(transactionId, params?)Mark a transaction paidtransactions:write
pxb.unreadThreads.list()List unread threadsthreads:read
pxb.usage.get()Get the usage reportusage:read
pxb.vaultCredentials.list(params?)List Vault credentialsvault:admin
pxb.vaultCredentials.get(credentialId)Reveal a Vault credentialvault:admin
pxb.vaultDocuments.list(params?)List Vault documentsvault:admin
pxb.vaultDocuments.get(documentId)Get a Vault documentvault:admin
pxb.vaultDocuments.create(params)Create a Vault document or foldervault:admin
pxb.vaultDocuments.update(documentId, params?)Update a Vault documentvault:admin
pxb.vaultDocuments.delete(documentId, params?)Archive or delete a Vault documentvault:admin
pxb.vaultDocuments.download(documentId)Get a download URLvault:admin
pxb.vaultFolders.list()List Vault foldersvault:admin

For anything not listed, pxb.request(method, path, { query, body }) calls any path under /api/public/v1/ with the same authentication, retries and errors.

Conventions

  • Types come from the API reference. Request types are generated from the same source as the endpoint reference, so they can't drift from what it documents. Response types come from its examples, so beyond id a record's fields are optional — an example shows what a field looks like, not that it is always set.
  • Server-side only. The client credentials grant is not safe in a browser — anything shipped to a user can be read by that user. Call it from your own backend.
  • Scopes still apply. The SDK is a wrapper over the same API, so a client without products:write cannot write products through it either.