@front-of-house/sdk
v0.1.0
Published
Front Of House Partner SDK — typed API client for leads, conversations, agents, webhooks, and reporting
Readme
@front-of-house/sdk
TypeScript SDK for the Front Of House Partner API.
- Typed client for agents, channels, leads, conversations, webhooks, org, and reporting.
- Auth helper for exchanging email/password into a service token.
- Idempotency-key helper for safe retry behavior on mutations.
Install
npm install @front-of-house/sdkQuick Start
import { FohClient, getServiceToken } from '@front-of-house/sdk'
const { token } = await getServiceToken(
process.env.FOH_EMAIL!,
process.env.FOH_PASSWORD!,
)
const client = new FohClient({
token,
orgId: process.env.FOH_ORG_ID!,
})
const { agents } = await client.agents.list()
console.log(agents.map((agent) => agent.name))Auth and Org Scoping
Every request is sent with:
Authorization: Bearer <token>x-org-id: <org-uuid>whenorgIdis set inFohClient
You can switch org context without re-authenticating:
const orgA = new FohClient({ token, orgId: 'org-a-uuid' })
const orgB = orgA.withOrg('org-b-uuid')Resource Surface
client.agentscreate,list,get,getDraft,patchDraft,validate,publish,readiness
client.channelsensureWidgetconnectWhatsApp,getWhatsAppStatus,verifyWhatsApp,testWhatsAppconnectInstagram,getInstagramStatus,verifyInstagram,testInstagram
client.voicecatalog,voiceCatalog,preview,realtimeHealthverify,reward,optimize,scorecard
client.toolslist,testConnection,enable,disable
client.knowledgelist,create,delete,reindex
client.leadshandoff,updateExtraction
client.conversationsreply,submitFeedback,getFeedback
client.webhooksregister,list,delete,deliveries,observability
client.orglistMine,create,onboarding,listMembers,invite
client.reportinglistTraces
Idempotency
Use an idempotency key for retry-safe mutation requests:
import { generateIdempotencyKey } from '@front-of-house/sdk'
const key = generateIdempotencyKey('publish')
// Publish is fail-closed unless the current draft has a fresh passing
// simulation certificate. Run `foh sim certify-loop --agent agent-uuid --full`
// before calling publish from SDK-first automation.
await client.agents.publish('agent-uuid', {}, key)Most mutating SDK methods accept idempotencyKey as the final argument.
Error Handling
The client throws FohApiError for non-2xx responses:
import { FohApiError } from '@front-of-house/sdk'
try {
await client.agents.list()
} catch (err) {
if (err instanceof FohApiError) {
console.error(err.status, err.message, err.detail, err.remediation)
}
}OpenAPI Contract Metadata
This package exports generated OpenAPI metadata used by CI drift checks:
PARTNER_OPENAPI_VERSIONPARTNER_OPENAPI_OPERATIONSPARTNER_OPENAPI_OPERATION_PATHPARTNER_OPENAPI_OPERATION_METHODPARTNER_OPENAPI_IDEMPOTENT_OPERATION_IDS
Security Model
- This SDK is for calling FOH Partner API endpoints from trusted server-side code.
- Do not expose service tokens in browser code.
- For FOH -> your tool endpoint authenticity verification, use
@front-of-house/tool-sdk(createToolAuthMiddleware/verifyToolRequest). - For FOH outbound webhooks, verify
X-FOH-Signature-V2with canonical${x-foh-timestamp}.${rawBody}and enforce a replay window (recommended300s). X-FOH-Signatureremains available as a legacy compatibility header during receiver migration.
See:
Docs/PARTNER_QUICKSTART.mdDocs/PARTNER_API_VERSIONING.mdexamples/booking-tool/README.mdpackages/sdk-ts/examples/channel-onboarding-dry-run.ts
