Puchify

TypeScript SDK

Full reference for @puchify/sdk — typed, async, production-ready.

Package: @puchify/sdk

npm install @puchify/sdk

Quick start

import { Puchify } from "@puchify/sdk"

const puchify = new Puchify({
  apiKey: process.env.PUCHIFY_API_KEY,
})

Resources

Servers

// List
const { data: servers } = await puchify.servers.list({ status: "running" })
const { data: page } = await puchify.servers.list({ cursor: "abc", limit: 100 })

// Paginate all pages
for await (const s of puchify.servers.listAll({ status: "running" })) {
  console.log(s.name, s.ipv4)
}

// CRUD
const server = await puchify.servers.get("svr_123")
const created = await puchify.servers.create({ name: "web-01", plan: "shared-2", region: "us-east" })
await puchify.servers.update("svr_123", { name: "web-01-renamed" })
await puchify.servers.delete("svr_123")

// Actions
await puchify.servers.restart("svr_123")
await puchify.servers.destroy("svr_123")
await puchify.servers.reconcile("svr_123")

// Wait for state
const running = await puchify.servers.waitFor("svr_123", "running", {
  timeout: 300_000,
  pollInterval: 5_000,
})

GPU Servers

const gpus = await puchify.gpuServers.list()
await puchify.gpuServers.restart("gpu_123")
await puchify.gpuServers.destroy("gpu_123")

Data

const db = await puchify.data.create({ name: "my-db", engine: "postgres", plan: "starter", region: "us-east" })
const ready = await puchify.data.waitFor(db.id, "running")

Kubernetes

const cluster = await puchify.kubernetes.create({ name: "prod-cluster", region: "us-east" })

Jobs

const job = await puchify.jobs.run({ name: "build", command: "npm run build" })
await puchify.jobs.cancel(job.id)

Object Storage

const bucket = await puchify.objectStorage.create({ name: "assets", region: "us-east", public: true })

File Storage

const share = await puchify.fileStorage.create({ name: "data", region: "us-east", size_gb: 500 })

Load Balancers

await puchify.loadBalancers.attach("lb_1", "svr_1")
await puchify.loadBalancers.detach("lb_1", "svr_1")

Backups

const backup = await puchify.backups.create({ name: "nightly", server_id: "svr_1" })
await puchify.backups.restore(backup.id)
await puchify.backups.waitFor(backup.id, "available")

Observability

const metrics = await puchify.observability.listMetrics()
const alerts = await puchify.observability.listAlerts()
const incidents = await puchify.observability.listIncidents()

Logs

const logs = await puchify.logs.list({ resource_id: "svr_1", limit: 100 })

Usage

const summary = await puchify.usage.summary()

Settings & API Keys

const profile = await puchify.settings.getProfile()
const team = await puchify.settings.getTeam()
const key = await puchify.settings.createApiKey("my-key")

Terminal

const session = await puchify.terminal.createSession("svr_1")

Agent

const thread = await puchify.agent.createThread("Debug server")
const messages = await puchify.agent.listMessages(thread.id)

Webhooks

const wh = await puchify.webhooks.create({ url: "https://myapp.com/hooks", events: ["server.created"] })
await puchify.webhooks.update("wh_1", { active: false })
await puchify.webhooks.retryDelivery("wh_1", "del_1")

Error handling

import { Puchify, NotFoundError, AuthError, RateLimitError } from "@puchify/sdk"

try {
  await puchify.servers.get("nonexistent")
} catch (err) {
  if (err instanceof Puchify.NotFoundError) { /* 404 */ }
  if (err instanceof Puchify.AuthError)     { /* 401 */ }
  if (err instanceof Puchify.RateLimitError) { /* 429 */ }
  if (err instanceof Puchify.ValidationError) { /* 400 */ }
  if (err instanceof Puchify.PuchifyError)   { /* other */ }
}

Pagination

import { paginate, collectAll } from "@puchify/sdk"

// Manual pagination
const items = await collectAll(
  (cursor) => puchify.servers.list({ cursor, limit: 100 })
)

// Or use the built-in listAll generators
for await (const s of puchify.servers.listAll()) { /* ... */ }

Retry

import { withRetry } from "@puchify/sdk"

const result = await withRetry(
  () => puchify.servers.get("svr_1"),
  { maxAttempts: 5, baseDelay: 1000 }
)

Webhook verification

import { verifyWebhookSignature } from "@puchify/sdk"

const valid = verifyWebhookSignature(
  payload,                  // raw request body as string
  signatureHeader,          // X-Puchify-Signature header
  webhookSecret             // your webhook signing secret
)

AbortSignal

Every method accepts an optional AbortSignal:

const controller = new AbortController()
setTimeout(() => controller.abort(), 10_000)

const servers = await puchify.servers.list({}, controller.signal)

On this page