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.
npm install @pixelbase/sdkQuick 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.
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.
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.
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.
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-Afterthe 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.
| Method | Does | Scope |
|---|---|---|
| pxb.agents.list(params?) | List agents | agents:read |
| pxb.agents.get(agentId) | Get an agent | agents:read |
| pxb.agents.create(params) | Hire an agent | agents:write |
| pxb.agents.update(agentId, params?) | Update an agent | agents:write |
| pxb.agents.delete(agentId) | Fire an agent | agents:admin |
| pxb.analyticsReport.get(params?) | Get the analytics report | analytics:read |
| pxb.appointmentAvailability.list(params) | List availability windows | appointments:read |
| pxb.appointmentAvailability.create(params) | Create availability window | appointments:write |
| pxb.appointmentAvailability.delete(availabilityId) | Delete availability window | appointments:write |
| pxb.appointments.list(params) | List appointments | appointments:read |
| pxb.appointments.get(appointmentId) | Get an appointment | appointments:read |
| pxb.appointments.updateStatus(appointmentId, params) | Update appointment status | appointments:write |
| pxb.appointmentServices.list(params) | List appointment services | appointments:read |
| pxb.appointmentServices.create(params) | Create appointment service | appointments:write |
| pxb.appointmentServices.update(serviceId, params?) | Update appointment service | appointments:write |
| pxb.appointmentServices.delete(serviceId) | Delete appointment service | appointments:write |
| pxb.auditLogs.list(params?) | List audit logs | security:read |
| pxb.benefits.list(params?) | List benefits | hr:read |
| pxb.benefits.get(benefitId) | Get a benefit | hr:read |
| pxb.benefits.create(params) | Create a benefit | hr:write |
| pxb.benefits.update(benefitId, params?) | Update a benefit | hr:write |
| pxb.benefits.delete(benefitId) | Delete a benefit | hr:write |
| pxb.blogPosts.list(params) | List blog posts | blog:read |
| pxb.blogPosts.get(postId) | Get a blog post | blog:read |
| pxb.blogPosts.create(params) | Create a blog post | blog:write |
| pxb.blogPosts.update(postId, params?) | Update a blog post | blog:write |
| pxb.blogPosts.delete(postId) | Delete a blog post | blog:write |
| pxb.buildDeployments.list() | List recent deployments | builder:engineer |
| pxb.builderUsage.get() | Get Builder usage | builder:read |
| pxb.buildSessions.list(params?) | List build sessions | builder:read |
| pxb.buildSessions.get(sessionId) | Get a build session | builder:read |
| pxb.buildSessions.create(params) | Start a build session | builder:write |
| pxb.buildSessions.delete(sessionId) | Delete a build session | builder:engineer |
| pxb.buildSessions.messages(sessionId, params?) | Read a session’s transcript | builder:read |
| pxb.buildSessions.message(sessionId, params) | Message the agent | builder:write |
| pxb.buildSessions.interrupt(sessionId) | Stop the agent | builder:write |
| pxb.buildSessions.retryStart(sessionId) | Retry starting the agent | builder:write |
| pxb.buildSessions.archive(sessionId) | Archive a build session | builder:write |
| pxb.buildSessions.reopen(sessionId) | Reopen an archived session | builder:engineer |
| pxb.buildSessions.approvePlan(sessionId) | Approve the plan | builder:write |
| pxb.buildSessions.setAutoMode(sessionId, params) | Set auto mode | builder:write |
| pxb.calendarEvents.list(params?) | List calendar events | calendar:read |
| pxb.calendarEvents.get(eventId) | Get a calendar event | calendar:read |
| pxb.calendarEvents.create(params) | Create a calendar event | calendar:write |
| pxb.calendarEvents.update(eventId, params?) | Update a calendar event | calendar:write |
| pxb.calendarEvents.delete(eventId, params?) | Delete a calendar event | calendar:write |
| pxb.calendarEvents.rsvp(eventId, params) | Answer a calendar invitation | calendar:write |
| pxb.callScripts.list(params) | List call scripts | call-scripts:read |
| pxb.callScripts.get(scriptId) | Get a call script | call-scripts:read |
| pxb.callScripts.create(params) | Create a call script | call-scripts:write |
| pxb.callScripts.update(scriptId, params?) | Update a call script | call-scripts:write |
| pxb.callScripts.delete(scriptId) | Delete a call script | call-scripts:write |
| pxb.campaigns.list(params) | List campaigns | campaigns:read |
| pxb.campaigns.get(campaignId) | Get a campaign | campaigns:read |
| pxb.campaigns.create(params) | Create a campaign | campaigns:write |
| pxb.campaigns.update(campaignId, params?) | Update a campaign | campaigns:write |
| pxb.campaigns.delete(campaignId) | Delete a campaign | campaigns:write |
| pxb.campaigns.send(campaignId, params) | Send, pause or cancel a campaign | campaigns:write |
| pxb.companyChart.get() | Get the company chart | company-structure:read |
| pxb.companySettings.get() | Get company settings | settings:read |
| pxb.companySettings.update(params?) | Update company settings | settings:write |
| pxb.contactInquiries.create(params) | Send the Pixelbase team a request | inquiries:write |
| pxb.conversations.list(params?) | List conversations | threads:read |
| pxb.conversations.get(conversationId) | Get a conversation | threads:read |
| pxb.conversations.messages(conversationId, params?) | List messages in a conversation | threads:read |
| pxb.conversations.thread(conversationId, messageId) | Read a thread | threads:read |
| pxb.conversations.send(conversationId, params) | Send a message | threads:write |
| pxb.conversations.read(conversationId) | Mark a conversation read | threads:write |
| pxb.conversations.unread(conversationId) | Mark a conversation unread | threads:write |
| pxb.conversations.readThread(conversationId, messageId) | Mark a thread read | threads:write |
| pxb.customerCustomFields.list(params) | List customer custom fields | customer:custom-fields:read |
| pxb.customerCustomFields.create(params) | Create a customer custom field | customer:custom-fields:write |
| pxb.customerCustomFields.update(customFieldId, params?) | Update a customer custom field | customer:custom-fields:write |
| pxb.customerCustomFields.delete(customFieldId) | Delete a customer custom field | customer:custom-fields:write |
| pxb.customers.list(params) | List customers | customers:read |
| pxb.customers.get(accountId) | Get a customer | customers:read |
| pxb.customers.create(params) | Create a customer | customers:write |
| pxb.customers.update(accountId, params?) | Update a customer | customers:write |
| pxb.customers.customFields(accountId) | Get customer custom field values | customer:custom-fields:read |
| pxb.customers.setCustomFields(accountId, params) | Set customer custom field values | customer:custom-fields:write |
| pxb.deals.list(params) | List deals | deals:read |
| pxb.deals.get(dealId) | Get a deal | deals:read |
| pxb.deals.create(params) | Create a deal | deals:write |
| pxb.deals.update(dealId, params?) | Update a deal | deals:write |
| pxb.deals.delete(dealId) | Archive a deal | deals:write |
| pxb.deals.move(dealId, params) | Move a deal to another stage | deals:write |
| pxb.deals.close(dealId, params) | Win, lose or re-open a deal | deals:write |
| pxb.departments.list() | List departments | company-structure:read |
| pxb.departments.create(params) | Create a department | company-structure:write |
| pxb.departments.update(departmentId, params) | Update a department | company-structure:write |
| pxb.departments.delete(departmentId) | Delete a department | company-structure:write |
| pxb.domains.list(params?) | List domains | domains:read |
| pxb.domains.get(domainId) | Get a domain | domains:read |
| pxb.domains.create(params) | Buy a domain | domains:write |
| pxb.emailAddresses.list(params?) | List email addresses | email:addresses:read |
| pxb.emailAddresses.create(params) | Create an email address | email:addresses:write |
| pxb.emailAddresses.delete(emailAddressId) | Delete an email address | email:addresses:write |
| pxb.emailDrafts.list(params?) | List email drafts | email:messages:read |
| pxb.emailDrafts.get(draftId) | Get an email draft | email:messages:read |
| pxb.emailDrafts.create(params?) | Create an email draft | email:messages:write |
| pxb.emailDrafts.update(draftId, params?) | Update an email draft | email:messages:write |
| pxb.emailDrafts.delete(draftId) | Delete an email draft | email:messages:write |
| pxb.emailDrafts.send(draftId) | Send an email draft | email:messages:write |
| pxb.emailFolders.list() | List email folders and mailboxes | email:messages:read |
| pxb.emailFolders.create(params) | Create an email folder | email:messages:write |
| pxb.emails.list(params?) | List emails | email:messages:read |
| pxb.emails.get(emailId, params?) | Get an email | email:messages:read |
| pxb.emails.create(params) | Send an email | email:messages:write |
| pxb.emails.update(emailId, params?) | Update an email | email:messages:write |
| pxb.emailThreads.get(threadId, params?) | Get an email thread | email:messages:read |
| pxb.employeeInvitations.list(params?) | List employee invitations | employee:invitations:read |
| pxb.employeeInvitations.create(params) | Invite an employee | employee:invitations:write |
| pxb.employeeInvitations.delete(invitationId) | Revoke an invitation | employee:invitations:write |
| pxb.employeeOnboardings.list(params?) | List employees in onboarding | employee:onboardings:read |
| pxb.employeeOnboardings.get(employeeId) | Get an onboarding employee | employee:onboardings:read |
| pxb.employees.list(params?) | List employees | employees:read |
| pxb.galleryPhotos.list(params) | List gallery photos | gallery:read |
| pxb.galleryPhotos.delete(photoId) | Delete a gallery photo | gallery:write |
| pxb.invoices.list(params?) | List invoices | invoices:read |
| pxb.invoices.get(invoiceId) | Get an invoice | invoices:read |
| pxb.invoices.create(params) | Create an invoice | invoices:write |
| pxb.invoices.delete(invoiceId) | Delete an invoice | invoices:write |
| pxb.invoices.void(invoiceId) | Void an invoice | invoices:write |
| pxb.invoices.sendEmail(invoiceId) | Email an invoice | invoices:write |
| pxb.ipWhitelistEntries.list() | List IP whitelist | security:read |
| pxb.ipWhitelistEntries.create(params) | Add IP to whitelist | security:write |
| pxb.ipWhitelistEntries.delete(id) | Remove IP from whitelist | security:write |
| pxb.jobTitles.list(params?) | List job titles | company-structure:read |
| pxb.jobTitles.create(params) | Create a job title | company-structure:write |
| pxb.jobTitles.update(jobTitleId, params?) | Update a job title | company-structure:write |
| pxb.jobTitles.delete(jobTitleId) | Delete a job title | company-structure:write |
| pxb.leads.list(params) | List leads | leads:read |
| pxb.leads.get(leadId) | Get a lead | leads:read |
| pxb.leads.create(params) | Create a lead | leads:write |
| pxb.leads.update(leadId, params?) | Update a lead | leads:write |
| pxb.leads.delete(leadId) | Delete a lead | leads:write |
| pxb.leads.convert(leadId) | Convert a lead to a customer | leads:write |
| pxb.legalEntities.list(params?) | List legal entities | settings:read |
| pxb.legalEntities.get(legalEntityId) | Get a legal entity | settings:read |
| pxb.legalEntities.create(params) | Create a legal entity | settings:write |
| pxb.legalEntities.amend(legalEntityId, params) | File an amendment | settings:write |
| pxb.locationHours.list(params) | Get location hours | location:hours:read |
| pxb.locationHours.set(params) | Update location hours | location:hours:write |
| pxb.locations.list(params?) | List locations | locations:read |
| pxb.locations.get(locationId) | Get a location | locations:read |
| pxb.locations.create(params) | Create a location | locations:write |
| pxb.locations.update(locationId, params?) | Update a location | locations:write |
| pxb.locations.archive(locationId) | Archive a location | locations:admin |
| pxb.meetingRecordings.list(params?) | List meeting recordings | meetings:read |
| pxb.meetingRooms.list(params?) | List meeting rooms | meetings:read |
| pxb.meetingRooms.get(roomId) | Get a meeting room | meetings:read |
| pxb.meetingRooms.create(params) | Create a meeting room | meetings:write |
| pxb.meetingRooms.update(roomId, params?) | Update a meeting room | meetings:write |
| pxb.meetingRooms.delete(roomId) | Delete a meeting room | meetings:write |
| pxb.milestones.list(params?) | List milestones | projects:read |
| pxb.milestones.get(milestoneId) | Get a milestone | projects:read |
| pxb.milestones.create(params) | Create a milestone | projects:write |
| pxb.milestones.update(milestoneId, params?) | Update a milestone | projects:write |
| pxb.milestones.delete(milestoneId) | Delete a milestone | projects:admin |
| pxb.newsletterSubscriptions.list(params) | List newsletter subscriptions | newsletter:subscriptions:read |
| pxb.newsletterSubscriptions.delete(subscriptionId) | Remove a newsletter subscription | newsletter:subscriptions:write |
| pxb.notificationPreferences.get() | Get notification preferences | notifications:read |
| pxb.notificationPreferences.update(params?) | Update notification preferences | notifications:write |
| pxb.notifications.list(params?) | List notifications | notifications:read |
| pxb.notifications.handle(notificationId) | Mark notification as handled | notifications:write |
| pxb.orders.list(params) | List orders | orders:read |
| pxb.orders.get(orderId) | Get an order | orders:read |
| pxb.payables.list(params?) | List payables | payables:read |
| pxb.paymentMethods.list() | List payment methods | billing:read |
| pxb.paymentMethods.setDefault(params) | Set default payment method | billing:write |
| pxb.payouts.list(params) | List payouts | payouts:read |
| pxb.payouts.create(params) | Create a payout | payouts:write |
| pxb.performanceReviews.list(params?) | List performance reviews | hr:read |
| pxb.performanceReviews.get(reviewId) | Get a performance review | hr:read |
| pxb.performanceReviews.create(params) | Write a performance review | hr:write |
| pxb.pipeline.get(params) | Get a location’s pipeline | deals:read |
| pxb.products.list(params) | List products | products:read |
| pxb.products.get(productId) | Get a product | products:read |
| pxb.products.create(params) | Create a product | products:write |
| pxb.products.update(productId, params?) | Update a product | products:write |
| pxb.products.delete(productId) | Delete a product | products:write |
| pxb.projectLabels.list(params?) | List project labels | projects:read |
| pxb.projectLabels.create(params) | Create a project label | projects:admin |
| pxb.projectLabels.delete(labelId) | Delete a project label | projects:admin |
| pxb.projects.list(params?) | List projects | projects:read |
| pxb.projects.get(projectId) | Get a project | projects:read |
| pxb.projects.create(params) | Create a project | projects:admin |
| pxb.projects.update(projectId, params?) | Update a project | projects:admin |
| pxb.projects.delete(projectId) | Delete a project | projects:admin |
| pxb.qaChecks.list(params) | List QA line checks | quality:checks:read |
| pxb.qaChecks.create(params) | Record a QA line check | quality:checks:write |
| pxb.qaCorrectiveActions.list(params) | List QA corrective actions | quality:actions:read |
| pxb.qaCorrectiveActions.create(params) | Open or update a corrective action | quality:actions:write |
| pxb.qaShiftSessions.list(params) | List QA shift sessions | quality:checks:read |
| pxb.qaSpecs.list(params) | List QA product specs | quality:specs:read |
| pxb.qaSpecs.create(params) | Create or update a QA product spec | quality:specs:write |
| pxb.shifts.list(params?) | List shifts | schedule:read |
| pxb.shifts.get(shiftId) | Get a shift | schedule:read |
| pxb.shifts.create(params) | Create a shift | schedule:write |
| pxb.shifts.update(shiftId, params?) | Update a shift | schedule:write |
| pxb.shifts.delete(shiftId) | Delete a shift | schedule:write |
| pxb.sso.get() | Get the SSO configuration | sso:read |
| pxb.supportConversations.list(params?) | List support conversations | internal:support:read |
| pxb.supportConversations.get(conversationId) | Get a support conversation | internal:support:read |
| pxb.taxFilings.list(params?) | List tax filings | taxes:read |
| pxb.taxFilings.get(filingId) | Get a tax filing | taxes:read |
| pxb.taxFilings.update(filingId, params) | Update a tax filing | taxes:write |
| pxb.taxLiability.get(params) | Get tax liability | taxes:read |
| pxb.tickets.list(params?) | List tickets | projects:read |
| pxb.tickets.get(ticketId) | Get a ticket | projects:read |
| pxb.tickets.create(params) | Create a ticket | projects:write |
| pxb.tickets.update(ticketId, params?) | Update a ticket | projects:write |
| pxb.tickets.delete(ticketId) | Delete a ticket | projects:admin |
| pxb.tickets.comments(ticketId) | List comments on a ticket | projects:read |
| pxb.tickets.comment(ticketId, params) | Comment on a ticket | projects:write |
| pxb.timeClockEntries.list(params?) | List time clock entries | hr:read |
| pxb.timeClockEntries.create() | Clock in | hr:write |
| pxb.timeClockEntries.clockOut(entryId) | Clock out | hr:write |
| pxb.timeOffRequests.list(params?) | List time-off requests | hr:read |
| pxb.timeOffRequests.get(requestId) | Get a time-off request | hr:read |
| pxb.timeOffRequests.create(params) | Request time off | hr:write |
| pxb.timeOffRequests.review(requestId, params) | Approve or deny time off | hr:write |
| pxb.timeOffRequests.cancel(requestId) | Withdraw a time-off request | hr:write |
| pxb.transactions.list(params?) | List transactions | transactions:read |
| pxb.transactions.get(transactionId) | Get a transaction | transactions:read |
| pxb.transactions.create(params) | Record a transaction | transactions:write |
| pxb.transactions.update(transactionId, params?) | Update a transaction | transactions:write |
| pxb.transactions.delete(transactionId) | Void a transaction | transactions:admin |
| pxb.transactions.markPaid(transactionId, params?) | Mark a transaction paid | transactions:write |
| pxb.unreadThreads.list() | List unread threads | threads:read |
| pxb.usage.get() | Get the usage report | usage:read |
| pxb.vaultCredentials.list(params?) | List Vault credentials | vault:admin |
| pxb.vaultCredentials.get(credentialId) | Reveal a Vault credential | vault:admin |
| pxb.vaultDocuments.list(params?) | List Vault documents | vault:admin |
| pxb.vaultDocuments.get(documentId) | Get a Vault document | vault:admin |
| pxb.vaultDocuments.create(params) | Create a Vault document or folder | vault:admin |
| pxb.vaultDocuments.update(documentId, params?) | Update a Vault document | vault:admin |
| pxb.vaultDocuments.delete(documentId, params?) | Archive or delete a Vault document | vault:admin |
| pxb.vaultDocuments.download(documentId) | Get a download URL | vault:admin |
| pxb.vaultFolders.list() | List Vault folders | vault: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
ida 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:writecannot write products through it either.