Official Node.js/TypeScript SDK for the Volley API. This SDK provides a convenient way to interact with the Volley webhook infrastructure API.
Volley is a webhook infrastructure platform that provides reliable webhook delivery, rate limiting, retries, monitoring, and more.
- Documentation: https://docs.volleyhooks.com
- Getting Started Guide: https://docs.volleyhooks.com/getting-started
- API Reference: https://docs.volleyhooks.com/api
- Authentication Guide: https://docs.volleyhooks.com/authentication
- Security Guide: https://docs.volleyhooks.com/security
- Console: https://app.volleyhooks.com
- Website: https://volleyhooks.com
npm install @volleyhq/volley-nodeor with yarn:
yarn add @volleyhq/volley-nodeimport { VolleyClient } from '@volleyhq/volley-node';
// Create a client with your API token
const client = new VolleyClient('your-api-token');
// Optionally set organization context
client.setOrganizationId(123);
// List organizations
const orgs = await client.organizations.list();
for (const org of orgs) {
console.log(`Organization: ${org.name} (ID: ${org.id})`);
}Volley uses API tokens for authentication. These are long-lived tokens designed for programmatic access.
- Log in to the Volley Console
- Navigate to Settings → Account → API Token
- Click View Token (you may need to verify your password)
- Copy the token and store it securely
Important: API tokens are non-expiring and provide full access to your account. Keep them secure and rotate them if compromised. See the Security Guide for best practices.
const client = new VolleyClient('your-api-token');For more details on authentication, API tokens, and security, see the Authentication Guide and Security Guide.
When you have multiple organizations, you need to specify which organization context to use for API requests. The API verifies that resources (like projects) belong to the specified organization.
You can set the organization context in two ways:
// Method 1: Set organization ID for all subsequent requests
client.setOrganizationId(123);
// Method 2: Create client with organization ID
const client = new VolleyClient('your-api-token', {
organizationId: 123,
});
// Clear organization context (uses first accessible organization)
client.clearOrganizationId();Note: If you don't set an organization ID, the API uses your first accessible organization by default. For more details, see the API Reference - Organization Context.
// List all organizations
const orgs = await client.organizations.list();
// Get current organization
const org = await client.organizations.get(); // undefined = use default
// Create organization
const newOrg = await client.organizations.create({
name: 'My Organization',
});// List projects
const projects = await client.projects.list();
// Create project
const project = await client.projects.create({
name: 'My Project',
is_default: false,
});
// Update project
const updated = await client.projects.update(project.id, {
name: 'Updated Name',
});
// Delete project
await client.projects.delete(project.id);// List sources in a project
const sources = await client.sources.list(projectId);
// Create source
const source = await client.sources.create(projectId, {
name: 'Stripe Webhooks',
eps: 10,
auth_type: 'none',
});
// Get source details
const source = await client.sources.get(sourceId);
// Update source
const updated = await client.sources.update(sourceId, {
name: 'Updated Source Name',
eps: 20,
auth_type: 'none',
});// List destinations
const destinations = await client.destinations.list(projectId);
// Create destination
const dest = await client.destinations.create(projectId, {
name: 'Production Endpoint',
url: 'https://api.example.com/webhooks',
eps: 5,
});// List connections
const connections = await client.projects.getConnections(projectId);
// Create connection
const conn = await client.connections.create(projectId, {
source_id: sourceId,
destination_id: destId,
status: 'enabled',
eps: 5,
max_retries: 3,
});// List events with filters
const events = await client.events.list(projectId, {
status: 'failed',
source_id: sourceId,
limit: 50,
offset: 0,
});
// Get event details
const event = await client.events.get(requestId);
// Replay failed event
const result = await client.events.replay({
event_id: 'evt_abc123def456',
});// List delivery attempts
const attempts = await client.deliveryAttempts.list(projectId, {
event_id: 'evt_abc123',
status: 'failed',
limit: 50,
});// Send a webhook to a source
const eventId = await client.webhooks.send('source_ingestion_id', {
event: 'user.created',
data: {
user_id: '123',
email: 'user@example.com',
},
});The SDK throws VolleyException for API errors:
import { VolleyException } from '@volleyhq/volley-node';
try {
const org = await client.organizations.get(orgId);
} catch (error) {
if (error instanceof VolleyException) {
if (error.isUnauthorized()) {
console.error('Authentication failed');
} else if (error.isNotFound()) {
console.error('Organization not found');
} else {
console.error(`API Error: ${error.message} (Status: ${error.statusCode})`);
}
} else {
console.error('Error:', error);
}
}200- Success201- Created202- Accepted (webhook queued)400- Bad Request (validation error)401- Unauthorized (invalid or missing API token)403- Forbidden (insufficient permissions)404- Not Found429- Rate Limit Exceeded500- Internal Server Error
For more details on error responses, see the API Reference - Response Codes.
You can configure the client with various options:
// Custom base URL (for testing)
const client = new VolleyClient('token', {
baseUrl: 'https://api-staging.volleyhooks.com',
});
// Custom timeout
const client = new VolleyClient('token', {
timeout: 60000, // 60 seconds
});
// Custom HTTP client (Axios instance)
import axios from 'axios';
const customHttpClient = axios.create({
timeout: 60000,
// ... other axios config
});
const client = new VolleyClient('token', {
httpClient: customHttpClient,
});The SDK is written in TypeScript and includes full type definitions. All types are exported:
import {
VolleyClient,
Organization,
Project,
Source,
Event,
// ... other types
} from '@volleyhq/volley-node';- Getting Started - Set up your account and create your first webhook
- How It Works - Understand Volley's architecture
- Webhooks Guide - Learn about webhook best practices and signature verification
- Rate Limiting - Configure rate limits for your webhooks
- Monitoring - Monitor webhook delivery and performance
- Best Practices - Webhook development best practices
- FAQ - Frequently asked questions
- Stripe Webhook Localhost Testing
- Retrying Failed Webhooks
- Webhook Event Replay
- Webhook Fan-out
- Multi-Tenant Webhooks
The SDK includes comprehensive unit tests and integration tests.
Unit tests use a mock HTTP server (nock) and don't require API credentials:
npm testTo run tests in watch mode:
npm test -- --watchIntegration tests make real API calls to the Volley API. You'll need to set your API token:
export VOLLEY_API_TOKEN="your-api-token"
npm test -- --testPathPattern=integrationNote: Integration tests are skipped if VOLLEY_API_TOKEN is not set.
To see test coverage:
npm test -- --coverage- Documentation: https://docs.volleyhooks.com
- Console: https://app.volleyhooks.com
- Website: https://volleyhooks.com
Contributions are welcome! Please feel free to submit a Pull Request.
When contributing:
- Add tests for new functionality
- Ensure all tests pass (
npm test) - Update documentation as needed
MIT License - see LICENSE file for details.