Neurana SDK
Official TypeScript/JavaScript SDK for the Neurana AI Workflow Automation Platform. Use it to build, deploy, and manage serverless workflows with strong typing, safe auth, and clear operational primitives.
Execute Serverless Workflows
Run complex automation pipelines with zero infrastructure management.
Secure Secret Management
Store and access sensitive credentials safely with encryption.
Code Management
Upload and version Python/Node.js code for workflow steps.
Full Observability
Monitor executions with real-time WebSocket updates.
API Key Management
Create scoped keys with granular permissions and rate limits.
Developer Experience
Full TypeScript support with exported types and intellisense.
Installation
Install the SDK using your preferred package manager:
1npm install @neurana/sdk1npm install @neurana/sdk1yarn add @neurana/sdk1yarn add @neurana/sdk1pnpm add @neurana/sdk1pnpm add @neurana/sdkQuick Start
Get up and running in minutes with this simple example:
1import { NeuranaClient } from '@neurana/sdk';
2
3const neurana = new NeuranaClient({
4 apiKey: process.env.NEURANA_API_KEY,
5});
6
7// List workflows
8const { data: workflows } = await neurana.workflows.list();
9
10// Trigger a workflow
11const { executionId } = await neurana.workflows.trigger('my-workflow', {
12 message: 'Hello from SDK!',
13});
14
15// Check execution status
16const status = await neurana.executions.getStatus(executionId);
17console.log(`Status: ${status.status}`);1import { NeuranaClient } from '@neurana/sdk';
2
3const neurana = new NeuranaClient({
4 apiKey: process.env.NEURANA_API_KEY,
5});
6
7// List workflows
8const { data: workflows } = await neurana.workflows.list();
9
10// Trigger a workflow
11const { executionId } = await neurana.workflows.trigger('my-workflow', {
12 message: 'Hello from SDK!',
13});
14
15// Check execution status
16const status = await neurana.executions.getStatus(executionId);
17console.log(`Status: ${status.status}`);Configuration
Configure the client with optional settings for custom endpoints and timeouts:
1const neurana = new NeuranaClient({
2 apiKey: 'your-api-key',
3
4 // Optional: Custom endpoints
5 baseUrl: 'https://workflows.neurana.io',
6 mainApiUrl: 'https://api.neurana.io',
7
8 // Optional: Request timeout (default: 30000ms)
9 timeout: 30000,
10
11 // Optional: Allow HTTP for local development
12 allowInsecureHttp: false,
13});1const neurana = new NeuranaClient({
2 apiKey: 'your-api-key',
3
4 // Optional: Custom endpoints
5 baseUrl: 'https://workflows.neurana.io',
6 mainApiUrl: 'https://api.neurana.io',
7
8 // Optional: Request timeout (default: 30000ms)
9 timeout: 30000,
10
11 // Optional: Allow HTTP for local development
12 allowInsecureHttp: false,
13});Workflows
Create, manage, and trigger workflows programmatically:
1// List all workflows
2const { data, pagination } = await neurana.workflows.list({ limit: 20 });
3
4// Get workflow by key
5const workflow = await neurana.workflows.get('workflow-key');1// List all workflows
2const { data, pagination } = await neurana.workflows.list({ limit: 20 });
3
4// Get workflow by key
5const workflow = await neurana.workflows.get('workflow-key');Executions
Monitor and inspect workflow executions:
1// Get execution status
2const status = await neurana.executions.getStatus('execution-id');
3
4// List all runs
5const { data: runs } = await neurana.executions.listRuns({ limit: 50 });
6
7// List runs for specific workflow
8const { data: workflowRuns } = await neurana.executions.listWorkflowRuns('workflow-key');
9
10// Test a step in isolation
11const result = await neurana.executions.testStep({
12 stepType: 'http',
13 stepConfig: {
14 url: 'https://api.example.com/data',
15 method: 'GET',
16 },
17});1// Get execution status
2const status = await neurana.executions.getStatus('execution-id');
3
4// List all runs
5const { data: runs } = await neurana.executions.listRuns({ limit: 50 });
6
7// List runs for specific workflow
8const { data: workflowRuns } = await neurana.executions.listWorkflowRuns('workflow-key');
9
10// Test a step in isolation
11const result = await neurana.executions.testStep({
12 stepType: 'http',
13 stepConfig: {
14 url: 'https://api.example.com/data',
15 method: 'GET',
16 },
17});Code Management
Upload and manage code files for your workflow steps:
1// Upload code file
2const file = await neurana.code.upload({
3 fileName: 'processor.py',
4 content: 'def handler(event, context): return event',
5 language: 'python',
6});
7
8// List code files
9const { data: files } = await neurana.code.list();
10
11// Get code file with download URL
12const code = await neurana.code.get('file-key');
13
14// Get version history
15const { data: history } = await neurana.code.getHistoryByKey('file-key');
16
17// Delete code file
18await neurana.code.delete('file-key');1// Upload code file
2const file = await neurana.code.upload({
3 fileName: 'processor.py',
4 content: 'def handler(event, context): return event',
5 language: 'python',
6});
7
8// List code files
9const { data: files } = await neurana.code.list();
10
11// Get code file with download URL
12const code = await neurana.code.get('file-key');
13
14// Get version history
15const { data: history } = await neurana.code.getHistoryByKey('file-key');
16
17// Delete code file
18await neurana.code.delete('file-key');Secrets
Securely store and manage sensitive credentials:
1// Create a secret
2await neurana.secrets.create({
3 name: 'OPENAI_API_KEY',
4 value: 'sk-...',
5});
6
7// List secrets (values hidden)
8const { data: secrets } = await neurana.secrets.list();
9
10// Get secret with value
11const secret = await neurana.secrets.get('OPENAI_API_KEY');
12
13// Update secret
14await neurana.secrets.update('OPENAI_API_KEY', { value: 'sk-new-value' });
15
16// Delete secret
17await neurana.secrets.delete('OPENAI_API_KEY');1// Create a secret
2await neurana.secrets.create({
3 name: 'OPENAI_API_KEY',
4 value: 'sk-...',
5});
6
7// List secrets (values hidden)
8const { data: secrets } = await neurana.secrets.list();
9
10// Get secret with value
11const secret = await neurana.secrets.get('OPENAI_API_KEY');
12
13// Update secret
14await neurana.secrets.update('OPENAI_API_KEY', { value: 'sk-new-value' });
15
16// Delete secret
17await neurana.secrets.delete('OPENAI_API_KEY');API Keys
Create and manage API keys with granular permissions:
1// Create API key with permissions
2const { apiKey } = await neurana.apiKeys.create({
3 name: 'Production Backend',
4 permissions: ['workflows:read', 'workflows:trigger', 'runs:read'],
5 expiresInDays: 90,
6 rateLimit: 10000,
7});
8
9// List API keys
10const { data: keys } = await neurana.apiKeys.list();
11
12// Rotate key (24h grace period)
13const { apiKey: newKey } = await neurana.apiKeys.rotate('key-id');
14
15// Revoke key immediately
16await neurana.apiKeys.revoke('key-id');
17
18// Get usage statistics
19const usage = await neurana.apiKeys.getUsage('key-id');1// Create API key with permissions
2const { apiKey } = await neurana.apiKeys.create({
3 name: 'Production Backend',
4 permissions: ['workflows:read', 'workflows:trigger', 'runs:read'],
5 expiresInDays: 90,
6 rateLimit: 10000,
7});
8
9// List API keys
10const { data: keys } = await neurana.apiKeys.list();
11
12// Rotate key (24h grace period)
13const { apiKey: newKey } = await neurana.apiKeys.rotate('key-id');
14
15// Revoke key immediately
16await neurana.apiKeys.revoke('key-id');
17
18// Get usage statistics
19const usage = await neurana.apiKeys.getUsage('key-id');Available Permissions
| Permission | Description |
|---|---|
workflows:read | View workflows |
workflows:write | Create/update workflows |
workflows:trigger | Execute workflows |
workflows:delete | Delete workflows |
code:read | View code files |
code:write | Upload code |
secrets:read | Access secrets |
runs:read | View execution history |
Error Handling
Handle errors gracefully with typed error classes:
1import {
2 NeuranaClient,
3 AuthenticationError,
4 ValidationError,
5 NotFoundError,
6 RateLimitError,
7 NeuranaError,
8} from '@neurana/sdk';
9
10try {
11 await neurana.workflows.trigger('my-workflow');
12} catch (error) {
13 if (error instanceof AuthenticationError) {
14 console.error('Invalid or expired API key');
15 } else if (error instanceof ValidationError) {
16 console.error('Invalid request:', error.message);
17 } else if (error instanceof NotFoundError) {
18 console.error('Workflow not found');
19 } else if (error instanceof RateLimitError) {
20 console.error(`Rate limited. Retry after ${error.retryAfter}s`);
21 } else if (error instanceof NeuranaError) {
22 console.error(`Error [${error.code}]: ${error.message}`);
23 }
24}1import {
2 NeuranaClient,
3 AuthenticationError,
4 ValidationError,
5 NotFoundError,
6 RateLimitError,
7 NeuranaError,
8} from '@neurana/sdk';
9
10try {
11 await neurana.workflows.trigger('my-workflow');
12} catch (error) {
13 if (error instanceof AuthenticationError) {
14 console.error('Invalid or expired API key');
15 } else if (error instanceof ValidationError) {
16 console.error('Invalid request:', error.message);
17 } else if (error instanceof NotFoundError) {
18 console.error('Workflow not found');
19 } else if (error instanceof RateLimitError) {
20 console.error(`Rate limited. Retry after ${error.retryAfter}s`);
21 } else if (error instanceof NeuranaError) {
22 console.error(`Error [${error.code}]: ${error.message}`);
23 }
24}TypeScript Support
Full TypeScript support with exported types:
1import type {
2 Workflow,
3 WorkflowStep,
4 ExecutionStatus,
5 ApiKey,
6 Secret,
7 CodeFile,
8 Run,
9 PaginatedResponse,
10} from '@neurana/sdk';1import type {
2 Workflow,
3 WorkflowStep,
4 ExecutionStatus,
5 ApiKey,
6 Secret,
7 CodeFile,
8 Run,
9 PaginatedResponse,
10} from '@neurana/sdk';Examples
Webhook Handler (Next.js)
1import { NeuranaClient } from '@neurana/sdk';
2
3const neurana = new NeuranaClient({
4 apiKey: process.env.NEURANA_API_KEY,
5});
6
7export async function POST(req: Request) {
8 const payload = await req.json();
9
10 const { executionId } = await neurana.workflows.trigger(
11 'process-webhook',
12 payload
13 );
14
15 return Response.json({ executionId });
16}1import { NeuranaClient } from '@neurana/sdk';
2
3const neurana = new NeuranaClient({
4 apiKey: process.env.NEURANA_API_KEY,
5});
6
7export async function POST(req: Request) {
8 const payload = await req.json();
9
10 const { executionId } = await neurana.workflows.trigger(
11 'process-webhook',
12 payload
13 );
14
15 return Response.json({ executionId });
16}Polling for Completion
1async function waitForCompletion(executionId: string, timeoutMs = 60000) {
2 const start = Date.now();
3
4 while (Date.now() - start < timeoutMs) {
5 const status = await neurana.executions.getStatus(executionId);
6
7 if (status.status === 'SUCCEEDED') return status.output;
8 if (status.status === 'FAILED') throw new Error(status.error);
9
10 await new Promise(r => setTimeout(r, 1000));
11 }
12
13 throw new Error('Execution timed out');
14}1async function waitForCompletion(executionId: string, timeoutMs = 60000) {
2 const start = Date.now();
3
4 while (Date.now() - start < timeoutMs) {
5 const status = await neurana.executions.getStatus(executionId);
6
7 if (status.status === 'SUCCEEDED') return status.output;
8 if (status.status === 'FAILED') throw new Error(status.error);
9
10 await new Promise(r => setTimeout(r, 1000));
11 }
12
13 throw new Error('Execution timed out');
14}Environment-Based Configuration
1const neurana = new NeuranaClient({
2 apiKey: process.env.NODE_ENV === 'production'
3 ? process.env.NEURANA_PROD_KEY
4 : process.env.NEURANA_DEV_KEY,
5});1const neurana = new NeuranaClient({
2 apiKey: process.env.NODE_ENV === 'production'
3 ? process.env.NEURANA_PROD_KEY
4 : process.env.NEURANA_DEV_KEY,
5});Resources Summary
| Resource | Methods |
|---|---|
workflows | list, get, create, update, delete, trigger, updateVisibility |
executions | getStatus, listRuns, listTestRuns, listWorkflowRuns, testStep |
code | list, get, upload, delete, listHistory, getHistoryByKey |
secrets | list, get, create, update, delete |
apiKeys | list, get, create, update, delete, rotate, revoke, getUsage, validate |
Ready to get started?
Create your free account and start building workflows in minutes.
Requirements
- Node.js 18+
- TypeScript 5.0+ (for TypeScript users)
Security
- HTTPS enforced
- API keys never logged
- Request tracing via X-Request-ID