### Box Python SDK setup and client initialization Source: https://developer.box.com/guides/getting-started Setup steps for the Box Python SDK quickstart: create and activate a virtual environment, install the SDK with pip, and begin obtaining a client with a developer token. The Python code is incomplete in the source; it shows the imports and the start of the auth assignment. ```shellscript python3 -m venv .venv source .venv/bin/activate ``` ```shellscript pip install "boxsdk>=10" ``` ```python from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth, UploadFileAttributes, UploadFileAttributesParentField import json auth = ``` -------------------------------- ### Example output of box users:get me Source: https://developer.box.com/guides/cli Example response from the CLI after a successful authentication, showing user account details. ```text Type: user ID: '0123456789' Name: Aaron Levie Login: example@box.com Created At: '2020-01-01T09:45:01-07:00' Modified At: '2021-03-01T09:30:05-07:00' Language: en Timezone: America/Los_Angeles Space Amount: 999999999999999 Space Used: 6291500 Max Upload Size: 16106127360 Status: active Job Title: '' Phone: '' Address: example+user@box.com Avatar URL: '' Notification Email: [] ``` -------------------------------- ### Get Workflows (Swift) Source: https://developer.box.com/reference/get-workflows Swift SDK example to get workflows in a folder. ```swift try await adminClient.workflows.getWorkflows(queryParams: GetWorkflowsQueryParams(folderId: workflowFolderId)) ``` -------------------------------- ### Get Workflows (Java) Source: https://developer.box.com/reference/get-workflows Java SDK example to get workflows in a folder. ```java adminClient.getWorkflows().getWorkflows(new GetWorkflowsQueryParams(workflowFolderId)) ``` -------------------------------- ### Get Workflows (C#) Source: https://developer.box.com/reference/get-workflows C# SDK example to get workflows in a folder. ```csharp await adminClient.Workflows.GetWorkflowsAsync(queryParams: new GetWorkflowsQueryParams(folderId: workflowFolderId)); ``` -------------------------------- ### Node.js server startup logging and export Source: https://developer.box.com/guides/getting-started/plan-your-integration This snippet shows the tail end of a Node.js server setup that logs the running port and available endpoints, then exports the app. It is part of a larger example, but only the visible portion is included. ```javascript running on port ${PORT}`);\n console.log('Available endpoints:');\n console.log(' POST /api/box/proxy - Box API proxy');\n console.log(' GET /api/health - Health check');\n});\n\nmodule.exports = app; ``` -------------------------------- ### Create a Box Sign request with .NET SDK (alternative setup) Source: https://developer.box.com/guides/box-sign/create-sign-request Builds a BoxSignRequestCreateRequest with source files, signers, and parent folder, then calls CreateSignRequestAsync. This example uses the BoxSignRequestCreateSourceFile and BoxSignRequestSignerCreate classes. ```csharp var sourceFiles = new List { new BoxSignRequestCreateSourceFile() { Id = "12345" } }; var signers = new List { new BoxSignRequestSignerCreate() { Email = "example@gmail.com" } }; var parentFolder = new BoxRequestEntity() { Id = "12345", Type = BoxType.folder }; var request = new BoxSignRequestCreateRequest { SourceFiles = sourceFiles, Signers = signers, ParentFolder = parentFolder }; BoxSignRequest signRequest = await client.SignRequestsManager.CreateSignRequestAsync(request); ``` -------------------------------- ### CSS: Badge styles for guides and HTTP methods Source: https://developer.box.com/guides/uploads/direct Defines badge colors for guide, tutorial, quickstart, and HTTP method badges (GET, POST, PUT, PATCH, DELETE) with dark mode variants. ```css /* Related links badge styles */ /* Guide badges */ .badge-guide, .badge-tutorial, .badge-quickstart { background-color: #1f2937; color: #fff; } .dark .badge-guide, .dark .badge-tutorial, .dark .badge-quickstart { background-color: #1f2937; color: #fff; } /* HTTP method badges */ .badge-get { background-color: rgb(74 222 128/0.2); color: #15803d; } .dark .badge-get { color: #4ade80; } .badge-post { background-color: rgb(96 165 250/0.2); color: #1d4ed8; } .dark .badge-post { color: #60a5fa; } .badge-put, .badge-patch { background-color: rgb(250 204 21/0.2); color: #a16207; } .dark .badge-put, .dark .badge-patch { color: #facc15; } .badge-delete { background-color: rgb(248 113 113/0.2); color: #b91c1c; } .dark .badge-delete { color: #f87171; } ``` -------------------------------- ### Project directory structure after setup Source: https://developer.box.com/tutorials/company-brain Shows the expected files in the project directory after completing the tutorial steps. Includes .env, .venv/, ask.py, box_client.py, intake.py, publish.py, and review.py. ```text company-brain/ ├── .env ├── .venv/ ├── ask.py ├── box_client.py ├── intake.py ├── publish.py └── review.py ``` -------------------------------- ### Get Sign Request by ID - Ruby Source: https://developer.box.com/reference/get-sign-requests-id Ruby example using the net/http library to fetch a sign request. Ensure you have the required gems installed. ```ruby require 'net/http' require 'json' uri = URI('https://api.box.com/2.0/sign_requests/12345') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri) request['Authorization'] = 'Bearer YOUR_ACCESS_TOKEN' response = http.request(request) puts response.body ``` -------------------------------- ### Run create_hub.py (Python) Source: https://developer.box.com/tutorials/sales-rfp-answer-bank Executes the script that creates the Sales Hub and adds content. The output confirms the hub creation and content addition, and prints the hub ID to save for later steps. ```bash python create_hub.py ``` -------------------------------- ### Simple sign request with prep YAML configuration Source: https://developer.box.com/guides/box-sign/document-types/unstructured A YAML configuration example showing a sign request status, signer email, and the prepare URL for a document. ```yaml Simple sign request with prep: xyz-abc-123 Status: converting Signers: signer@example.com Prepare url: https://app.box.com/sign/document/xyz-abc-123/.../prepare_doc/ ``` -------------------------------- ### Create Hub Example Source: https://developer.box.com/reference/v2025.0/hubs-resources Creates a new hub with a specified name and description. ```json { "name": "Contracts", "description": "All the contracts for the company." } ``` -------------------------------- ### Files resource example (JSON) Source: https://developer.box.com/reference/files-resources Example JSON response showing a file list with total_count and entries array. ```json { "total_count": 1, "entries": [ { "id": "12345", "type": "file_version", "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc" } ] } ``` -------------------------------- ### Get Workflows Response Source: https://developer.box.com/reference/get-workflows Example JSON response for a successful get workflows request. ```json { "limit": 1000, "next_marker": "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii", "prev_marker": "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVih", "entries": [ { "id": "11446498", "type": "workflow", "name": "New Hire Workflow", "description": "This workflow sets off a new hire approval flow", "is_enabled": true, "flows": [ { "id": "12345", "type": "flow", "trigger": { "type": "trigger", "trigger_type": "WORKFLOW_MANUAL_START", "scope": [ { "type": "trigger_scope", "ref": "/event/source/parameters/folder", "object": { "type": "folder", "id": "12345" } } ] }, "outcomes": [ { "id": "12345", "type": "outcome", "name": "Task Approval Outcome", "action_type": "assign_task", "if_rejected": [ { "id": "12345", "type": "outcome", "name": "Approval Rejection Outcome", "action_type": "assign_task" } ] } ], "created_at": "2012-12-12T10:53:43-08:00", "created_by": { "id": "11446498", "type": "user" } } ] } ] } ``` -------------------------------- ### Example Source: https://support.box.com/hc/en-us/articles/9920431507603-Understanding-Information-Barriers A simple example. ```JavaScript console.log("Hello, world!"); ``` -------------------------------- ### GET /zip_downloads/{zip_download_id}/status Source: https://developer.box.com/reference/get-workflows Gets the download status of a zip archive. Valid for 12 hours after the download starts. ```APIDOC ## GET /zip_downloads/{zip_download_id}/status ### Description Returns the download status of a `zip` archive, allowing an application to inspect the progress of the download as well as the number of items that might have been skipped. This endpoint can only be accessed once the download has started. Subsequently this endpoint is valid for 12 hours from the start of the download. The URL of this endpoint should not be considered as fixed. Instead, use the Create zip download API to request to create a `zip` archive, and then follow the `status_url` field in the response to this endpoint. ### Method GET ### Endpoint /zip_downloads/{zip_download_id}/status ``` -------------------------------- ### Get Workflows for a Folder Source: https://developer.box.com/reference/get-workflows Retrieves workflows for a given folder. The cURL example uses the GET /2.0/workflows endpoint with a folder_id query parameter and an authorization header. The Python and TypeScript examples use the Box SDK methods get_workflows and getWorkflows respectively. ```cURL curl -i -X GET "https://api.box.com/2.0/workflows?folder_id=324234" \ -H "authorization: Bearer " ``` ```python admin_client.workflows.get_workflows(workflow_folder_id) ``` ```typescript await adminClient.workflows.getWorkflows({ folderId: workflowFolderId, } satisfies GetWorkflowsQueryParams); ``` -------------------------------- ### Initialize Box SDK with App Auth Source: https://developer.box.com/guides/embed/box-view/setup Use getPreconfiguredInstance to load configuration and getAppAuthClient to authenticate as an enterprise. ```javascript const sdk = BoxSDK.getPreconfiguredInstance(configJSON); const client = sdk.getAppAuthClient("enterprise"); ``` -------------------------------- ### Configure SDK (C#) Source: https://developer.box.com/guides/authentication/oauth2/with-sdk Initializes the Box SDK with client ID, client secret, and redirect URI. ```csharp var redirectUrl = "[REDIRECT_URI]"; var config = new BoxConfig("[CLIENT_ID]", "[CLIENT_SECRET]", new Uri(redirectUrl)); var sdk = new BoxClient(config); ``` -------------------------------- ### Get Sign Requests - Success Response Example Source: https://developer.box.com/reference/get-sign-requests Example JSON response for a successful get sign requests call. Shows the full structure of a sign request object, including signers, source files, signing log, and status fields. ```json { "limit": 1000, "next_marker": "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii", "entries": [ { "is_document_preparation_needed": true, "redirect_url": "https://www.example.com", "declined_redirect_url": "https://declined-redirect.com", "are_text_signatures_enabled": true, "email_subject": "Sign Request from Acme", "email_message": "Hello! Please sign the document below", "are_reminders_enabled": true, "name": "name", "prefill_tags": [ { "document_tag_id": "1234", "text_value": "text", "checkbox_value": true, "date_value": "2021-04-26" } ], "days_valid": 2, "external_id": "123", "template_id": "123075213-af2c8822-3ef2-4952-8557-52d69c2fe9cb", "external_system_name": "Box", "request_flow": "standard", "type": "sign-request", "source_files": [ { "id": "12345", "type": "file", "etag": "1" } ], "signers": [ { "email": "example@gmail.com", "role": "signer", "is_in_person": true, "order": 2, "embed_url_external_user_id": "1234", "redirect_url": "https://example.com", "declined_redirect_url": "https://declined-example.com", "login_required": true, "verification_phone_number": "6314578901", "signer_group_id": "cd4ff89-8fc1-42cf-8b29-1890dedd26d7", "suppress_notifications": false, "language": "en", "has_viewed_document": true, "signer_decision": { "type": "signed", "finalized_at": "2021-04-26T08:12:13.982Z", "additional_info": "Requesting changes before signing." }, "inputs": [ { "page_index": 4, "document_tag_id": "1234", "text_value": "text", "checkbox_value": true, "date_value": "2021-04-26", "type": "text", "content_type": "signature", "read_only": true, "validation": { "validation_type": "email" }, "reason": "I read and approve this document", "is_validated": true } ], "embed_url": "https://example.com", "iframeable_embed_url": "https://app.box.com/embed/sign/document/gfhr4222-a331-494b-808b-79bc7f3992a3/f14d7098-a331-494b-808b-79bc7f3992a4", "attachments": [ { "id": "12345", "name": "proof_of_identity.pdf" } ] } ], "signature_color": "blue", "id": "12345", "prepare_url": "https://prepareurl.com", "signing_log": { "id": "12345", "type": "file", "etag": "1", "sequence_id": "3", "name": "Contract.pdf", "sha1": "85136C79CBF9FE36BB9D05D0639C70C265C18D37", "file_version": { "id": "12345", "type": "file_version", "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc" } }, "status": "converting", "sign_files": { "files": [ { "id": "12345", "type": "file", "etag": "1", "sequence_id": "3", "name": "Contract.pdf", "sha1": "85136C79CBF9FE36BB9D05D0639C70C265C18D37", "file_version": { "id": "12345", "type": "file_version", "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc" } } ], "is_ready_for_download": true }, "auto_expire_at": "2021-04-26T08:12:13.982Z", "parent_folder": { "id": "12345", "type": "folder", "etag": "1", "sequence_id": "3", "name": "Contracts" }, "collaborator_level": "owner", "short_id": "SR-12345", "created_at": "2025-02-01T12:00:00Z", "finished_at": "2025-02-02T12:00:00Z", "error_code": "cfr11_validation_failed", "sender_email": "sender@box.com", "sender_id": 12345 } ] } ``` -------------------------------- ### File (Full) Example Source: https://developer.box.com/reference/files-resources Example of a full file object with all attributes, including status, classification, uploader, shared link options, collections, and download URLs. ```json { "id": "12345", "etag": "1", "type": "file", "sequence_id": "3", "name": "Contract.pdf", "sha1": "85136C79CBF9FE36BB9D05D0639C70C265C18D37", "file_version": { "id": "12345", "type": "file_version", "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc" } } ``` -------------------------------- ### Get Sign Request by ID - C# Source: https://developer.box.com/reference/get-sign-requests-id C# example using HttpClient to make a GET request. Ensure you have the System.Net.Http namespace. ```csharp using System; using System.Net.Http; using System.Net.Http.Headers; var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "YOUR_ACCESS_TOKEN"); var response = await client.GetAsync("https://api.box.com/2.0/sign_requests/12345"); var content = await response.Content.ReadAsStringAsync(); Console.WriteLine(content); ``` -------------------------------- ### GET /collections Source: https://developer.box.com/guides/collections/list This snippet documents the GET /collections endpoint, which lists all collections for a user. It includes the cURL request example and references to SDK methods. ```APIDOC ## GET /collections ### Description Lists all collections for a user. ### Method GET ### Endpoint https://api.box.com/2.0/collections ### Parameters #### Headers - **authorization** (string) - Required - Bearer token for authentication. ### Request Example ``` curl -i -X GET "https://api.box.com/2.0/collections" \ -H "authorization: Bearer " ``` ### Response #### Success Response (200) Returns a list of collections for the user. #### Response Example (No response body example provided in the source.) ``` -------------------------------- ### Configure SDK in Java Source: https://developer.box.com/guides/authentication/oauth2/with-sdk Import the BoxAPIConnection class to begin setting up your connection. ```java import com.box.sdk.BoxAPIConnection; String authorizationUrl ``` -------------------------------- ### Create Hub and Review Files Source: https://developer.box.com/tutorials/company-brain Creates a hub, reviews a file, builds governance, and prints domain, health score, and summary. ```python review = review_file(item.id) governance = build_governance(review) print(f" Domain: {governance['domain']}") print(f" Health: {governance['contentHealthScore']}") print(f" Summary: ``` -------------------------------- ### Copy Hub API Examples Source: https://developer.box.com/guides/hubs-api/hubs/copy-hub Code examples for copying a hub using the Box API. The Python and .NET examples show the method calls with parameters for the hub ID, title, and description. The Swift example is incomplete, showing only the start of a try statement. ```python client.hubs.copy_hub_v2025_r0(created_hub.id, title=copied_hub_title, description=copied_hub_description) ``` ```csharp await client.Hubs.CopyHubV2025R0Async(hubId: createdHub.Id, requestBody: new HubCopyRequestV2025R0() { Title = copiedHubTitle, Description = copiedHubDescription }); ``` ```swift try ``` -------------------------------- ### Install Box .NET SDK with Package Manager Source: https://developer.box.com/guides/getting-started Run this command in the Package Manager Console to install the Box.V2.Core package for .NET Framework or .NET Core. ```powershell PM> Install-Package Box.V2.Core ``` -------------------------------- ### Get Hub Items with Box CLI, cURL, and Node/TypeScript Source: https://developer.box.com/guides/hubs-api/hubs-items/hub-items These commands call the GET /2.0/hub_items endpoint with the hub ID. The Box CLI example uses the command 'box hubs:items 12345'. The cURL example includes the Authorization header with an access token and the 'box-version: 2025.0' header. The Node/TypeScript v10 example uses the client method getHubItemsV2025R0 with the hubId parameter. ```shellscript box hubs:items 12345 ``` ```shellscript curl -i -X GET "https://api.box.com/2.0/hub_items?hub_id=HUB_ID" \ -H "Authorization: Bearer " \ -H "box-version: 2025.0" ``` ```typescript await client.hubItems.getHubItemsV2025R0({ hubId: createdHub.id, } ``` -------------------------------- ### GET /workflows Source: https://developer.box.com/reference/groups-resources Lists workflows that can be manually started for a given folder. ```APIDOC ## GET /workflows ### Description Returns a list of workflows that act on a given `folder ID` and have a flow with a trigger type of `WORKFLOW_MANUAL_START`. Your application must be authorized to use the `Manage Box Relay` application scope within the developer console to use this endpoint. ### Method GET ### Endpoint /workflows ### Parameters #### Query Parameters - **folder_id** (string) - Required - The ID of the folder to list workflows for. ### Response #### Success Response (200) - **entries** (array) - List of workflow objects. #### Response Example ```json { "entries": [] } ``` ``` -------------------------------- ### Python script to create a hub and populate with sales folders Source: https://developer.box.com/tutorials/sales-rfp-answer-bank Creates a new hub and populates it with sales content folders. Requires a Box client with Client Credentials Grant and 'Generate User Access Tokens' enabled. Uses environment variables via dotenv. ```python import os from dotenv import load_dotenv from box_sdk_gen import ( BoxClient, FolderReferenceV2025R0, HubItemOperationV2025R0, HubItemOperationV2025R0ActionField, ) from box_client import get_box_client load_dotenv() def ``` -------------------------------- ### Get sign request by ID with Java v5 Source: https://developer.box.com/guides/box-sign/list-sign-requests Use the Box Java SDK v5 to get a sign request by its ID. The example shows how to get the sign request info and optionally specify fields. ```Java v5 BoxSignRequest signRequest = new BoxSignRequest(api, id); BoxSignRequest.Info signRequestInfo = signRequest.getInfo(); //using `fields` parameter BoxSignRequest.Info signRequestInfoWithFields = signRequest.getInfo("status") ``` -------------------------------- ### Get Sign Request by ID - Java Source: https://developer.box.com/reference/get-sign-requests-id Java example using OkHttp to make a GET request to the Box Sign API. Replace the access token and sign request ID. ```java OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://api.box.com/2.0/sign_requests/12345") .get() .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Create project directory Source: https://developer.box.com/tutorials/company-brain Creates a new project directory and changes into it. ```bash mkdir company-brain && cd company-brain ``` -------------------------------- ### Successful response for Get Sign Templates Source: https://developer.box.com/reference/get-sign-templates Example JSON response from the Get Sign Templates endpoint, containing a list of sign templates with details such as id, name, signers, and settings. ```json { "limit": 1000, "next_marker": "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii", "prev_marker": "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVih", "entries": [ { "type": "sign-template", "id": "4206996024-14944f75-c34b-478a-95a1-264b1ff80d35", "name": "Official contract", "email_subject": "Sign Request from Acme", "email_message": "Hello! Please sign the document below", "days_valid": 2, "parent_folder": { "id": "12345", "type": "folder", "etag": "1", "sequence_id": "3", "name": "Contracts" }, "source_files": [ { "id": "12345", "type": "file", "etag": "1", "sequence_id": "3", "name": "Contract.pdf", "sha1": "85136C79CBF9FE36BB9D05D0639C70C265C18D37", "file_version": { "id": "12345", "type": "file_version", "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc" } } ], "are_fields_locked": false, "are_options_locked": true, "are_recipients_locked": false, "are_email_settings_locked": true, "are_files_locked": true, "signers": [ { "inputs": [ { "page_index": 4, "document_tag_id": "1234", "text_value": "text", "checkbox_value": true, "date_value": "2021-04-26", "type": "text", "content_type": "text", "is_required": true, "document_id": "123075213-eb54b537-8b25-445e-87c1-5a1c67d8cbd7", "dropdown_choices": [ "Yes", "No", "Maybe" ], "group_id": "da317330-225a-4c72-89ad-0d6dcaaf4df6", "coordinates": { "x": 0.672258592471358, "y": 0.18654283173599448 }, "dimensions": { "width": 0.2618657937806874, "height": 0.05311728090109673 }, "label": "Legal name", "read_only": true, "validation": { "validation_type": "email" } } ], "email": "example@mail.com", "role": "signer", "is_in_person": true, "order": 2, "signer_group_id": "cd4ff89-8fc1-42cf-8b29-1890dedd26d7", "label": "Jane Doe", "public_id": "RJZYYVPR", "is_password_required": true, "is_phone_number_required": true, "login_required": true } ], "additional_info": { "non_editable": [ "email_subject", "name" ], "required": { "signers": [ [ "email" ], [ "email" ] ] } }, "ready_sign_link": { "url": "\"https://app.box.com/sign/\nready-sign-link/a1cdf2c7-fa81-4a67-8163-1e5f4dbe5178\"", "name": "Official contract", "instructions": "Hello! Please sign the document below", "folder_id": "12345", "is_notification_disabled": true, "is_active": false }, "custom_branding": { "company_name": "Corporation inc.", "logo_uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA\nAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A\n8AAQUBAScY42YAAAAASUVORK5CYII=", "branding_color": "9E5E6F", "email_footer_text": "Contact email email@mail.com" }, "request_flow": "standard" } ] } ``` -------------------------------- ### Create intake.py to review and stamp governance metadata Source: https://developer.box.com/tutorials/company-brain Creates a script that reviews every file in a staging folder, builds governance metadata from the review, and applies it as a metadata instance. Uses environment variables for the metadata template key and staging folder ID. ```python import os from dotenv import load_dotenv from box_sdk_gen import BoxClient, CreateFileMetadataByIdScope from box_client import get_box_client from review import review_file load_dotenv() def build_governance(review: dict) -> dict: return { "domain": review.get("suggested_domain", "other"), "owner": "unassigned", "status": "staged", "contentHealthScore": review.get("content_health_score", 0), "summary": review.get("summary", ""), "tags": review.get("suggested_tags", ""), "reviewNotes": review.get("review_notes", ""), } def apply_governance(client: BoxClient, file_id: str, governance: dict): template_key = os.getenv("BOX_METADATA_TEMPLATE_KEY") client.file_metadata.create_file_metadata_by_id( file_id=file_id, scope=CreateFileMetadataByIdScope.ENTERPRISE, template_key=template_key, request_body=governance, ) def process_staging_folder(client: BoxClient, folder_id: str): items = client.folders.get_folder_items(folder_id).entries for item in items: if item.type != "file": continue print(f"\nReviewing: {item.name} ({item.id})") review = review_file(item.id) governance = build_governance(review) print(f" Domain: {governance['domain']}") print(f" Health: {governance['contentHealthScore']}") print(f" Summary: {governance['summary']}") if governance["reviewNotes"]: print(f" Notes: {governance['reviewNotes']}") apply_governance(client, item.id, governance) print(" Governance metadata applied.") def main(): client = get_box_client() staging_folder_id = os.getenv("STAGING_FOLDER_ID") process_staging_folder(client, staging_folder_id) if __name__ == "__main__": main() ``` -------------------------------- ### Initialize Box SDK with JWT Authentication Source: https://developer.box.com/guides/embed/box-view/setup This snippet demonstrates how to import the Box SDK, read a configuration file, and initialize the SDK client. ```javascript const BoxSDK = require("box-node-sdk"); const fs = require("fs"); const configJSON = JSON.parse(fs.readFileSync("/path/to/config.json")); const sdk = BoxSDK ``` -------------------------------- ### Get sign request by ID with Python v4 Source: https://developer.box.com/guides/box-sign/list-sign-requests Use the Box Python SDK v4 to get a sign request by its ID. The example prints the sign request ID. ```Python v4 sign_request = client.sign_request(sign_request_id='12345').get() print(f'Sign Request ID is {sign_request.id}') ``` -------------------------------- ### Upload file and list root folder with Box Python SDK Source: https://developer.box.com/guides/getting-started Create a Python virtual environment, install the Box Python SDK (version 10 or later), obtain a client with a developer token, then upload a file and list root folder items. The developer token expires one hour after generation; store credentials in a .env file for production. ```bash python3 -m venv .venv source .venv/bin/activate ``` ```bash pip install "boxsdk>=10" ``` ```python from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth, UploadFileAttributes, UploadFileAttributesParentField import json auth = BoxDeveloperTokenAuth(token="YOUR_DEVELOPER_TOKEN") client = BoxClient(auth=auth) ``` ```python with open("demo-invoice-20tax-2.pdf", "rb") as file_content_stream: uploaded_file = client.uploads.upload_file( UploadFileAttributes( name="demo-invoice-20tax-2.pdf", parent=UploadFileAttributesParentField(id="0"), ), file_content_stream, ) items = client.folders.get_folder_items("0") print(json.dumps(items.to_dict(), indent=2)) ``` -------------------------------- ### Start Box proxy server with port and endpoints Source: https://developer.box.com/guides/archives Starts the Box proxy server on a port from the environment or default 3001, and logs the running endpoints: POST /api/box/proxy and GET /api/health. ```javascript const PORT = process.env.PORT || 3001; app.listen(PORT, () => { console.log(`Box proxy server running on port ${PORT}`); console.log('Available endpoints:'); console.log(' POST /api/box/proxy - Box API proxy'); console.log(' GET /api/health - Health check'); }); module.exports = app; ``` -------------------------------- ### Create a Sign Request using .NET v6 Source: https://developer.box.com/guides/box-sign/create-sign-request Demonstrates the setup of source files for a sign request using the .NET v6 SDK. ```csharp var sourceFiles = new List { new ``` -------------------------------- ### Get sign request by ID with .NET v6 Source: https://developer.box.com/guides/box-sign/list-sign-requests Use the Box .NET SDK v6 to get a sign request by its ID. The example uses a hardcoded sign request ID. ```.NET v6 BoxSignRequest signRequest = await client.SignRequestsManager.GetSignRequestByIdAsync("12345"); ``` -------------------------------- ### Get sign request by ID with Java v10 Source: https://developer.box.com/guides/box-sign/list-sign-requests Use the Box Java SDK to get a sign request by its ID. The example uses a previously created sign request's ID. ```Java v10 client.getSignRequests().getSignRequestById(createdSignRequest.getId()) ``` -------------------------------- ### Marker-based pagination example in Go Source: https://developer.box.com/guides/api-calls/pagination/marker-based This example shows how to use marker-based pagination with the Box Go SDK. It retrieves folder items page by page using the marker parameter. ```go package main import ( "context" "fmt" "github.com/box/box-go-sdk" ) func main() { client, err := box.NewClient(box.WithToken("YOUR_ACCESS_TOKEN")) if err != nil { panic(err) } var items []box.Item marker := "" for { resp, err := client.Folders.GetItems(context.Background(), "0", &box.GetItemsParams{ Limit: 100, Marker: marker, }) if err != nil { panic(err) } items = append(items, resp.Entries...) if resp.NextMarker == "" { break } marker = resp.NextMarker } fmt.Println(items) } ``` -------------------------------- ### Get sign request by ID with Swift v10 Source: https://developer.box.com/guides/box-sign/list-sign-requests Use the Box Swift SDK to get a sign request by its ID. The example uses a previously created sign request's ID. ```Swift v10 try await client.signRequests.getSignRequestById(signRequestId: createdSignRequest.id!) ``` -------------------------------- ### Handle Sign Request Input Types Source: https://developer.box.com/guides/box-sign/document-types/structured Example demonstrating how to process different input types and prepare a sign request URL. ```python elif content_type == SignRequestSignerInputTypeField.DATE: value = input.date_value print( f"{input.type.value}: {value if value is not None else ''}" ) print(f"Prepare url: {sign_request.prepare_url}") ``` -------------------------------- ### Get sign request by ID with .NET v10 Source: https://developer.box.com/guides/box-sign/list-sign-requests Use the Box .NET SDK to get a sign request by its ID. The example uses a previously created sign request's ID. ```.NET v10 await client.SignRequests.GetSignRequestByIdAsync(signRequestId: NullableUtils.Unwrap(createdSignRequest.Id)); ``` -------------------------------- ### Get sign request by ID with Python v10 Source: https://developer.box.com/guides/box-sign/list-sign-requests Use the Box Python SDK to get a sign request by its ID. The example uses a previously created sign request's ID. ```Python v10 client.sign_requests.get_sign_request_by_id(created_sign_request.id) ``` -------------------------------- ### List Files Response Example Source: https://developer.box.com/reference/legal-hold-policy-assignments-resources Example response for listing files with pagination markers and an entries array containing a file object. ```json { "limit": 1000, "next_marker": "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii", "prev_marker": "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVih", "entries": [ { "id": "12345", "etag": "1", "type": "file", "sequence_id": "3", "name": "Contract.pdf", "sha1": "85136C79CBF9FE36BB9D05D0639C70C265C18D37", "file_version": { "type": "file_version", "id": "12345", "sha1": "134b65991ed38fc9628e0d9b30b09b8d8c6c5b1a" } } ] } ``` -------------------------------- ### Get sign request by ID with Node/TypeScript v10 Source: https://developer.box.com/guides/box-sign/list-sign-requests Use the Box Node SDK to get a sign request by its ID. The example uses a previously created sign request's ID. ```Node/TypeScript v10 await client.signRequests.getSignRequestById(createdSignRequest.id!); ``` -------------------------------- ### Example GitHub Action Source: https://developer.box.com/reference/task-assignments-resources An example GitHub Actions workflow that triggers on push and prints hello world. ```yaml name: GitHub Actions Demo on: [push] jobs: Explore-GitHub-Actions: runs-on: ubuntu-latest steps: - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." ``` -------------------------------- ### Install uv on Windows Source: https://developer.box.com/guides/box-mcp/self-hosted Install the uv package manager on Windows using PowerShell. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Get sign request by ID with Node v4 Source: https://developer.box.com/guides/box-sign/list-sign-requests Use the Box Node SDK v4 to get a sign request by its ID. The example logs the sign request ID and the number of source files. ```Node v4 const sr = await client.signRequests.getById({ sign_request_id: 12345, }); console.log( `Sign request id ${sr.id} contains ${sr.source_files.length} files` ); ``` -------------------------------- ### List Hubs with getHubsV2025R0 (Swift and Java) Source: https://developer.box.com/guides/hubs-api/hubs/list-hubs The Swift example calls the Box Hubs API to list hubs with query parameters for scope, sort, and direction. The Java example is truncated in the source and shows the start of a similar call to getHubsV2025R0. ```swift try await client.hubs.getHubsV2025R0(queryParams: GetHubsV2025R0QueryParams(scope: "all", sort: "name", direction: GetHubsV2025R0QueryParamsDirectionField.asc)) ``` ```java client.getHubs().getHubsV2025R0(new ``` -------------------------------- ### Initialize Box Client Source: https://developer.box.com/tutorials/sales-rfp-answer-bank Sets up the Box SDK client with OAuth 2.0 credentials. ```javascript const BoxSDK = require('box-node-sdk'); const sdk = new BoxSDK({ clientID: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET' }); const client = sdk.getAppAuthClient('enterprise', 'YOUR_ENTERPRISE_ID'); ``` -------------------------------- ### Upload file and list root folder with Box Node.js SDK Source: https://developer.box.com/guides/getting-started Install the Box Node.js SDK (requires Node.js 22 or later), import the SDK, obtain a client with a developer token, then upload a file and list root folder items. The developer token expires one hour after generation. ```bash npm install box ``` ```javascript import BoxSDK from 'box/sdk'; // ESM const BoxSDK = require('box/sdk'); // CommonJS ``` ```javascript const { BoxClient, BoxDeveloperTokenAuth } = require('box/sdk'); const auth = new BoxDeveloperTokenAuth({ token: 'YOUR_DEVELOPER_TOKEN' }); const client = new BoxClient({ auth }); ``` ```javascript const fs = require('fs'); const attrs = { name: 'demo-invoice-20tax-2.pdf', parent: { id: '0' } }; const body = { attributes: attrs, file: fs.createReadStream('demo-invoice-20tax-2.pdf'), }; const files = await client.uploads.uploadFile(body); const file = files.entries[0]; console.log(`File uploaded with id ${file.id}, name ${file.name}`); const items = await client.folders.getFolderItems('0'); console.log(JSON.stringify(items, null, 2)); ``` -------------------------------- ### Get Hub Collaboration by ID Source: https://developer.box.com/guides/hubs-api/hubs-collaborations/hub-collaborations Retrieve a hub collaboration by its ID using the Box API. The cURL example requires an access token and the box-version header set to 2025.0. The Node/TypeScript and Python examples use the corresponding SDK methods. ```shellscript box hubs:collaborations:get HUB_COLLABORATION_ID ``` ```shellscript curl -i -X GET "https://api.box.com/2.0/hub_collaborations/HUB_COLLABORATION_ID" \ -H "Authorization: Bearer " \ -H "box-version: 2025.0" ``` ```typescript await client.hubCollaborations.getHubCollaborationByIdV2025R0(hubCollaborationId); ``` ```python client.hub_collaborations.get_hub_collaboration_by_id_v2025_r0(hub_collaboration_id) ``` -------------------------------- ### cURL: Get Sign Request by ID Source: https://developer.box.com/reference/get-sign-requests-id Example of retrieving a sign request by its ID using cURL. The sign_request_id is included in the URL path. ```bash curl --location --request GET 'https://api.box.com/2.0/sign_requests/12345' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' ``` -------------------------------- ### Python: List Hubs Source: https://developer.box.com/guides/hubs-api/index Example of listing all hubs using the Python SDK. Requires a Box developer account and an access token. ```python from boxsdk import Client from boxsdk.auth import OAuth2 oauth = OAuth2( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', access_token='YOUR_ACCESS_TOKEN' ) client = Client(oauth) hubs = client.hubs() for hub in hubs: print(f'Hub ID: {hub.id}, Name: {hub.name}') ``` -------------------------------- ### cURL: Get Hub Items Source: https://developer.box.com/guides/hubs-api/index Example of retrieving items in a hub using cURL. Requires a Box developer account and an access token. ```bash curl -X GET "https://api.box.com/2.0/hubs/{hub_id}/items" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` -------------------------------- ### Add file to hub with manageHubItemsV2025R0 Source: https://developer.box.com/guides/hubs-api/hubs-items/hub-items Adds a file to a hub using the Box API. The TypeScript example uses the `manageHubItemsV2025R0` method with an operations array containing an 'add' action and a `FileReferenceV2025R0` item. The Python example shows the start of the equivalent `manage_hub_items_v2025_r0` call. ```typescript client.hubItems.manageHubItemsV2025R0(createdHub.id, { operations: [ { action: 'add' as HubItemOperationV2025R0ActionField, item: new FileReferenceV2025R0({ id: file.id }), } satisfies HubItemOperationV2025R0, ], } satisfies HubItemsManageRequestV2025R0); ``` ```python client.hub_items.manage_hub_items_v2025_r0( ```