DocuTray
Node.js SDKResources

Steps

Node.js SDK reference for the Steps resource — methods, parameters, and return types for the DocuTray API.

Steps

Resource for running predefined processing steps. Access via client.steps.

Methods

runAsync(params, options?)

Runs a processing step asynchronously. Returns the enqueue response (id, status: 'ENQUEUED', step_id and step_name) with a .wait() method for polling.

const enqueued = await client.steps.runAsync({
  stepId: 'step_abc123',
  url: 'https://example.com/document.pdf',
});
console.log(enqueued.id); // execution id

const result = await enqueued.wait();
if (result.status === 'SUCCESS') {
  console.log(result.data); // processed result
} else {
  console.log(result.error?.message);
}

wait() accepts WaitOptions (pollInterval, timeout, onStatus) and resolves with the final status on both SUCCESS and ERROR: it does not throw when the operation fails, so check status. It rejects only on timeout (APITimeoutError) or when a status request fails.

Parameters: StepsRunParams Returns: Promise<StepExecutionEnqueued & { wait(options?): Promise<StepExecutionStatus> }>

getStatus(executionId, options?)

Retrieves the current status of a step execution, identified by the id that runAsync() returned (execution_id in the status).

const status = await client.steps.getStatus('exec_abc123');
console.log(status.execution_id, status.status);

Parameters: executionId: string Returns: Promise<StepExecutionStatus>

Raw Responses

Access raw HTTP response details via withRawResponse:

const raw = await client.steps.withRawResponse.runAsync({
  stepId: 'step_abc123',
  url: 'https://example.com/document.pdf',
});

console.log(raw.statusCode);

On this page