Skip to main content
Docs/Node.js SDK/Quickstart
SDK Reference

Quickstart

Get your first API call working in under 5 minutes.

1. Install

bash

npm install staffify

2. Get your API key

Open console.staffifyai.com, navigate to your project, and go to API Keys. Keys start with sfy_live_. Store the key in an environment variable — never hardcode it in your source.

3. Initialize the client

TypeScript

import Staffify from 'staffify';

const client = new Staffify({
  apiKey: process.env.STAFFIFY_API_KEY,
});

CommonJS also works: const { Staffify } = require('staffify');

4. Make your first call

TypeScript

// Check your account health
const { data } = await client.health();
console.log(data.status); // "ok"
console.log(data.tier);   // "payg"

// List your agents
const { data: agentsData } = await client.agents.list();
console.log(agentsData.agents);

5. Handle errors

TypeScript

import { StaffifyAuthError, StaffifyRateLimitError, StaffifyError } from 'staffify';

try {
  const { data } = await client.agents.get('agent_doesnotexist');
} catch (err) {
  if (err instanceof StaffifyAuthError) {
    console.error('Invalid API key');
  } else if (err instanceof StaffifyRateLimitError) {
    console.error('Rate limited, resets at:', err.resetAt);
  } else if (err instanceof StaffifyError) {
    console.error(err.status, err.code, err.message);
  }
}

Next steps

Quickstart - Node.js SDK - Staffify