@hoststack.dev/sdk
Infrastructure-as-TypeScript
The official HostStack SDK turns the platform into something you can script. Wire deploys into your CI, spin up preview environments from a chatbot, or drive the whole dashboard from a Node process — with proper types, proper errors, and zero surprises.
Quick start
Install
npm install @hoststack.dev/sdktypescript
import { HostStack } from '@hoststack.dev/sdk';
const client = new HostStack({
apiKey: process.env.HOSTSTACK_API_KEY!,
});
const teamId = 'team_abc123'; // or numeric id from `hoststack whoami`
// Deploy a service
const { deploy } = await client.deploys.trigger(teamId, 'svc_abc123');
console.log(deploy.status); // 'pending' | 'building' | 'live' | ...
// List all services
const { services } = await client.services.list(teamId);
for (const svc of services) {
console.log(svc.name, svc.status);
}End-to-end typed — every response shape is inferred from the API
Typed error hierarchy (NotFoundError, RateLimitError, AuthenticationError, ...)
Zero runtime dependencies beyond the platform fetch
Runs in Node.js 18+, Bun, Deno, Cloudflare Workers, and the browser
Offset/limit pagination helpers + a streamLogs async iterator for live tails
Accepts numeric ids or human-friendly publicIds (svc_…, dpl_…) and resolves transparently
Available resources
client.projects
list
get
create
update
delete
client.services
list
get
create
update
delete
resize
listDevEnvironments
createDevEnvironment
spinUpDevEnvironment
tearDownDevEnvironment
suspend
resume
getMetrics
getMetricsHistory
getConfig
updateConfig
getRuntimeLogs
streamLogs
client.deploys
list
get
trigger
cancel
rollback
promote
getLogs
client.databases
list
get
create
update
delete
suspend
resume
restart
getCredentials
resetPassword
query
upgradeToHa
upgradeVersion
getCluster
client.domains
list
add
update
remove
verify
client.envVars
list
create
update
delete
bulkSet
client.environments
list
get
create
update
delete
client.cron
list
get
trigger
client.volumes
list
create
update
delete
client.machines
list
get
client.notifications
listChannels
createChannel
updateChannel
deleteChannel
testChannel
client.errors
listIssues
getIssue
listOccurrences
updateIssue
fixInDevBox
listIngestKeys
createIngestKey
deleteIngestKey
client.analytics
listSites
createSite
updateSite
siteStatus
rotateKey
deleteSite
verifyDomain
getDomainProof
summary
overview
realtime
eventMetadata
client.uptime
get
upsert
remove
getForSite
upsertForSite
removeForSite
client.devTasks
list
counts
get
create
update
delete
client.teams
list
client.dns
listZones
createZone
deleteZone
listRecords
createRecord
updateRecord
deleteRecord
resyncRecord
client.serviceResourceLinks
listManagedResources
list
create
updateAlias
delete
Real-world example
typescript
import { HostStack, NotFoundError } from '@hoststack.dev/sdk';
const client = new HostStack({ apiKey: process.env.HOSTSTACK_API_KEY! });
const teamId = 'team_abc123';
// Set environment variables and deploy
await client.envVars.bulkSet(teamId, 'svc_abc123', {
vars: [
{ key: 'NODE_ENV', value: 'production', target: 'both' },
{ key: 'DATABASE_URL', value: process.env.DATABASE_URL!, target: 'runtime', isSecret: true },
],
});
const { deploy } = await client.deploys.trigger(teamId, 'svc_abc123');
// Read build logs
const { logs } = await client.deploys.getLogs(teamId, 'svc_abc123', deploy.publicId);
for (const line of logs) {
console.log(`[${line.level}] ${line.message}`);
}
// Error handling
try {
await client.services.get(teamId, 'svc_invalid');
} catch (error) {
if (error instanceof NotFoundError) {
console.log('Service not found');
}
}From npm install to first deploy in a minute
Generate an API key, drop it into your process env, and automate everything you used to click through by hand.