You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Vector bucket
DeleteVectorBucket(TOS Vectors Node.js SDK)
Copy page
Download PDF
DeleteVectorBucket(TOS Vectors Node.js SDK)
The deleteVectorBucket interface requires the vector bucket to be empty before deletion, meaning the vector indexes in the bucket must have been deleted. This article explains how to complete this operation using the deleteVectorBucket interface of the TOS Vectors Node.js SDK.​
Notes​
  • To prevent key leakage, the sample code in this article reads the Access Key ID and Secret Access Key from environment variables. Therefore, before using the SDK, you need to configure long-term access credentials. For details, see Configuring Long-term Access Credentials.​
  • The TOS Vectors Node.js SDK supports using temporary access credentials and also supports timeout mechanisms, retry policies, and other features. You can configure these flexibly according to your business needs to improve application security. For details, see Common Configuration Scenarios.​
Permissions required​
The main account has all permissions by default, but IAM users have no permissions by default. If you need to perform the deleteVectorBucket operation using a sub-account, the main account must grant the following permissions to the sub-account through IAM policies and bucket policies:​
tosvectors:DeleteVectorBucket​
Code example​
Basic usage of deleting a vector bucket​
​
// Basic usage of deleting a vector bucket​
​
import {​
TosVectorsClient,​
TosClientError,​
TosServerError,​
} from "@volcengine/tos-sdk";​
​
// Obtain credentials and configuration from environment variables​
const client = new TosVectorsClient({​
accessKeyId: process.env["TOS_ACCESS_KEY"] as string, // TOS_ACCESS_KEY: your Access Key ID​
accessKeySecret: process.env["TOS_SECRET_KEY"] as string, // TOS_SECRET_KEY: your Secret Key​
region: 'Provide your region',​
endpoint: 'Provide your vector endpoint',​
});​
​
// Read the name of the vector bucket to be deleted and the account ID from environment variables​
const vectorBucketName = 'Provide your vector bucket name';​
const accountId = process.env["TOS_ACCOUNT_ID"]; // TOS_ACCOUNT_ID: your account ID​
​
/**​
* handle possible errors during SDK calls.​
*@paramerror the captured error object​
*/​
function handleError(error: Error) {​
if (error instanceof TosClientError) {​
// client-side exceptions, usually due to parameter errors or network issues​
console.log("Client Error:");​
console.log(" Message:", error.message);​
if (error.stack) {​
console.log(" Stack:", error.stack);​
}​
} else if (error instanceof TosServerError) {​
// server-side exceptions, indicating the request was received but failed to process​
console.log("Server Error:");​
console.log(" Request ID:", error.requestId);​
console.log(" Status Code:", error.statusCode);​
console.log(" Code:", error.code);​
console.log(" Message:", error.message);​
console.log(" Headers:", error.headers);​
} else {​
// other unknown exceptions​
console.log("Unexpected Error:");​
console.log(" Message:", error.message);​
}​
}​
​
async function main() {​
try {​
// 1. Prepare parameters required by the API according to the use case scenario.​
console.log(`Begin deleting vector buckets: ${vectorBucketName} ...`);​
​
// 2. Call the deleteVectorBucket method to delete the specified vector bucket.​
const result = await client.deleteVectorBucket({​
vectorBucketName,​
accountID: accountId,​
});​
​
// 3. Print the generic return information.​
console.log("Request Succeeded:");​
console.log(" Request ID:", result.requestId);​
console.log(" Status Code:", result.statusCode);​
console.log(" Headers:", result.headers);​
​
// 4. Print business data: DeleteVectorBucketOutput is an empty object, usually {}.​
console.log("Business Data:");​
console.log(" Result Data:", result.data);​
console.log(` Name of the vector bucket that has initiated deletion: ${vectorBucketName}`);​
} catch (error: any) {​
handleError(error);​
}​
}​
​
main();​
​
​
Related documentation​
For the API documentation of DeleteVectorBucket, see DeleteVectorBucket.​
​
Last updated: 2026.02.06 18:01:44