Soniox

Handling files with Node SDK

Upload audio files and manage them with the Soniox Node SDK

Node SDK provides helpers to work with the Files API to upload audio for async transcription or to reuse files across multiple jobs.

Upload

upload() accepts Buffer, Uint8Array, Blob, ReadableStream

import { readFile } from 'node:fs/promises';

const audio = await readFile('audio.mp3');

const file = await client.files.upload(audio, {
  filename: 'audio.mp3',
  client_reference_id: 'meeting-42',
});

console.log(file.id, file.filename, file.size);

Read more about Supported audio formats.

List files

list() returns a paginated list of all uploaded files. Use for await...of to iterate through all pages.

const result = await client.files.list({ limit: 100 });

// Automatic pagination
for await (const file of result) {
  console.log(file.id, file.filename);
}

Get file

Get a file by ID using get() method:

const file = await client.files.get('file-id');

Delete file

Delete file via instance using file.delete() method:

const file = await client.files.get('file-id');

if (file) {
  await file.delete();
}

Or delete by ID using delete() method:

await client.files.delete('file-id');

Delete all files from your account

You can delete all files using files.delete_all method.

await client.files.delete_all();

delete_all operation is irreversible and cannot be undone.