JavaScript / TypeScript SDK

Zero-dependency SDK for Node.js, Deno, Bun, and browsers. Uses native fetch. TypeScript-first with full type exports.

Installation

bash
npm install @stack/sdk

Quick Start

typescript
import { Stack } from '@stack/sdk';

const stack = new Stack({ apiKey: 'sk_live_...' });

// Register an agent
const agent = await stack.agents.register({ name: 'my-agent' });

// Issue a passport
const passport = await stack.passports.issue({
  agent_id: agent.id,
  scopes: ['read', 'write'],
  intent_description: 'Process invoices',
  intent_services: ['slack', 'stripe'],
});

// Retrieve credentials
const cred = await stack.credentials.get('slack');

Services

stack.agents

typescript
stack.agents.register({ name, description?, credential_access? })
stack.agents.list()
stack.agents.get(id)
stack.agents.update(id, { name?, status?, credential_access? })
stack.agents.delete(id)
stack.agents.unblock(id)

stack.passports

typescript
stack.passports.issue({ agent_id, scopes?, ttl_seconds?, ... })
stack.passports.verify(token, serviceId?)
stack.passports.revoke(jti, reason?)
stack.passports.delegate({ parent_token, child_agent_id, ... })
stack.passports.refresh(token, ttlSeconds?)
stack.passports.listActive({ agentId?, sessionId? })
stack.passports.revokeAgent(agentId, reason?)
stack.passports.revokeAll(reason?)
stack.passports.checkpoint(jti, input)
stack.passports.checkout(jti, input)

stack.skills

typescript
// Publishing
stack.skills.publish({ name, description, input_schema, output_schema, ... })
stack.skills.get(id)
stack.skills.browse({ query?, tags?, trust_level? })
stack.skills.listOwned()
stack.skills.update(id, updates)
stack.skills.suspend(id)
stack.skills.activate(id)

// Invocations
stack.skills.invoke(skillId, { agent_id, input, passport_claims? })
stack.skills.getInvocation(invocationId)
stack.skills.poll(invocationId, { intervalMs?, timeoutMs? })
stack.skills.listInvocations()

// Requests
stack.skills.postRequest({ description, max_price_credits?, tags? })
stack.skills.listRequests({ status?, limit? })
stack.skills.suggestComposition(requestId)

stack.identity

typescript
stack.identity.listProviders()
stack.identity.initiateVerification({ provider_key, return_url? })
stack.identity.completeVerification(providerKey, sessionRef)
stack.identity.listClaims()
stack.identity.revokeClaim(id)
stack.identity.grantDelegation(scopes)

Other Services

typescript
stack.services.listAvailable()
stack.services.listConnected()
stack.services.connect({ service_id, provider, credential })
stack.services.connectCustom({ name, credential })
stack.services.disconnect(connectionId)

stack.credentials.get(provider)
stack.credentials.getByConnection(connectionId)

stack.dropoffs.create({ from_agent, to_agent, schema })
stack.dropoffs.deposit(id, agentId, payload)
stack.dropoffs.collect(id, agentId)

stack.team.invite({ email, name?, role? })
stack.team.list()
stack.team.update(id, { role?, allowed_connections? })
stack.team.revoke(id)

stack.notifications.create({ channel_type, destination, events? })
stack.notifications.list()
stack.notifications.verify(id, code)
stack.notifications.test(id)

stack.securityEvents.list({ agentId?, page?, limit? })
stack.securityEvents.resolve(id)

stack.proxy.request({ provider, method, url, headers?, body? })

Error Handling

typescript
import { Stack, StackError, NotFoundError } from '@stack/sdk';

try {
  const agent = await stack.agents.get('agt_nonexistent');
} catch (err) {
  if (err instanceof NotFoundError) {
    console.log('Agent not found');
  } else if (err instanceof StackError) {
    console.log(err.code, err.status, err.message);
  }
}
STACK — Infrastructure for AI Agents