Noukai Client
Main client for interacting with Noukai flows.
Noukai
Main async client for executing flows. The Node SDK is async-first — all methods return promises.
Constructor
Parameters:
apiKey(string, optional): API key starting withnk_. Falls back toNOUKAI_API_KEYenv var.org(string, optional): Default organization name for flow lookups. Must be paired withproject. If set,client.flow("slug")uses the defaults; if omitted,client.flow("org/project/slug")is required.project(string, optional): Default project name for flow lookups. Must be paired withorg. If set,client.flow("slug")uses the defaults; if omitted,client.flow("org/project/slug")is required.env(string, optional): Environment for base URL resolution. Accepts"dev"/"development"(→http://localhost:8080/api/v1) or"production"(default →https://api.noukai.xyz/api/v1). Falls back toNOUKAI_ENVenv var.timeout(number, optional): Request timeout in milliseconds. Default: 300000.maxRetries(number, optional): Number of retries on 5xx errors. Default: 1.onLog(function, optional): Logging hook that receivesLogEventobjects.logPayloads(boolean, optional): If true, include request/response bodies in log events. Default: false.
Throws:
AuthenticationError: If no API key is provided or the prefix is invalid.Error: If only one oforgorprojectis provided (both required together).
Example:
Properties
defaultOrg (read-only)
Returns the organization name passed to the constructor, or undefined if not set.
defaultProject (read-only)
Returns the project name passed to the constructor, or undefined if not set.
Methods
flow(identifier) -> Flow
Get a flow proxy for executing a specific flow.
Parameters:
identifier(string | object): Flow identifier in one of three forms:- Single-segment slug (e.g.,
"grade-3") — only valid if the client was constructed withorgandprojectdefaults - Three-segment path (e.g.,
"org/project/slug") — fully-qualified, works regardless of defaults - Object (e.g.,
{ org: "acme", project: "spelling", slug: "grade-3" }) — kwargs form, overrides defaults if provided
- Single-segment slug (e.g.,
Returns: Flow proxy object.
Throws:
Error: If a single-segment slug is given without client-level defaults, or if the identifier format is invalid.
Example:
LogEvent (Type)
Structured logging event passed to onLog hook.
Attributes:
phase(string): One of"request","response","retry"method(string): HTTP method (GET, POST, etc.)path(string): Request pathattempt(number): Attempt number (1 for first try, 2+ for retries)statusCode(number, optional): HTTP status code (only on response)requestId(string, optional): Request ID from response headersrequestBody(any, optional): Request body (iflogPayloads=true)responseBody(any, optional): Response body (iflogPayloads=true)
Example:
FlowIdentifier (Type)
Flow identifier can be a string or object:
String format: "org/project/slug"
Object format: { org: "acme", project: "spelling", slug: "grade-3" }
Both refer to the same flow.