@esperient/sdk

JavaScript SDK

The official Esperient SDK for JavaScript and TypeScript. Build integrations with full type safety.

npm install @esperient/sdk

TypeScript Native

Full type definitions included. Autocomplete everything.

15KB Gzipped

Lightweight with zero dependencies.

Tree Shakeable

Import only what you use.

Quick Examples

Initialize the Client
import { Esperient } from '@esperient/sdk'

const esperient = new Esperient({
  apiKey: process.env.ESPERIENT_API_KEY
})
Create a Workflow
const workflow = await esperient.workflows.create({
  name: 'New Lead Notification',
  trigger: {
    app: 'hubspot',
    event: 'contact.created'
  },
  actions: [
    { app: 'slack', action: 'send_message', channel: '#sales' },
    { app: 'notion', action: 'create_page', database: 'leads' }
  ]
})

console.log('Workflow created:', workflow.id)
List Connections
const connections = await esperient.connections.list()

connections.forEach(conn => {
  console.log(`${conn.app}: ${conn.status}`)
})
Handle Webhooks
import { esperient } from '@esperient/sdk'

// In your webhook handler
export async function POST(req: Request) {
  const payload = await req.json()
  const signature = req.headers.get('x-esperient-signature')
  
  const event = esperient.webhooks.verify(payload, signature)
  
  if (event.type === 'workflow.completed') {
    console.log('Workflow completed:', event.data.workflow_id)
  }
  
  return new Response('OK')
}