### Install Dependencies Source: https://github.com/box/box-node-sdk/blob/main/test-browser/README.md Installs the necessary Node.js dependencies for the project. ```bash npm install ``` -------------------------------- ### Install Box SDK via npm Source: https://github.com/box/box-node-sdk/blob/main/migration-guides/from-box-typescript-sdk-gen-v1-to-box-node-sdk.md Commands to install the legacy package or the new consolidated SDK versions. ```console npm install box-typescript-sdk-gen ``` ```console npm install box-node-sdk ``` ```console npm install box-node-sdk@4 ``` -------------------------------- ### Install Box Node SDK with yarn Source: https://github.com/box/box-node-sdk/blob/main/README.md Use this command to install a specific version of the Box Node SDK using yarn. Replace `` with the desired SDK version. ```bash yarn add box-node-sdk@ ``` -------------------------------- ### Install Box Node SDK with npm Source: https://github.com/box/box-node-sdk/blob/main/README.md Use this command to install a specific version of the Box Node SDK using npm. Replace `` with the desired SDK version. ```bash npm install box-node-sdk@ ``` -------------------------------- ### Install Box Node SDK v10 Source: https://github.com/box/box-node-sdk/blob/main/migration-guides/from-v3-to-v10.md Use this command to install the v10 version of the Box Node SDK. This version is auto-generated and supports newer Node.js versions. ```bash npm install box-node-sdk@10 ``` -------------------------------- ### Start Automate workflow Source: https://github.com/box/box-node-sdk/blob/main/docs/automateWorkflows.md Starts an Automate workflow manually by using a workflow action ID and file IDs. This operation is performed by calling the `createAutomateWorkflowStartV2026R0` function. ```APIDOC ## POST /automate_workflows/:workflow_id/start ### Description Starts an Automate workflow manually by using a workflow action ID and file IDs. ### Method POST ### Endpoint /automate_workflows/:workflow_id/start ### Parameters #### Path Parameters - **workflow_id** (string) - Required - The ID of the workflow. #### Request Body - **workflowActionId** (string) - Required - The ID of the workflow action to start. - **fileIds** (array) - Required - An array of file IDs to include in the workflow start. ### Request Example ```ts await adminClient.automateWorkflows.createAutomateWorkflowStartV2026R0( workflowAction.workflow.id, { workflowActionId: workflowAction.id, fileIds: [workflowFileId], } satisfies AutomateWorkflowStartRequestV2026R0, ); ``` ### Response #### Success Response (200) - **(undefined)** - Indicates the workflow was successfully started. ``` -------------------------------- ### Install box-node-sdk v4 Source: https://github.com/box/box-node-sdk/blob/main/migration-guides/from-v3-to-v4.md Commands to update the SDK dependency to version 4. ```console npm install box-node-sdk@4 ``` ```json { "dependencies": { "box-node-sdk": "^4.0.0" } } ``` -------------------------------- ### GET /webhooks Source: https://github.com/box/box-node-sdk/blob/main/docs/webhooks.md Returns all defined webhooks for the requesting application. ```APIDOC ## GET /webhooks ### Description Returns all defined webhooks for the requesting application. This API only returns webhooks that are applied to files or folders that are owned by the authenticated user. ### Method GET ### Endpoint /webhooks ### Parameters #### Query Parameters - **queryParams** (GetWebhooksQueryParams) - Optional - Query parameters of getWebhooks method ### Response #### Success Response (200) - **Webhooks** (object) - A list of webhooks. ``` -------------------------------- ### GET /enterprise_configurations/{enterprise_id} Source: https://github.com/box/box-node-sdk/blob/main/docs/enterpriseConfigurations.md Retrieves the configuration settings for a specific enterprise. ```APIDOC ## GET /enterprise_configurations/{enterprise_id} ### Description Retrieves the configuration for an enterprise. ### Method GET ### Endpoint /enterprise_configurations/{enterprise_id} ### Parameters #### Path Parameters - **enterpriseId** (string) - Required - The ID of the enterprise. #### Query Parameters - **categories** (array) - Optional - List of configuration categories to retrieve (e.g., 'user_settings', 'content_and_sharing', 'security', 'shield'). ### Request Example ```ts await adminClient.enterpriseConfigurations.getEnterpriseConfigurationByIdV2025R0( '3442311', { categories: ['user_settings', 'content_and_sharing', 'security', 'shield'], } ); ``` ### Response #### Success Response (200) - **EnterpriseConfigurationV2025R0** (object) - The enterprise configuration object. ``` -------------------------------- ### Get file version Source: https://github.com/box/box-node-sdk/blob/main/docs/fileVersions.md Retrieves details for a specific version of a file. ```ts await client.fileVersions.getFileVersionById( file.id, fileVersions.entries![0].id, ); ``` -------------------------------- ### Authenticate with Developer Token and List Folder Items Source: https://github.com/box/box-node-sdk/blob/main/README.md This JavaScript example demonstrates how to authenticate with a Developer Token and retrieve a list of items in the root folder. Ensure you replace 'INSERT YOUR DEVELOPER TOKEN HERE' with your actual token. ```javascript const { BoxClient, BoxDeveloperTokenAuth } = require('box-node-sdk'); async function main(token) { let auth = new BoxDeveloperTokenAuth({ token }); let client = new BoxClient({ auth }); let entries = (await client.folders.getFolderItems('0')).entries; entries.forEach((entry) => console.log(entry)); } main('INSERT YOUR DEVELOPER TOKEN HERE'); ``` -------------------------------- ### Get zip download status Source: https://github.com/box/box-node-sdk/blob/main/docs/zipDownloads.md Checks the progress and status of a zip archive download. This endpoint is accessible for 12 hours after the download process has started. ```typescript await client.zipDownloads.getZipDownloadStatus(zipDownload.statusUrl!); ``` -------------------------------- ### Initialize Client with Client Credentials Grant (CCG) for User Account (Duplicate) Source: https://github.com/box/box-node-sdk/blob/main/docs/authentication.md Initialize a `BoxClient` for user account access using `CCGAuth`. Requires user ID, client ID, and client secret. This is a repeat of a previous example. ```javascript import { BoxClient } from 'box-node-sdk'; import { BoxCcgAuth, CcgConfig } from 'box-node-sdk/box'; const ccgConfig = new CcgConfig({ userId: 'YOUR_USER_ID', clientId: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET', }); const ccgAuth = new BoxCcgAuth({ config: ccgConfig }); const client = new BoxClient({ auth: ccgAuth }); ``` -------------------------------- ### List Recently Accessed Items Source: https://github.com/box/box-node-sdk/blob/main/docs/recentItems.md Call this function to get information about items recently accessed by a user. It can retrieve up to the last 1000 items or those accessed within the last 90 days. No specific setup is required beyond having an authenticated client instance. ```typescript await client.recentItems.getRecentItems(); ``` -------------------------------- ### Configure proxy settings Source: https://github.com/box/box-node-sdk/blob/main/docs/client.md Sets up an HTTP/S proxy with optional basic authentication. Proxy settings take precedence over custom agent options. ```js newClient = client.withProxy({ url: 'http://127.0.0.1:1234/', username: 'user', password: 'password', }); ``` -------------------------------- ### GET /files/:id/shared_link Source: https://github.com/box/box-node-sdk/blob/main/docs/sharedLinksFiles.md Gets the information for a shared link on a specific file. ```APIDOC ## GET /files/:id/shared_link ### Description Gets the information for a shared link on a file. ### Method GET ### Endpoint /files/:file_id/shared_link ### Parameters #### Path Parameters - **file_id** (string) - Required - The unique identifier that represents a file. #### Query Parameters - **fields** (string) - Optional - Comma-separated list of fields to include in the response. ### Request Example await client.sharedLinksFiles.getSharedLinkForFile(fileId, { fields: 'shared_link' } satisfies GetSharedLinkForFileQueryParams); ### Response #### Success Response (200) - **FileFull** (object) - The base representation of a file with the additional shared link information. ``` -------------------------------- ### GET /web_links/:id/shared_link Source: https://github.com/box/box-node-sdk/blob/main/docs/sharedLinksWebLinks.md Gets the information for a shared link on a specific web link. ```APIDOC ## GET /web_links/:id/shared_link ### Description Gets the information for a shared link on a web link. ### Method GET ### Endpoint /web_links/:id/shared_link ### Parameters #### Path Parameters - **webLinkId** (string) - Required - The ID of the web link. #### Query Parameters - **fields** (string) - Optional - The fields to return, e.g., 'shared_link'. ### Response #### Success Response (200) - **WebLink** (object) - Returns the base representation of a web link with the additional shared link information. ``` -------------------------------- ### GET /files/:file_id/thumbnail/:extension Source: https://github.com/box/box-node-sdk/blob/main/docs/files.md Gets the download URL for a file's thumbnail without downloading the content. ```APIDOC ## GET /files/:file_id/thumbnail/:extension ### Description Get the download URL without downloading the content. ### Method GET ### Endpoint /files/:file_id/thumbnail/:extension ### Parameters #### Path Parameters - **fileId** (string) - Required - The unique identifier of the file for which to get the thumbnail URL. Example: "12345" - **extension** (string) - Required - The desired thumbnail image format (e.g., 'png'). ### Request Example ```ts await client.files.getFileThumbnailUrl( thumbnailFile.id, 'png' as GetFileThumbnailUrlExtension ); ``` ``` -------------------------------- ### Use legacy and generated SDKs together Source: https://github.com/box/box-node-sdk/blob/main/migration-guides/from-v3-to-v4.md Example of initializing and using both the legacy SDK and the new auto-generated sdk-gen module within the same application. ```typescript import BoxSDK from 'box-node-sdk'; import { BoxClient, BoxDeveloperTokenAuth } from 'box-node-sdk/sdk-gen'; // Using the generated SDK (recommended) const newAuth = new BoxDeveloperTokenAuth({ token: 'DEVELOPER_TOKEN' }); const newClient = new BoxClient({ auth: newAuth }); const newFolderItems = await newClient.folders.getFolderItems('0'); // Using the manually written legacy SDK (deprecated) const legacySdk = new BoxSDK({ clientID: 'id', clientSecret: 'secret' }); const manualClient = legacySdk.getBasicClient('DEVELOPER_TOKEN'); const manualFolderItems = await manualClient.folders.getItems('0'); // Both clients can be used in the same application ``` -------------------------------- ### GET /authorize Source: https://github.com/box/box-node-sdk/blob/main/docs/authorization.md Authorize a user by redirecting them to the Box website to request permission. ```APIDOC ## GET /authorize ### Description Authorize a user by sending them through the Box website and request their permission to act on their behalf. ### Method GET ### Endpoint /authorize ### Parameters #### Query Parameters - **queryParams** (AuthorizeUserQueryParams) - Required - Query parameters of authorizeUser method ### Returns - **undefined** - Does not return any data, used in the browser. ``` -------------------------------- ### Get Event Stream Source: https://github.com/box/box-node-sdk/blob/main/docs/events.md Obtain an event stream for the Box API. This function is used to get a continuous stream of events. ```typescript client.events.getEventStream(); ``` -------------------------------- ### Create metadata instance on file Source: https://github.com/box/box-node-sdk/blob/main/docs/fileMetadata.md Applies an instance of a metadata template to a file. Accepts key-value pairs, with specific templates like `global.properties` allowing any pair. ```APIDOC ## POST /files/{file_id}/metadata/{scope}/{template_key} ### Description Applies an instance of a metadata template to a file. In most cases only values that are present in the metadata template will be accepted, except for the `global.properties` template which accepts any key-value pair. ### Method POST ### Endpoint /files/{file_id}/metadata/{scope}/{template_key} ### Parameters #### Path Parameters - **file_id** (string) - Required - The unique identifier that represents a file. - **scope** (string) - Required - The scope of the metadata template. Example: "global" - **template_key** (string) - Required - The name of the metadata template. Example: "properties" #### Query Parameters None #### Request Body - **requestBody** (object) - Required - Request body containing the metadata key-value pairs. - Example fields: `name` (string), `age` (number), `birthDate` (string), `countryCode` (string), `sports` (array of strings) ### Request Example ```json { "example": { "name": "John", "age": 23, "birthDate": "2001-01-03T02:20:50.520Z", "countryCode": "US", "sports": ["basketball", "tennis"] } } ``` ### Response #### Success Response (200 or 201) - **MetadataFull** - Returns the instance of the template that was applied to the file, including the data that was applied to the template. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Get AI agent by agent ID Source: https://github.com/box/box-node-sdk/blob/main/docs/aiStudio.md Gets an AI Agent using the `agent_id` parameter. This operation is performed by calling the `getAiAgentById` function. ```APIDOC ## GET /ai/agents/{agent_id} ### Description Gets an AI Agent using the `agent_id` parameter. ### Method GET ### Endpoint /ai/agents/{agent_id} ### Parameters #### Path Parameters - **agentId** (string) - Required - The agent id to get. Example: "1234" #### Query Parameters - **queryParams** (GetAiAgentByIdQueryParams) - Optional - Query parameters for getting the agent by ID. - **optionalsInput** (GetAiAgentByIdOptionalsInput) - Optional ### Response #### Success Response (200) - **AiSingleAgentResponseFull** - A successful response including the agent. ### Request Example ```ts await client.aiStudio.getAiAgentById(createdAgent.id, { queryParams: { fields: ['ask'] } satisfies GetAiAgentByIdQueryParams, } satisfies GetAiAgentByIdOptionalsInput); ``` ### Response Example ```json { "example": "AiSingleAgentResponseFull" } ``` ``` -------------------------------- ### Chunked Upload (Manual box-node-sdk) Source: https://github.com/box/box-node-sdk/blob/main/migration-guides/from-box-node-sdk-to-sdk-gen.md Create a chunked uploader using `getChunkedUploader()` and start the upload with `.start()`. This method requires `parentFolderId`, `fileSize`, `fileName`, and a `stream`. ```typescript var stream = fs.createReadStream('/path/to/file.txt'); var fileName = 'new_name.txt'; var fileSize = fs.statSync('/path/to/file.txt').size; var parentFolderId = '0'; client.files .getChunkedUploader(parentFolderId, fileSize, fileName, stream) .then((uploader) => uploader.start()) .then((file) => { /* ... */ }); ``` -------------------------------- ### Initialize JWT Auth with Config File Source: https://github.com/box/box-node-sdk/blob/main/docs/authentication.md Authenticate as a Service Account using a configuration file generated from the Box Developer Console. ```js import { BoxClient } from 'box-node-sdk'; import { BoxJwtAuth, JwtConfig } from 'box-node-sdk/box'; const jwtConfig = JwtConfig.fromConfigFile('/path/to/settings.json'); const jwtAuth = new BoxJwtAuth({ config: jwtConfig }); const client = new BoxClient({ auth: jwtAuth }); const me = await client.users.getUserMe(); console.log(`My user ID is ${me.id}`); ``` -------------------------------- ### Create metadata instance on folder Source: https://github.com/box/box-node-sdk/blob/main/docs/folderMetadata.md Applies a metadata template instance to a folder with specified key-value pairs. Requires enterprise configuration for cascading metadata. ```ts await client.folderMetadata.createFolderMetadataById( folder.id, 'enterprise' as CreateFolderMetadataByIdScope, templateKey, { ['name']: 'John', ['age']: 23, ['birthDate']: '2001-01-03T02:20:50.520Z', ['countryCode']: 'US', ['sports']: ['basketball', 'tennis'], }, ); ``` -------------------------------- ### Authenticate with Developer Token Source: https://github.com/box/box-node-sdk/blob/main/migration-guides/from-box-node-sdk-to-sdk-gen.md Compares the manual SDK initialization with the streamlined generated SDK approach. ```typescript var BoxSDK = require('box-node-sdk'); var sdk = new BoxSDK({ clientID: 'YOUR-CLIENT-ID', clientSecret: 'YOUR-CLIENT_SECRET', }); var client = sdk.getBasicClient('YOUR-DEVELOPER-TOKEN'); ``` ```typescript import { BoxClient, BoxDeveloperTokenAuth } from 'box-node-sdk'; const auth = new BoxDeveloperTokenAuth({ token: 'DEVELOPER_TOKEN_GOES_HERE' }); const client = new BoxClient({ auth }); ``` -------------------------------- ### Get Trashed Folder by ID Source: https://github.com/box/box-node-sdk/blob/main/docs/trashedFolders.md Retrieves a specific folder that has been moved to the trash. This function can only retrieve the folder itself if it was directly trashed, not if a parent folder was trashed. Use this to get details about a trashed folder, including when it was moved. ```typescript await client.trashedFolders.getTrashedFolderById(folder.id); ``` -------------------------------- ### Create metadata instance on folder Source: https://github.com/box/box-node-sdk/blob/main/docs/folderMetadata.md Applies an instance of a metadata template to a folder. In most cases, only values present in the metadata template will be accepted, except for the `global.properties` template which accepts any key-value pair. ```APIDOC ## POST /folders/{folder_id}/metadata/{scope}/{template_key} ### Description Applies an instance of a metadata template to a folder. In most cases only values that are present in the metadata template will be accepted, except for the `global.properties` template which accepts any key-value pair. To display the metadata template in the Box web app the enterprise needs to be configured to enable **Cascading Folder Level Metadata** for the user in the admin console. ### Method POST ### Endpoint /folders/{folder_id}/metadata/{scope}/{template_key} ### Parameters #### Path Parameters - **folder_id** (string) - Required - The unique identifier that represent a folder. Example: "12345" - **scope** (string) - Required - The scope of the metadata template. Example: "global" - **template_key** (string) - Required - The name of the metadata template. Example: "properties" #### Request Body - **data** (object) - Required - The metadata key-value pairs to apply to the folder. ### Request Example ```json { "name": "John", "age": 23, "birthDate": "2001-01-03T02:20:50.520Z", "countryCode": "US", "sports": [ "basketball", "tennis" ] } ``` ### Response #### Success Response (200) - **type** (string) - The type of the metadata instance. - **id** (string) - The unique identifier of the metadata instance. - **template** (string) - The name of the metadata template. - **scope** (string) - The scope of the metadata template. - **sequence_id** (string) - The sequence ID of the metadata instance. - **created_at** (string) - The timestamp when the metadata instance was created. - **modified_at** (string) - The timestamp when the metadata instance was last modified. - **created_by** (object) - Information about the user who created the metadata instance. - **type** (string) - The type of the user. - **id** (string) - The unique identifier of the user. - **name** (string) - The name of the user. - **login** (string) - The login name of the user. - **modified_by** (object) - Information about the user who last modified the metadata instance. - **type** (string) - The type of the user. - **id** (string) - The unique identifier of the user. - **name** (string) - The name of the user. - **login** (string) - The login name of the user. - **data** (object) - The metadata key-value pairs. #### Response Example { "type": "metadata", "id": "12345", "template": "properties", "scope": "enterprise", "sequence_id": "1", "created_at": "2023-01-01T12:00:00Z", "modified_at": "2023-01-01T12:00:00Z", "created_by": { "type": "user", "id": "67890", "name": "John Doe", "login": "john.doe@example.com" }, "modified_by": { "type": "user", "id": "67890", "name": "John Doe", "login": "john.doe@example.com" }, "data": { "name": "John", "age": 23 } } ``` -------------------------------- ### Get Folder Information by ID Source: https://github.com/box/box-node-sdk/blob/main/docs/folders.md Retrieves details for a specific folder using its ID. Supports optional parameters for sorting and pagination of folder items. Use this to get basic folder metadata and its immediate contents. ```typescript await client.folders.getFolderById('0'); ``` -------------------------------- ### GET /shield_lists Source: https://github.com/box/box-node-sdk/blob/main/docs/shieldLists.md Retrieves all shield lists in the enterprise. ```APIDOC ## GET /shield_lists ### Description Retrieves all shield lists in the enterprise. ### Method GET ### Endpoint /shield_lists ### Parameters #### Request Body - headersInput (GetShieldListsV2025R0HeadersInput) - Optional - Headers of getShieldListsV2025R0 method - cancellationToken (CancellationToken) - Optional - Token used for request cancellation. ### Response #### Success Response (200) - ShieldListsV2025R0 (object) - The list of shield list objects. ``` -------------------------------- ### POST /tasks Source: https://github.com/box/box-node-sdk/blob/main/docs/tasks.md Creates a new task on a file. ```APIDOC ## POST /tasks ### Description Creates a single task on a file. This task is not assigned to any user and will need to be assigned separately. ### Method POST ### Endpoint /tasks ### Parameters #### Request Body - **requestBody** (CreateTaskRequestBody) - Required - The configuration for the new task. ### Response #### Success Response (200) - **Task** (object) - The newly created task object. ``` -------------------------------- ### GET /box/hub/collaborations Source: https://github.com/box/box-node-sdk/blob/main/docs/hubCollaborations.md Retrieves all collaborations for a Box Hub. ```APIDOC ## GET /box/hub/collaborations ### Description Retrieves all collaborations for a Box Hub. ### Method GET ### Endpoint /box/hub/collaborations ### Query Parameters - **hubId** (string) - Required - The ID of the hub. ### Request Example ```ts await client.hubCollaborations.getHubCollaborationsV2025R0({ hubId: hub.id, } satisfies GetHubCollaborationsV2025R0QueryParams); ``` ### Response #### Success Response (200) - **collaborations** (array) - A list of hub collaborations. - **total_count** (integer) - The total number of collaborations. - **limit** (integer) - The limit for the number of collaborations returned. - **offset** (integer) - The offset for the number of collaborations returned. #### Response Example ```json { "total_count": 1, "limit": 100, "offset": 0, "order": [ { "type": "user", "id": "12345", "name": "Test User" } ], "collaborations": [ { "type": "collaboration", "id": "67890", "created_at": "2023-01-01T12:00:00Z", "modified_at": "2023-01-01T12:00:00Z", "role": "viewer", "status": "accepted", "user": { "type": "user", "id": "12345", "name": "Test User" }, "created_by": { "type": "user", "id": "12345", "name": "Test User" }, "hub": { "type": "hub", "id": "hub_id_123", "name": "Test Hub" } } ] } ``` ``` -------------------------------- ### Create Metadata Instance on a File Source: https://github.com/box/box-node-sdk/blob/main/docs/fileMetadata.md Applies a metadata template instance to a file. For 'global.properties', any key-value pair is accepted; otherwise, values must match the template. ```typescript await client.fileMetadata.createFileMetadataById( file.id, 'enterprise' as CreateFileMetadataByIdScope, templateKey, { ['name']: 'John', ['age']: 23, ['birthDate']: '2001-01-03T02:20:50.520Z', ['countryCode']: 'US', ['sports']: ['basketball', 'tennis'], }, ); ``` -------------------------------- ### GET /webhooks/{id} Source: https://github.com/box/box-node-sdk/blob/main/docs/webhooks.md Retrieves a specific webhook by its ID. ```APIDOC ## GET /webhooks/{id} ### Description Retrieves a specific webhook. ### Method GET ### Endpoint /webhooks/{webhookId} ### Parameters #### Path Parameters - **webhookId** (string) - Required - The ID of the webhook. ### Response #### Success Response (200) - **Webhook** (object) - A webhook object. ``` -------------------------------- ### Initialize Client with Client Credentials Grant (CCG) for User Account Source: https://github.com/box/box-node-sdk/blob/main/docs/authentication.md Use `CCGAuth` to initialize a `BoxClient` for user account access. Requires user ID, client ID, and client secret. The obtained token is automatically refreshed. ```javascript import { BoxClient } from 'box-node-sdk'; import { BoxCcgAuth, CcgConfig } from 'box-node-sdk/box'; const ccgConfig = new CcgConfig({ userId: 'YOUR_USER_ID', clientId: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET', }); const ccgAuth = new BoxCcgAuth({ config: ccgConfig }); const client = new BoxClient({ auth: ccgAuth }); const me = await client.users.getUserMe(); console.log(`My user ID is ${me.id}`); ``` -------------------------------- ### GET /collaborations/{id} Source: https://github.com/box/box-node-sdk/blob/main/docs/userCollaborations.md Retrieves a single collaboration by its ID. ```APIDOC ## GET /collaborations/{id} ### Description Retrieves a single collaboration. ### Method GET ### Endpoint /collaborations/{collaborationId} ### Parameters #### Path Parameters - **collaborationId** (string) - Required - The ID of the collaboration. ### Response #### Success Response (200) - **Collaboration** (object) - Returns a collaboration object. ``` -------------------------------- ### Initialize JWT Auth with Manual Configuration Source: https://github.com/box/box-node-sdk/blob/main/docs/authentication.md Manually provide configuration fields to the JwtConfig constructor when a JSON file is not available. ```js import { BoxClient } from 'box-node-sdk'; import { BoxJwtAuth, JwtConfig } from 'box-node-sdk/box'; const jwtConfig = new JwtConfig({ clientId: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET', jwtKeyId: 'YOUR_JWT_KEY_ID', privateKey: 'YOUR_PRIVATE_KEY', privateKeyPassphrase: 'PASSPHRASE', enterpriseId: 'YOUR_ENTERPRISE_ID', }); const jwtAuth = new BoxJwtAuth({ config: jwtConfig }); const serviceAccountClient = new BoxClient({ auth: jwtAuth }); ``` -------------------------------- ### Initialize Client with Client Credentials Grant (CCG) for Service Account Source: https://github.com/box/box-node-sdk/blob/main/docs/authentication.md Initialize a `BoxClient` for service account access using `CCGAuth`. This requires the enterprise ID, client ID, and client secret. ```javascript import { BoxClient } from 'box-node-sdk'; import { BoxCcgAuth, CcgConfig } from 'box-node-sdk/box'; const ccgConfig = new CcgConfig({ enterpriseId: 'YOUR_ENTERPRISE_ID', clientId: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET', }); const ccgAuth = new BoxCcgAuth({ config: ccgConfig }); const client = new BoxClient({ auth: ccgAuth }); ``` -------------------------------- ### GET /tasks/:id/assignments Source: https://github.com/box/box-node-sdk/blob/main/docs/taskAssignments.md Lists all of the assignments for a given task. ```APIDOC ## GET /tasks/:id/assignments ### Description Lists all of the assignments for a given task. ### Method GET ### Endpoint /tasks/:taskId/assignments ### Parameters #### Path Parameters - **taskId** (string) - Required - The ID of the task. ### Response #### Success Response (200) - **TaskAssignments** (object) - A collection of task assignment objects. ``` -------------------------------- ### Authenticate as App User with JWT Constructor Source: https://github.com/box/box-node-sdk/blob/main/docs/authentication.md Initialize a client to act as an app user by passing the `userId` directly to the `JwtConfig` constructor. This is an alternative to using a configuration file. ```javascript import { BoxClient } from 'box-node-sdk'; import { BoxJwtAuth, JwtConfig } from 'box-node-sdk/box'; const jwtConfig = new JwtConfig({ clientId: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET', jwtKeyId: 'YOUR_JWT_KEY_ID', privateKey: 'YOUR_PRIVATE_KEY', privateKeyPassphrase: 'PASSPHRASE', userId: 'USER_ID', }); const jwtAuth = new BoxJwtAuth({ config: jwtConfig }); const userClient = new BoxClient({ auth: jwtAuth }); ``` -------------------------------- ### GET /sign_requests Source: https://github.com/box/box-node-sdk/blob/main/docs/signRequests.md Lists all signature requests created by the user. ```APIDOC ## GET /sign_requests ### Description Gets signature requests created by a user. ### Method GET ### Endpoint /sign_requests ### Response #### Success Response (200) - **SignRequests** (object) - Returns a collection of sign requests. ``` -------------------------------- ### GET /groups/:id/collaborations Source: https://github.com/box/box-node-sdk/blob/main/docs/listCollaborations.md Retrieves all the collaborations for a specific group. ```APIDOC ## GET /groups/:id/collaborations ### Description Retrieves all the collaborations for a group. The user must have admin permissions to inspect enterprise's groups. ### Method GET ### Endpoint /groups/:groupId/collaborations ### Parameters #### Path Parameters - **groupId** (string) - Required - The ID of the group. #### Request Body - **optionalsInput** (GetGroupCollaborationsOptionalsInput) - Optional - Optional parameters for the request. ### Response #### Success Response (200) - **CollaborationsOffsetPaginated** (object) - A collection of collaboration objects. ``` -------------------------------- ### Authenticate with JWT Configuration File Source: https://github.com/box/box-node-sdk/blob/main/migration-guides/from-box-node-sdk-to-sdk-gen.md Initializes JWT authentication using a preconfigured JSON file. ```typescript var BoxSDK = require('box-node-sdk'); var jsonConfig = require('/path/to/config.json'); var sdk = BoxSDK.getPreconfiguredInstance(jsonConfig); var serviceAccountClient = sdk.getAppAuthClient('enterprise'); ``` ```typescript import { BoxClient, BoxJwtAuth, JwtConfig } from 'box-node-sdk'; const jwtConfig = JwtConfig.fromConfigFile('/path/to/config.json'); const auth = new BoxJwtAuth({ config: jwtConfig }); const client = new BoxClient({ auth }); ``` -------------------------------- ### GET /enterprise/hubs Source: https://github.com/box/box-node-sdk/blob/main/docs/hubs.md Retrieves all Box Hubs for a given enterprise. ```APIDOC ## GET /enterprise/hubs ### Description Retrieves all Box Hubs for a given enterprise. Admins or Hub Co-admins of an enterprise with GCM scope can make this call. ### Method GET ### Endpoint /enterprise/hubs ### Parameters #### Query Parameters - **sort** (string) - Optional - The field to sort by. - **direction** (string) - Optional - The sort direction (ASC or DESC). ### Response #### Success Response (200) - **HubsV2025R0** (object) - A list of Box Hubs for the enterprise. ``` -------------------------------- ### POST /workflows/:id/start Source: https://github.com/box/box-node-sdk/blob/main/docs/workflows.md Initiates a workflow with a manual trigger type. ```APIDOC ## POST /workflows/:id/start ### Description Initiates a flow with a trigger type of WORKFLOW_MANUAL_START. ### Method POST ### Endpoint /workflows/:id/start ### Parameters #### Path Parameters - **workflowId** (string) - Required - The ID of the workflow. #### Request Body - **type** (string) - Required - The type of the request body (e.g., 'workflow_parameters'). - **flow** (object) - Required - The flow object containing the flow ID. - **files** (array) - Optional - List of files to include in the workflow. - **folder** (object) - Optional - The folder object to associate with the workflow. ### Request Example { "type": "workflow_parameters", "flow": { "type": "flow", "id": "123" }, "files": [{ "type": "file", "id": "456" }], "folder": { "type": "folder", "id": "789" } } ### Response #### Success Response (200) - **undefined** - The workflow has been successfully started. ``` -------------------------------- ### GET /hubs Source: https://github.com/box/box-node-sdk/blob/main/docs/hubs.md Retrieves all Box Hubs for the requesting user. ```APIDOC ## GET /hubs ### Description Retrieves all Box Hubs for the requesting user. ### Method GET ### Endpoint /hubs ### Parameters #### Query Parameters - **scope** (string) - Optional - The scope of hubs to retrieve. - **sort** (string) - Optional - The field to sort by. - **direction** (string) - Optional - The sort direction (ASC or DESC). ### Response #### Success Response (200) - **HubsV2025R0** (object) - A list of Box Hubs. ``` -------------------------------- ### OPTIONS /files/content Source: https://github.com/box/box-node-sdk/blob/main/docs/uploads.md Performs a preflight check to verify that a file will be accepted by Box before uploading the entire file. ```APIDOC ## OPTIONS /files/content ### Description Performs a check to verify that a file will be accepted by Box before you upload the entire file. ### Method OPTIONS ### Endpoint /files/content ### Parameters #### Request Body - **requestBody** (PreflightFileUploadCheckRequestBody) - Required - Body containing file name, size, and parent folder information. ### Response #### Success Response (200) - **UploadUrl** (object) - Returns a session URL that can be used to upload the file. ``` -------------------------------- ### GET /box/hub-items Source: https://github.com/box/box-node-sdk/blob/main/docs/hubItems.md Retrieves all items associated with a Box Hub. ```APIDOC ## GET /box/hub-items ### Description Retrieves all items associated with a Box Hub. ### Method GET ### Endpoint /box/hub-items ### Query Parameters - **hubId** (string) - Required - The unique identifier of the hub. ### Response #### Success Response (200) - **items** (array) - A list of items associated with the hub. - **total_count** (integer) - The total number of items in the hub. ### Response Example ```json { "items": [ { "type": "folder", "id": "12345", "name": "Example Folder" } ], "total_count": 1 } ``` ``` -------------------------------- ### Download ZIP Source: https://github.com/box/box-node-sdk/blob/main/docs/zipDownloads.md Creates a zip archive of specified items and downloads its content. ```APIDOC ## POST /zip/downloads ### Description Creates a zip archive of specified items and downloads its content. ### Method POST ### Endpoint /zip/downloads ### Parameters #### Request Body - **items** (array) - Required - An array of items to include in the zip archive. Each item should have an `id` and `type` ('file' or 'folder'). - **downloadFileName** (string) - Required - The desired name for the downloaded zip file. ### Request Example ```json { "items": [ { "id": "file1.id", "type": "file" }, { "id": "file2.id", "type": "file" }, { "id": "folder1.id", "type": "folder" } ], "downloadFileName": "zip" } ``` ### Response #### Success Response (200) - **ByteStream** - The content of the downloaded zip file. ``` -------------------------------- ### Initialize OAuth with In-Memory Storage Source: https://github.com/box/box-node-sdk/blob/main/docs/authentication.md Default configuration for OAuth using volatile memory storage. ```javascript const config = new OAuthConfig({ clientId: 'OAUTH_CLIENT_ID', clientSecret: 'OAUTH_CLIENT_SECRET', }); const oauth = new BoxOAuth({ config: config }); ``` -------------------------------- ### Get Watermark for Folder Source: https://github.com/box/box-node-sdk/blob/main/docs/folderWatermarks.md Retrieve the watermark for a specific folder. ```APIDOC ## GET /folders/{folder_id}/watermark ### Description Retrieve the watermark for a folder. ### Method GET ### Endpoint /folders/{folder_id}/watermark ### Parameters #### Path Parameters - **folder_id** (string) - Required - The unique identifier that represent a folder. The ID for any folder can be determined by visiting this folder in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/folder/123` the `folder_id` is `123`. The root folder of a Box account is always represented by the ID `0`. Example: "12345" ### Response #### Success Response (200) - **watermark** (object) - Information about the watermark associated with the folder. #### Response Example ```json { "watermark": { "imprint": "default" } } ``` ``` -------------------------------- ### POST /hubs Source: https://github.com/box/box-node-sdk/blob/main/docs/hubs.md Creates a new Box Hub. ```APIDOC ## POST /hubs ### Description Creates a new Box Hub. ### Method POST ### Endpoint /hubs ### Parameters #### Request Body - **title** (string) - Required - The title of the hub. - **description** (string) - Optional - The description of the hub. ### Response #### Success Response (200) - **HubV2025R0** (object) - The created hub object. ``` -------------------------------- ### GET /event_stream Source: https://github.com/box/box-node-sdk/blob/main/docs/events.md Retrieves an event stream for the Box API. ```APIDOC ## GET /event_stream ### Description Get an event stream for the Box API. ### Method GET ### Parameters #### Query Parameters - **queryParams** (GetEventStreamQueryParams) - Optional - Query parameters for the event stream - **headersInput** (GetEventStreamHeadersInput) - Optional - Headers of getEventStream method - **cancellationToken** (CancellationToken) - Optional - Token used for request cancellation ### Response #### Success Response (200) - **EventStream** (Object) - The event stream object. ``` -------------------------------- ### GET /ai/agent_default Source: https://github.com/box/box-node-sdk/blob/main/docs/ai.md Retrieves the default configuration for an AI agent. ```APIDOC ## GET /ai/agent_default ### Description Get the AI agent default config. ### Method GET ### Endpoint /ai/agent_default ### Parameters #### Query Parameters - **queryParams** (GetAiAgentDefaultConfigQueryParams) - Required - Query parameters of getAiAgentDefaultConfig method - **optionalsInput** (GetAiAgentDefaultConfigOptionalsInput) - Optional - Optional parameters for the request ### Response #### Success Response (200) - **response** (AiAgent) - A successful response including the default agent configuration. ``` -------------------------------- ### Get a specific webhook Source: https://github.com/box/box-node-sdk/blob/main/docs/webhooks.md Retrieves the details of a specific webhook by its ID. ```ts await client.webhooks.getWebhookById(webhook.id!); ``` -------------------------------- ### List storage policies Source: https://github.com/box/box-node-sdk/blob/main/docs/storagePolicies.md Fetches all the storage policies in the enterprise. ```APIDOC ## GET /storage/policies ### Description Fetches all the storage policies in the enterprise. ### Method GET ### Endpoint /storage/policies ### Parameters #### Query Parameters - **limit** (int) - Optional - The maximum number of items to return. - **offset** (int) - Optional - The number of items to skip before starting to collect the result set. ### Request Example ```json { "limit": 100, "offset": 0 } ``` ### Response #### Success Response (200) - **total_count** (int) - The total number of storage policies available. - **entries** (array) - An array of storage policy objects. - **type** (string) - The type of the object. - **id** (string) - The unique identifier for the storage policy. - **enterprise** (object) - Information about the enterprise. - **type** (string) - The type of the object. - **id** (string) - The unique identifier for the enterprise. - **name** (string) - The name of the enterprise. - **is_default** (boolean) - Indicates if this is the default storage policy. - **policy_name** (string) - The name of the storage policy. - **storage_hashing_algorithm** (string) - The hashing algorithm used for storage. #### Response Example ```json { "total_count": 2, "entries": [ { "type": "storage_policy", "id": "12345", "enterprise": { "type": "enterprise", "id": "67890", "name": "Example Enterprise" }, "is_default": true, "policy_name": "Default Policy", "storage_hashing_algorithm": "sha1" }, { "type": "storage_policy", "id": "54321", "enterprise": { "type": "enterprise", "id": "67890", "name": "Example Enterprise" }, "is_default": false, "policy_name": "Custom Policy", "storage_hashing_algorithm": "sha1" } ] } ``` ``` -------------------------------- ### List All Storage Policies - Box Node SDK Source: https://github.com/box/box-node-sdk/blob/main/docs/storagePolicies.md Fetches all storage policies in the enterprise. This operation requires no specific arguments beyond the client initialization. ```typescript await client.storagePolicies.getStoragePolicies(); ``` -------------------------------- ### GET /task_assignments/:id Source: https://github.com/box/box-node-sdk/blob/main/docs/taskAssignments.md Retrieves information about a specific task assignment. ```APIDOC ## GET /task_assignments/:id ### Description Retrieves information about a task assignment. ### Method GET ### Endpoint /task_assignments/:taskAssignmentId ### Parameters #### Path Parameters - **taskAssignmentId** (string) - Required - The ID of the task assignment. ### Response #### Success Response (200) - **TaskAssignment** (object) - The task assignment object. ``` -------------------------------- ### GET /tasks/:id Source: https://github.com/box/box-node-sdk/blob/main/docs/tasks.md Retrieves information about a specific task by its ID. ```APIDOC ## GET /tasks/:id ### Description Retrieves information about a specific task. ### Method GET ### Endpoint /tasks/:id ### Parameters #### Path Parameters - **taskId** (string) - Required - The ID of the task. ### Response #### Success Response (200) - **Task** (object) - The task object. ``` -------------------------------- ### List All Global Metadata Templates Source: https://github.com/box/box-node-sdk/blob/main/docs/metadataTemplates.md Fetches all generic, global metadata templates available across all enterprises on Box. Query parameters and cancellation tokens can be provided. ```typescript await client.metadataTemplates.getGlobalMetadataTemplates(); ``` -------------------------------- ### Create an archive with Box Node SDK Source: https://github.com/box/box-node-sdk/blob/main/docs/archives.md Creates a new archive by providing a name and description to the createArchiveV2025R0 method. ```typescript await client.archives.createArchiveV2025R0({ name: archiveName, description: archiveDescription, } satisfies CreateArchiveV2025R0RequestBody); ``` -------------------------------- ### GET /folders/trash/items Source: https://github.com/box/box-node-sdk/blob/main/docs/trashedItems.md Retrieves a list of files and folders that have been moved to the trash. ```APIDOC ## GET /folders/trash/items ### Description Retrieves the files and folders that have been moved to the trash. This endpoint supports both offset-based and marker-based pagination. ### Method GET ### Endpoint /folders/trash/items ### Parameters #### Query Parameters - **queryParams** (GetTrashedItemsQueryParams) - Optional - Query parameters for the request. #### Headers - **headersInput** (GetTrashedItemsHeadersInput) - Optional - Custom headers for the request. ### Request Example ```ts await client.trashedItems.getTrashedItems(); ``` ### Response #### Success Response (200) - **Items** (Object) - A list of items that have been deleted. #### Response Example { "total_count": 1, "entries": [ { "type": "file", "id": "12345", "name": "example.txt" } ] } ``` -------------------------------- ### Initialize Box Client in Browser Source: https://github.com/box/box-node-sdk/blob/main/example.html Uses a developer token to authenticate and retrieve the current user's name. Requires the box-typescript-sdk-gen library to be available on the window object. ```javascript const { BoxClient, BoxDeveloperTokenAuth } = window['box-typescript-sdk-gen']; async function main(token) { try { const client = new BoxClient({ auth: new BoxDeveloperTokenAuth({ token }), }); const { name } = await client.users.getUserMe(); alert(`Hello ${name}!`); } catch (e) { alert(String(e)); console.error(e); } } main(prompt('Provide the developer token')); ``` -------------------------------- ### GET /shield_lists/{shield_list_id} Source: https://github.com/box/box-node-sdk/blob/main/docs/shieldLists.md Retrieves a single shield list by its ID. ```APIDOC ## GET /shield_lists/{shield_list_id} ### Description Retrieves a single shield list by its ID. ### Method GET ### Endpoint /shield_lists/{shield_list_id} ### Parameters #### Path Parameters - shieldListId (string) - Required - The unique identifier that represents a shield list. ### Response #### Success Response (200) - ShieldListV2025R0 (object) - The shield list object. ``` -------------------------------- ### GET /sign_requests/{id} Source: https://github.com/box/box-node-sdk/blob/main/docs/signRequests.md Retrieves a specific sign request by its ID. ```APIDOC ## GET /sign_requests/{id} ### Description Gets a sign request by ID. ### Method GET ### Endpoint /sign_requests/{signRequestId} ### Parameters #### Path Parameters - **signRequestId** (string) - Required - The ID of the signature request. ### Response #### Success Response (200) - **SignRequest** (object) - Returns a signature request. ``` -------------------------------- ### Configure Custom Base URLs (Manual box-node-sdk) Source: https://github.com/box/box-node-sdk/blob/main/migration-guides/from-box-node-sdk-to-sdk-gen.md Use the `configure` method on an SDK instance to specify custom base URLs for API calls. This is applicable to the manually maintained `box-node-sdk` module. ```typescript const sdk = BoxSDKNode.getPreconfiguredInstance(APP_SETTINGS); var additonalParams = { apiRootURL: 'https://my.company.url.com', uploadAPIRootURL: 'https://my.company.url.com/upload', authorizeRootURL: 'https://my.company.url.com/authorize', }; sdk.configure(additonalParams); ```