Node.js SDK: Migrate from V1 to V2
Node.js SDK: Migrate from V1 to V2
Node.js SDK: Migrate from V1 to V2
Skyflow Node.js SDK v2 introduces a new authentication model, multi-vault support, TypeScript types, typed request and response classes, and richer error diagnostics. This guide walks through the key changes with before-and-after code examples, focuses on Insert end-to-end, then shows how the same pattern applies to other operations. A final section covers the v2.1+ changes — most notably the camelCase migration on error fields — which are backward compatible.
V1 required a bearer token function. V2 lets you choose from five credential types and adds full TypeScript support.
V1:
V2:
Use only one authentication method per credentials object.
V2 replaces the static Skyflow.init() factory with a new Skyflow(config) constructor and adds multi-vault support. Log levels are now per-instance instead of global.
V1:
V2 (single vault):
V2 (multiple vaults):
Key changes:
vaultURL is replaced by clusterId (derived from your vault URL).env is now required. Supported values: Env.PROD, Env.SANDBOX.V2 replaces the plain-object request payload with a typed InsertRequest class. Responses come back as typed InsertResponse objects.
V1:
V2:
V1 response:
V2 response:
Every vault operation in v2 follows the same pattern: build a typed request, then pass it to a method on the vault client. The snippets below show v2 request construction.
Get:
Update:
Delete:
Detokenize:
Query:
V2 replaces the plain options object with a typed InsertOptions class. Configure it through setters before passing it to the vault call.
V1:
V2:
The same setter-based pattern applies to UpsertOptions, UpdateOptions, DeleteOptions, and GetOptions.
V2 errors carry more context to help with debugging. The example below shows the v2.0 field names; see the v2.1+ section for the camelCase canonical names introduced in v2.1.0.
V1:
V2:
Use the request ID field when contacting Skyflow Support — it uniquely identifies the request for faster diagnosis.
v2.1.0 normalizes the public interface to camelCase and introduces several backward-compatible renames. All legacy names continue to work and emit a deprecation warning on use; they will be removed in a future major release.
Error field renames:
SkyflowError and ISkyflowError field names are now canonical camelCase.
SkyflowRecordError.request_ID has been renamed the same way:
Method renames:
If both the legacy and preferred names are provided, the preferred name takes precedence.
FileUploadRequest constructor normalization:
The canonical constructor is now new FileUploadRequest(table, columnName). The legacy 3-argument form new FileUploadRequest(table, skyflowId, columnName) is deprecated; configure skyflowId through FileUploadOptions.setSkyflowId() instead.
Credential field aliases:
Credential JSON files now accept camelCase keys alongside the legacy forms. Existing credential files continue to work unchanged.
Response type tightening:
InsertResponse.insertedFields is guaranteed non-null (returns [] instead of null).DeleteResponse.deletedIds is guaranteed defined (returns [] instead of undefined).DeidentifyFileResponse and DeidentifyTextResponse now include an errors: Array<SkyflowRecordError> | null field.Existing === null and === undefined checks against these fields can be replaced with empty-array checks.
Custom token URI:
BearerTokenOptions, SignedDataTokensOptions, and Credentials now accept a tokenUri field to override the default token endpoint URL when generating bearer tokens.
invokeConnection content types:
invokeConnection now correctly handles application/json, application/x-www-form-urlencoded, text/plain, multipart/form-data, text/xml, application/xml, and text/html. Previously, mismatched request/response content types could cause incorrect serialization behavior.
For the full list of changes, see the Node SDK releases on GitHub.
If you hit issues during migration, contact Skyflow Support and include the requestId from any failed call.