### Get User Info (boxsdk) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md In the old SDK, you first created a class representing a User, then called methods on it. This example shows how to get user information. ```python user = client.user(user_id='123456') ``` -------------------------------- ### Install Box Python SDK Gen Source: https://github.com/box/box-python-sdk-gen/blob/main/README.md Install the base SDK using pip. For JWT authentication, install with the 'jwt' extra. ```console pip install box-sdk-gen ``` ```console pip install "box-sdk-gen[jwt]" ``` -------------------------------- ### Install box-sdk-gen Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md Use pip to install the new Box Python SDK GENERATED. This can be used alongside the legacy SDK. ```console pip install box-sdk-gen ``` -------------------------------- ### Create User (boxsdk) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md This example demonstrates creating a new user using the legacy `boxsdk`. ```python user = client.create_user(name='Some User') ``` -------------------------------- ### Get User Info (box-sdk-gen) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md The new SDK uses a manager approach. Use the `UserManager` via `client.users` to get user information by ID. ```python user = client.users.get_user_by_id(user_id='123456') ``` -------------------------------- ### Start Workflow Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/workflows.md Initiates a flow with a trigger type of WORKFLOW_MANUAL_START. Requires 'Manage Box Relay' scope. ```APIDOC ## POST /workflows/{workflow_id}/start ### Description Initiates a flow with a trigger type of `WORKFLOW_MANUAL_START`. You application must be authorized to use the `Manage Box Relay` application scope within the developer console. ### Method POST ### Endpoint /workflows/{workflow_id}/start ### Parameters #### Path Parameters - **workflow_id** (str) - Required - The ID of the workflow. Example: "12345" #### Query Parameters - **extra_headers** (Dict[str, Optional[str]]) - Optional - Extra headers that will be included in the HTTP request. #### Request Body - **type** (StartWorkflowType) - Optional - The type of the parameters object. - **flow** (StartWorkflowFlow) - Required - The flow that will be triggered. - **files** (List[StartWorkflowFiles]) - Required - The array of files for which the workflow should start. All files must be in the workflow's configured folder. - **folder** (StartWorkflowFolder) - Required - The folder object for which the workflow is configured. - **outcomes** (List[Outcome]) - Optional - A configurable outcome the workflow should complete. ### Request Example { "example": "{\"type\": \"workflow_parameters\", \"flow\": {\"type\": \"flow\", \"id\": \"12345\"}, \"files\": [{\"type\": \"file\", \"id\": \"67890\"}], \"folder\": {\"type\": \"folder\", \"id\": \"0\"}}" } ### Response #### Success Response (200) - **None** - Starts the workflow. #### Response Example { "example": "" } ``` -------------------------------- ### Get File Information Source: https://context7.com/box/box-python-sdk-gen/llms.txt Retrieves detailed information about a file, allowing selection of specific fields to return. ```python file = client.files.get_file_by_id( file_id="12345", fields=["name", "size", "created_at", "modified_at", "is_externally_owned", "has_collaborations"] ) print(f"File: {file.name}, Size: {file.size} bytes") ``` -------------------------------- ### Get Zip Download Status Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/zip_downloads.md Check the status of a zip archive download. This endpoint is accessible only after the download has started and is valid for 12 hours. It provides progress information and details on skipped items. ```python client.zip_downloads.get_zip_download_status(zip_download.status_url) ``` -------------------------------- ### Authenticate with Developer Token and List Folder Items Source: https://github.com/box/box-python-sdk-gen/blob/main/README.md Demonstrates how to authenticate using a Developer Token and list the names of all items within the root folder. Ensure you replace 'INSERT YOUR DEVELOPER TOKEN HERE' with your actual token. ```python from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth def main(token: str): auth: BoxDeveloperTokenAuth = BoxDeveloperTokenAuth(token=token) client: BoxClient = BoxClient(auth=auth) for item in client.folders.get_folder_items('0').entries: print(item.name) if __name__ == '__main__': main('INSERT YOUR DEVELOPER TOKEN HERE') ``` -------------------------------- ### Initialize Box Client with Developer Token Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/authentication.md Use a developer token for quick testing and development. This token is short-lived and cannot be refreshed. ```python from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth auth = BoxDeveloperTokenAuth(token="DEVELOPER_TOKEN_GOES_HERE") client = BoxClient(auth=auth) me = client.users.get_user_me() print(f"My user ID is {me.id}") ``` -------------------------------- ### GET /sign_requests/{sign_request_id} Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/sign_requests.md Gets a sign request by ID. This operation is performed by calling the `get_sign_request_by_id` function. ```APIDOC ## GET /sign_requests/{sign_request_id} ### Description Gets a sign request by ID. ### Method GET ### Endpoint /sign_requests/{sign_request_id} ### Parameters #### Path Parameters - **sign_request_id** (str) - Required - The ID of the signature request. Example: "33243242" #### Query Parameters - **extra_headers** (Optional[Dict[str, Optional[str]]]) - Optional - Extra headers that will be included in the HTTP request. ### Request Example ```python client.sign_requests.get_sign_request_by_id(created_sign_request.id) ``` ### Response #### Success Response (200) - **SignRequest** (SignRequest) - Returns a signature request. #### Response Example ```json { "type": "sign_request", "id": "12345", "status": "sent" } ``` ``` -------------------------------- ### Create Client with User Header (New SDK) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md Methods that modify object state in the new SDK return a new instance with a 'with_' prefix, such as creating a client impersonating a user. ```python from box_sdk_gen import BoxClient as_user_client: BoxClient = client.with_as_user_header('USER_ID') ``` -------------------------------- ### Get Authorization URL (Old SDK) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md Use this method in the old boxsdk to get the authorization URL and CSRF token. ```python from boxsdk import OAuth2 auth = OAuth2( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', ) auth_url, csrf_token = auth.get_authorization_url('http://YOUR_REDIRECT_URL') ``` -------------------------------- ### Get AI agent by agent ID Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/ai_studio.md Gets an AI Agent using the `agent_id` parameter. This operation is performed by calling the `get_ai_agent_by_id` function. ```APIDOC ## GET /ai/agents/:agent_id ### Description Gets an AI Agent using the `agent_id` parameter. ### Method GET ### Endpoint /ai/agents/:agent_id ### Query Parameters - **fields** (List[str]) - Optional - The fields to return in the response. - **extra_headers** (Dict[str, Optional[str]]) - Optional - Extra headers that will be included in the HTTP request. ### Request Example ```python client.ai_studio.get_ai_agent_by_id(created_agent.id, fields=["ask"]) ``` ``` -------------------------------- ### Create metadata instance on file Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/file_metadata.md Applies an instance of a metadata template to a file. For 'global.properties', any key-value pair is accepted; otherwise, values must be present in the template. ```python client.file_metadata.create_file_metadata_by_id( file.id, CreateFileMetadataByIdScope.ENTERPRISE, template_key, { "name": "John", "age": 23, "birthDate": "2001-01-03T02:20:50.520Z", "countryCode": "US", "sports": ["basketball", "tennis"], }, ) ``` -------------------------------- ### Initialize Box Client with JWT Auth from Direct Configuration Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/authentication.md Authenticate as an enterprise using JWT by providing configuration details directly to the JWTConfig constructor. This is an alternative to loading from a file. ```python from box_sdk_gen import BoxClient, BoxJWTAuth, JWTConfig jwt_config = JWTConfig( client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", jwt_key_id="YOUR_JWT_KEY_ID", private_key="YOUR_PRIVATE_KEY", private_key_passphrase="PASSPHRASE", enterprise_id="YOUR_ENTERPRISE_ID", ) auth = BoxJWTAuth(config=jwt_config) service_account_client = BoxClient(auth=auth) ``` -------------------------------- ### Get Shared Link for File Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/shared_links_files.md Retrieves the shared link information for a specific file. Ensure the `file_id` is correct and specify `shared_link` to get the relevant fields. ```python client.shared_links_files.get_shared_link_for_file(file_id, "shared_link") ``` -------------------------------- ### Get Specific Comment Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/comments.md Retrieves the full details of a single comment by its ID. Use this to get the message and metadata of a specific comment. Requires the comment ID. ```python client.comments.get_comment_by_id(new_comment.id) ``` -------------------------------- ### Create Metadata Instance on Folder Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/folder_metadata.md 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. ```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. ### Method POST ### Endpoint /folders/{folder_id}/metadata/{scope}/{template_key} ### Parameters #### Path Parameters - **folder_id** (str) - 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" - **scope** (CreateFolderMetadataByIdScope) - Required - The scope of the metadata template. Example: "global" - **template_key** (str) - Required - The name of the metadata template. Example: "properties" #### Query Parameters None #### Request Body - **request_body** (Dict) - Required - Request body of createFolderMetadataById method ### Request Example ```json { "name": "John", "age": 23, "birthDate": "2001-01-03T02:20:50.520Z", "countryCode": "US", "sports": ["basketball", "tennis"] } ``` ### Response #### Success Response (200) - **MetadataFull** (MetadataFull) - Returns the instance of the template that was applied to the folder, including the data that was applied to the template. #### Response Example None ``` -------------------------------- ### Get Shared Link for Web Link Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/shared_links_web_links.md Retrieves the shared link information for a specific web link. The `fields` argument must be set to 'shared_link' to get this information. ```python client.shared_links_web_links.get_shared_link_for_web_link(web_link_id, "shared_link") ``` -------------------------------- ### Get File Information (Old SDK) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md In the old SDK, file information was dynamically mapped into classes at runtime, making it difficult to predict response fields. ```python file = client.file(file_id='12345678').get() ``` -------------------------------- ### GET /sign_requests Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/sign_requests.md Gets signature requests created by a user. If the `sign_files` and/or `parent_folder` are deleted, the signature request will not return in the list. This operation is performed by calling the `get_sign_requests` function. ```APIDOC ## GET /sign_requests ### Description Gets signature requests created by a user. ### Method GET ### Endpoint /sign_requests ### Parameters #### Query Parameters - **marker** (Optional[str]) - Optional - Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. This requires `usemarker` to be set to `true`. - **limit** (Optional[int]) - Optional - The maximum number of items to return per page. - **senders** (Optional[List[str]]) - Optional - A list of sender emails to filter the signature requests by sender. If provided, `shared_requests` must be set to `true`. - **shared_requests** (Optional[bool]) - Optional - If set to `true`, only includes requests that user is not an owner, but user is a collaborator. Collaborator access is determined by the user access level of the sign files of the request. Default is `false`. Must be set to `true` if `senders` are provided. - **extra_headers** (Optional[Dict[str, Optional[str]]]) - Optional - Extra headers that will be included in the HTTP request. ### Request Example ```python client.sign_requests.get_sign_requests() ``` ### Response #### Success Response (200) - **SignRequests** (SignRequests) - Returns a collection of sign requests. #### Response Example ```json { "total_count": 2, "entries": [ { "type": "sign_request", "id": "12345" } ] } ``` ``` -------------------------------- ### Set Up Proxy for Box API Calls Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/client.md Configure a new client to use a proxy for API requests by calling `client.with_proxy()`. This method supports HTTP/S proxies with basic authentication; username and password are optional. ```python new_client = client.with_proxy( ProxyConfig(url="http://proxy.com", username="username", password="password") ) ``` -------------------------------- ### Get Trashed File by ID with Box SDK Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/trashed_files.md Retrieves a specific file that has been moved to the trash. This is only applicable if the file itself was trashed, not its parent folder. Use this to get details about a trashed file. ```python client.trashed_files.get_trashed_file_by_id(file.id) ``` -------------------------------- ### Search for Content Source: https://context7.com/box/box-python-sdk-gen/llms.txt Searches for files, folders, and web links across Box. This example snippet is incomplete and requires further context for full functionality. ```python from box_sdk_gen import MetadataFilter, MetadataFilterScopeField ``` -------------------------------- ### Create Webhook Source: https://context7.com/box/box-python-sdk-gen/llms.txt Set up a webhook to receive notifications for specific Box events like file uploads or downloads. This requires a target resource ID and a callback URL. ```python from box_sdk_gen import CreateWebhookTarget, CreateWebhookTargetTypeField, CreateWebhookTriggers webhook = client.webhooks.create_webhook( CreateWebhookTarget(id="12345", type=CreateWebhookTargetTypeField.FOLDER), "https://example.com/webhook-endpoint", [CreateWebhookTriggers.FILE_UPLOADED, CreateWebhookTriggers.FILE_DOWNLOADED] ) print(f"Webhook created with ID: {webhook.id}") ``` -------------------------------- ### Get Shared Link for Web Link Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/shared_links_web_links.md Retrieves the shared link information for a specific web link. This is used to get details about an existing shared link associated with a web link. ```APIDOC ## GET /web_links/:web_link_id ### Description Gets the information for a shared link on a web link. This operation retrieves the base representation of a web link with the additional shared link information. ### Method GET ### Endpoint /web_links/:web_link_id ### Parameters #### Path Parameters - **web_link_id** (str) - The ID of the web link. Example: "12345" #### Query Parameters - **fields** (str) - Explicitly request the `shared_link` fields to be returned for this item. ### Request Example ```python client.shared_links_web_links.get_shared_link_for_web_link(web_link_id, "shared_link") ``` ### Response #### Success Response (200) - **WebLink** (WebLink) - Returns the base representation of a web link with the additional shared link information. #### Response Example ```json { "type": "web_link", "id": "12345", "shared_link": { "url": "https://app.box.com/shared/static/abcde.pdf", "name": "example.pdf", "login_required": false, "can_preview": true, "can_download": true, "can_edit": false, "is_password_protected": true, "expires_at": null, "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } } ``` ``` -------------------------------- ### JWT Auth from Settings File (Old SDK) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md The old SDK used a static method 'from_settings_file' on JWTAuth to load configuration. ```python from boxsdk import JWTAuth, Client auth = JWTAuth.from_settings_file('/path/to/config.json') client = Client(auth) ``` -------------------------------- ### Get Folder Information by ID Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/folders.md Retrieves details for a specific folder using its ID. Supports pagination and field selection for folder items. Use this to get basic folder information and its contents. ```python client.folders.get_folder_by_id("0") ``` -------------------------------- ### Get Group Membership by ID Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/memberships.md Retrieves a specific group membership using its ID. Only group admins or users with admin-level permissions can access this information. Use this to get details about a particular membership. ```python client.memberships.get_group_membership_by_id(group_membership.id) ``` -------------------------------- ### Obtain Service Account Token (Old SDK) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md Use `CCGAuth` with client ID, client secret, and enterprise ID to authenticate as an enterprise. ```python from boxsdk import CCGAuth, Client auth = CCGAuth( client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", enterprise_id="YOUR_ENTERPRISE_ID", ) client = Client(auth) ``` -------------------------------- ### Complete Box OAuth Workflow with Flask Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/authentication.md This Flask app example demonstrates the complete Box OAuth workflow, including obtaining an authorization URL, handling the callback, exchanging the auth code for tokens, and listing items in the root folder. ```python from flask import Flask, request, redirect from box_sdk_gen import BoxClient, BoxOAuth, OAuthConfig, GetAuthorizeUrlOptions app = Flask(__name__) AUTH = BoxOAuth( OAuthConfig(client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET") ) @app.route("/") def get_auth(): auth_url = AUTH.get_authorize_url( options=GetAuthorizeUrlOptions(redirect_uri="YOUR_REDIRECT_URL") ) return redirect(auth_url, code=302) @app.route("/oauth2callback") def callback(): AUTH.get_tokens_authorization_code_grant(request.args.get("code")) client = BoxClient(auth=AUTH) items_in_root_folder = [ item.name for item in client.folders.get_folder_items(folder_id="0").entries ] return ", ".join(items_in_root_folder) if __name__ == "__main__": app.run(port=4999) ``` -------------------------------- ### Get Metadata Template by Name Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/metadata_templates.md Fetches a specific metadata template using its scope (e.g., 'enterprise' or 'global') and its unique template key. This is the primary way to get template details when the template key is known. ```python client.metadata_templates.get_metadata_template( GetMetadataTemplateScope.ENTERPRISE, template.template_key ) ``` -------------------------------- ### Get Collaboration Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/user_collaborations.md Retrieves a single collaboration by its ID. ```APIDOC ## GET /collaborations/{collaboration_id} ### Description Retrieves a single collaboration. ### Method GET ### Endpoint /collaborations/{collaboration_id} ### Parameters #### Path Parameters - **collaboration_id** (str) - Required - The ID of the collaboration. #### Query Parameters - **fields** (Optional[List[str]]) - Optional - A comma-separated list of attributes to include in the response. - **extra_headers** (Optional[Dict[str, Optional[str]]]) - Optional - Extra headers that will be included in the HTTP request. ### Response #### Success Response (200) - **Collaboration** (Collaboration) - Description of the collaboration object. #### Response Example { "example": "Collaboration object details" } ``` -------------------------------- ### Create Metadata Instance on Folder Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/folder_metadata.md Applies a metadata template instance to a folder. For most templates, only predefined values are accepted. The 'global.properties' template accepts any key-value pair. Ensure 'Cascading Folder Level Metadata' is enabled in the admin console for the metadata to display in the Box web app. ```python client.folder_metadata.create_folder_metadata_by_id( folder.id, CreateFolderMetadataByIdScope.ENTERPRISE, template_key, { "name": "John", "age": 23, "birthDate": "2001-01-03T02:20:50.520Z", "countryCode": "US", "sports": ["basketball", "tennis"], }, ) ``` -------------------------------- ### Get task Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/tasks.md Retrieves information about a specific task. ```APIDOC ## GET /tasks/{task_id} ### Description Retrieves information about a specific task. This operation is performed by calling function `get_task_by_id`. ### Method GET ### Endpoint /tasks/{task_id} ### Parameters #### Path Parameters - **task_id** (str) - Required - The ID of the task. Example: "12345" #### Query Parameters - **extra_headers** (Optional[Dict[str, Optional[str]]]) - Optional - Extra headers that will be included in the HTTP request. ### Response #### Success Response (200) - **Task** - Returns a task object. ### Response Example ```json { "example": "Task object" } ``` ``` -------------------------------- ### Create Shield List Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/shield_lists.md Creates a new shield list. Requires a name, content, and optionally a description. The `BoxVersionHeaderV2025R0` is necessary. ```python client.shield_lists.create_shield_list_v2025_r0( shield_list_country_name, ShieldListContentCountryV2025R0( type=ShieldListContentCountryV2025R0TypeField.COUNTRY, country_codes=["US", "PL"], ), description="A list of things that are shielded", ) ``` -------------------------------- ### GET /web_links/:web_link_id Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/web_links.md Retrieve information about a web link. ```APIDOC ## GET /web_links/:web_link_id ### Description Retrieve information about a web link. ### Method GET ### Endpoint /web_links/:web_link_id ### Parameters #### Path Parameters - **web_link_id** (str) - Required - The ID of the web link. Example: "12345" #### Query Parameters None #### Request Body None ### Request Example ```python client.web_links.get_web_link_by_id(weblink.id) ``` ### Response #### Success Response (200) - **WebLink** (WebLink) - The web link object. #### Response Example ```json { "type": "web_link", "id": "12345", "name": "Example Web Link", "url": "https://www.example.com", "description": "Weblink description", "parent": { "type": "folder", "id": "67890" } } ``` ``` -------------------------------- ### List All Storage Policies Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/storage_policies.md Fetches all storage policies in the enterprise. Optional arguments include fields for specific attributes, marker for pagination, and limit for items per page. ```python client.storage_policies.get_storage_policies() ``` -------------------------------- ### Initialize Box Client with JWT Auth from Config File Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/authentication.md Authenticate as an enterprise using JWT by loading configuration from a JSON file. This method is suitable for authenticating as the application's service account. ```python from box_sdk_gen import BoxClient, BoxJWTAuth, JWTConfig jwt_config = JWTConfig.from_config_file(config_file_path="/path/to/settings.json") auth = BoxJWTAuth(config=jwt_config) client = BoxClient(auth=auth) service_account = client.users.get_user_me() print(f"Service Account user ID is {service_account.id}") ``` -------------------------------- ### GET /folders/:folder_id/watermark Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/folder_watermarks.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** (str) - 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" #### Query Parameters None #### Request Body None ### Request Example ```python client.folder_watermarks.get_folder_watermark(folder.id) ``` ### Response #### Success Response (200) - **watermark** (Watermark) - Description of the watermark associated with the folder. #### Response Example ```json { "watermark": { "imprint": "DEFAULT" } } ``` ``` -------------------------------- ### Get Watermark on File Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/file_watermarks.md Retrieve the watermark for a specific file. ```APIDOC ## GET /files/{file_id}/watermark ### Description Retrieve the watermark for a file. ### Method GET ### Endpoint /files/:file_id/watermark ### Parameters #### Path Parameters - **file_id** (string) - Required - The unique identifier that represents a file. The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the `file_id` is `123`. Example: "12345" #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **watermark** (Watermark) - Information about the watermark associated with the file. #### Response Example { "watermark": "Watermark object" } ``` -------------------------------- ### Create Webhook Source: https://context7.com/box/box-python-sdk-gen/llms.txt Set up a webhook to receive notifications for Box events. Specify the target (folder or item) and the events to trigger notifications. ```APIDOC ## Create Webhook ### Description Sets up a webhook to receive notifications for Box events. Specify the target (folder or item) and the events to trigger notifications. ### Method POST ### Endpoint /webhooks ### Parameters #### Request Body - **target** (object) - Required - The target for the webhook. - **id** (string) - Required - The ID of the target (e.g., folder ID). - **type** (string) - Required - The type of the target ('folder' or 'item'). - **address** (string) - Required - The URL endpoint to send notifications to. - **triggers** (array[string]) - Required - A list of events that trigger the webhook (e.g., 'FILE.UPLOADED', 'FILE.DOWNLOADED'). ### Request Example ```json { "target": { "id": "12345", "type": "folder" }, "address": "https://example.com/webhook-endpoint", "triggers": [ "FILE.UPLOADED", "FILE.DOWNLOADED" ] } ``` ### Response #### Success Response (201) - **id** (string) - The ID of the created webhook. ### Response Example ```json { "id": "webhook_abc123" } ``` ``` -------------------------------- ### List All Global Metadata Templates Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/metadata_templates.md Fetches all generic, global metadata templates available across all Box enterprises. Supports marker-based pagination for large result sets. ```python client.metadata_templates.get_global_metadata_templates() ``` -------------------------------- ### Get Events Source: https://context7.com/box/box-python-sdk-gen/llms.txt Retrieve user or enterprise events for audit and monitoring. ```APIDOC ## Get Events ### Description Retrieve user or enterprise events for audit and monitoring. ### Method GET ### Endpoint /events ### Parameters #### Query Parameters - **stream_type** (string) - Optional - The type of event stream to retrieve (e.g., 'admin_logs_streaming'). - **limit** (integer) - Optional - The maximum number of events to return. ### Response #### Success Response (200) - **entries** (array) - A list of event objects. - **event_type** (string) - The type of the event. - **created_at** (string) - The timestamp when the event occurred. ### Request Example ```python from box_sdk_gen import GetEventsStreamType # Get user events events = client.events.get_events() for event in events.entries: print(f"Event: {event.event_type} at {event.created_at}") # Get enterprise admin events admin_events = client.events.get_events( stream_type=GetEventsStreamType.ADMIN_LOGS_STREAMING, limit=100 ) ``` ``` -------------------------------- ### Get Current User Source: https://context7.com/box/box-python-sdk-gen/llms.txt Retrieve information about the currently authenticated user. ```APIDOC ## Get Current User ### Description Retrieves information about the currently authenticated user. ### Method GET ### Endpoint /users/me ### Response #### Success Response (200) - **name** (string) - The name of the current user. - **id** (string) - The ID of the current user. ### Response Example ```json { "name": "Current User", "id": "11111" } ``` ``` -------------------------------- ### Impersonate User: Old vs New SDK Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md Demonstrates how to make API calls on behalf of a user. The old SDK used `client.as_user()`, while the new SDK uses `client.with_as_user_header()` which takes only the user ID. ```python from boxsdk import Client user_to_impersonate = client.user(user_id='USER_ID') user_client: Client = client.as_user(user_to_impersonate) ``` ```python from box_sdk_gen import BoxClient user_client: BoxClient = client.with_as_user_header(user_id='USER_ID') ``` -------------------------------- ### GET /shield-information-barriers Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/shield_information_barriers.md Retrieves a list of shield information barriers for the enterprise. ```APIDOC ## GET /shield-information-barriers ### Description Retrieves a list of shield information barrier objects for the enterprise. ### Method GET ### Endpoint /shield-information-barriers ### Parameters #### Path Parameters None #### Query Parameters - **marker** (str) - Optional - Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. - **limit** (int) - Optional - The maximum number of items to return per page. #### Request Body None ### Request Example None ### Response #### Success Response (200) - **ShieldInformationBarriers** (ShieldInformationBarriers) - Returns a paginated list of shield information barrier objects, empty list if currently no barrier. #### Response Example { "example": "Paginated list of ShieldInformationBarrier objects" } ``` -------------------------------- ### Create Client to Impersonate User Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/client.md Use `client.with_as_user_header()` to create a new client instance that makes API calls on behalf of a specified user. This is useful for administrative tasks requiring user impersonation. ```python user_client = client.with_as_user_header(user_id="1234567") ``` -------------------------------- ### Get Retention Policy Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/retention_policies.md Retrieves a specific retention policy by its ID. ```APIDOC ## GET /retention_policies/:retention_policy_id ### Description Retrieves a retention policy. ### Method GET ### Endpoint /retention_policies/:retention_policy_id ### Parameters #### Path Parameters - **retention_policy_id** (str) - Required - The ID of the retention policy. #### Query Parameters - **fields** (Optional[List[str]]) - Optional - A comma-separated list of attributes to include in the response. If specified, only the requested fields and mini representation fields are returned. - **extra_headers** (Optional[Dict[str, Optional[str]]]) - Optional - Extra headers that will be included in the HTTP request. ### Response #### Success Response (200) - **RetentionPolicy** - The retention policy object. #### Response Example ```json { "type": "retention_policy", "id": "982312", "policy_name": "My Retention Policy", "description": "Policy for retaining documents for 7 years.", "disposition_action": "permanently_delete", "retention_type": "non-modifiable", "retention_length": "2555 days", "status": "active", "created_by": { "type": "user", "id": "12345", "name": "John Doe", "login": "john.doe@example.com" }, "date_created": "2023-01-01T12:00:00Z", "modified_by": { "type": "user", "id": "12345", "name": "John Doe", "login": "john.doe@example.com" }, "date_modified": "2023-01-01T12:00:00Z", "are_owners_notified": true, "can_owner_extend_retention": false } ``` ``` -------------------------------- ### Chunked File Upload (Old SDK) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md Use `get_chunked_uploader()` in the old `boxsdk` to initiate chunked uploads. This method requires `file_path` and `file_name` to start the upload process. ```python chunked_uploader = client.folder('0').get_chunked_uploader(file_path='/path/to/file.txt', file_name='new_name.txt') uploaded_file = chunked_uploader.start() print(f'File "{uploaded_file.name}" uploaded to Box with file ID {uploaded_file.id}') ``` -------------------------------- ### Create metadata instance on file Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/file_metadata.md 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. This operation is performed by calling function `create_file_metadata_by_id`. ```APIDOC ## POST /files/{file_id}/metadata/{scope}/{template_key} ### Description Applies an instance of a metadata template to a file. ### Method POST ### Endpoint /files/{file_id}/metadata/{scope}/{template_key} ### Parameters #### Path Parameters - **file_id** (str) - Required - The unique identifier that represents a file. Example: "12345" - **scope** (CreateFileMetadataByIdScope) - Required - The scope of the metadata template. Example: "global" - **template_key** (str) - Required - The name of the metadata template. Example: "properties" #### Query Parameters None #### Request Body - **request_body** (Dict) - Required - Request body of createFileMetadataById method ### Request Example ```json { "example": "{\"name\": \"John\", \"age\": 23, \"birthDate\": \"2001-01-03T02:20:50.520Z\", \"countryCode\": \"US\", \"sports\": [\"basketball\", \"tennis\"]}" } ``` ### Response #### Success Response (200) - **MetadataFull** (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 File Thumbnail Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/files.md Retrieves a thumbnail image representation of a file. ```APIDOC ## GET /files/{file_id}/thumbnail ### Description Retrieves a thumbnail, or smaller image representation, of a file. Supports PNG and JPG formats with various size options. ### Method GET ### Endpoint /files/{file_id}/thumbnail ### Parameters #### Path Parameters - **file_id** (str) - Required - The unique identifier that represents a file. #### Query Parameters - **extension** (GetFileThumbnailByIdExtension) - Required - The file format for the thumbnail (e.g., "png"). - **min_height** (Optional[int]) - The minimum height of the thumbnail. - **min_width** (Optional[int]) - The minimum width of the thumbnail. - **max_height** (Optional[int]) - The maximum height of the thumbnail. - **max_width** (Optional[int]) - The maximum width of the thumbnail. - **extra_headers** (Optional[Dict[str, Optional[str]]]) - Extra headers that will be included in the HTTP request. ### Response #### Success Response (200) - **Binary data** - The thumbnail image data. ### Response Example (Returns binary image data, no JSON example provided) ### Error Handling - **Retry-After** (header) - Indicates when the thumbnail will be ready if generation is in progress. ``` -------------------------------- ### Get collection by ID Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/collections.md Retrieves a specific collection by its unique ID. ```APIDOC ## GET /collections/{collection_id} ### Description Retrieves a collection by its ID. ### Method GET ### Endpoint /collections/{collection_id} ### Parameters #### Path Parameters - **collection_id** (str) - Required - The ID of the collection. Example: "926489" #### Query Parameters - **extra_headers** (Optional[Dict[str, Optional[str]]]) - Optional - Extra headers that will be included in the HTTP request. ### Response #### Success Response (200) - **Collection** (Collection) - Returns an array of items in the collection. ### Request Example ```python client.collections.get_collection_by_id(collections.entries[0].id) ``` ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Create User (box-sdk-gen) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md To create a new user with `box-sdk-gen`, call the `create_user` method on the `UserManager`. ```python user = client.users.create_user(name='Some User') ``` -------------------------------- ### Make Custom Multipart Request to Upload File Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/client.md This example shows how to upload a file using a multipart POST request. It requires specifying the content type and providing multipart data including attributes and the file stream. ```python from box_sdk_gen import FetchResponse, FetchOptions, MultipartItem response: FetchResponse = client.make_request( FetchOptions( method="POST", url="https://upload.box.com/api/2.0/files/content", content_type="multipart/form-data", multipart_data=[ MultipartItem( part_name="attributes", data={"name": "new_folder_name", "parent": {"id": "0"}}, ), MultipartItem(part_name="file", file_stream=open("file.txt", "rb")), ], ) ) print("Received status code: ", response.status) ``` -------------------------------- ### GET /users/:user_id/avatar Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/avatars.md Retrieves an image of the user's avatar. ```APIDOC ## GET /users/:user_id/avatar ### Description Retrieves an image of the user's avatar. ### Method GET ### Endpoint /users/:user_id/avatar ### Parameters #### Path Parameters - **user_id** (str) - Required - The ID of the user. Example: "12345" #### Query Parameters None #### Request Body None ### Request Example ```python client.avatars.get_user_avatar(user.id) ``` ### Response #### Success Response (200) - **ByteStream** - The image data will be returned in the body of the response. #### Response Example (Image data) ``` -------------------------------- ### Get webhook by ID Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/webhooks.md Retrieves the details of a specific webhook using its ID. ```APIDOC ## GET /webhooks/:webhook_id ### Description Retrieves a specific webhook. This operation is performed by calling function `get_webhook_by_id`. ### Method GET ### Endpoint /webhooks/:webhook_id ### Parameters #### Path Parameters - **webhook_id** (str) - Required - The ID of the webhook. Example: "3321123" #### Query Parameters - **extra_headers** (Optional[Dict[str, Optional[str]]]) - Optional - Extra headers that will be included in the HTTP request. ### Response #### Success Response (200) - **Webhook** - Returns a webhook object. #### Response Example ```json { "type": "webhook", "id": "3321123", "target": { "type": "folder", "id": "67890" }, "created_by": { "type": "user", "id": "112233", "name": "John Doe" }, "address": "https://example.com/webhook", "created_at": "2023-01-01T12:00:00Z", "triggers": ["FILE.UPLOADED"] } ``` ``` -------------------------------- ### Create Box Hub Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/hubs.md Creates a new Box Hub with a specified title and optional description. The title cannot be empty and must be less than 50 characters. ```python client.hubs.create_hub_v2025_r0(hub_title, description=hub_description) ``` -------------------------------- ### JWT Auth with Manual Configuration (Old SDK) Source: https://github.com/box/box-python-sdk-gen/blob/main/migration-guide.md Manual JWT configuration in the old SDK used JWTAuth with parameters like 'rsa_private_key_file_sys_path'. ```python from boxsdk import JWTAuth auth = JWTAuth( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', enterprise_id='YOUR_ENTERPRISE_ID', user_id='USER_ID', jwt_key_id='YOUR_JWT_KEY_ID', rsa_private_key_file_sys_path='CERT.PEM', rsa_private_key_passphrase='PASSPHRASE', jwt_algorithm='RS256', ) ``` -------------------------------- ### Get Trashed Web Link Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/trashed_web_links.md Retrieves a web link that has been moved to the trash. ```APIDOC ## GET /web_links/{web_link_id}/trash ### Description Retrieves a web link that has been moved to the trash. ### Method GET ### Endpoint /web_links/{web_link_id}/trash ### Parameters #### Path Parameters - **web_link_id** (str) - Required - The ID of the web link. #### Query Parameters - **fields** (Optional[List[str]]) - A comma-separated list of attributes to include in the response. ### Request Example ```python client.trashed_web_links.get_trashed_web_link_by_id(web_link_id='12345') ``` ### Response #### Success Response (200) - **id** (str) - The ID of the web link. - **type** (str) - The type of the object. - **name** (str) - The name of the web link. - **trashed_at** (str) - The date and time the web link was moved to the trash. #### Response Example ```json { "type": "web_link", "id": "12345", "name": "Example Web Link", "trashed_at": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Initialize Client with Client Credentials Grant Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/authentication.md Use BoxCCGAuth to initialize a client for Client Credentials Grant authentication. This method allows working with service or user accounts using client credentials. ```python from box_sdk_gen import BoxClient, BoxCCGAuth, CCGConfig ccg_config = CCGConfig( client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", user_id="YOUR_USER_ID", ) auth = BoxCCGAuth(config=ccg_config) client = BoxClient(auth=auth) print(f"Id of the authenticated user is: {client.users.get_user_me().id}") ``` -------------------------------- ### Get Terms of Service by ID Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/terms_of_services.md Fetches a specific terms of service by its ID. ```APIDOC ## GET /terms_of_services/:terms_of_service_id ### Description Fetches a specific terms of service. ### Method GET ### Endpoint /terms_of_services/:terms_of_service_id ### Parameters #### Path Parameters - **terms_of_service_id** (str) - Required - The ID of the terms of service. Example: "324234" #### Query Parameters - **extra_headers** (Dict[str, Optional[str]]) - Optional - Extra headers that will be included in the HTTP request. ### Response #### Success Response (200) - **TermsOfService** - A terms of service object. ### Request Example _Currently we don't have an example for calling `get_terms_of_service_by_id` in integration tests_ ``` -------------------------------- ### GET /shield-information-barriers/:barrier_id Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/shield_information_barriers.md Retrieves a specific shield information barrier by its ID. ```APIDOC ## GET /shield-information-barriers/:barrier_id ### Description Get shield information barrier based on provided ID. ### Method GET ### Endpoint /shield-information-barriers/:barrier_id ### Parameters #### Path Parameters - **barrier_id** (str) - Required - The ID of the shield information barrier. Example: "1910967" #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **ShieldInformationBarrier** (ShieldInformationBarrier) - Description of the shield information barrier object. #### Response Example { "example": "ShieldInformationBarrier object" } ``` -------------------------------- ### Make Custom Request for Binary Response Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/client.md To receive a binary response, such as file content, specify `ResponseFormat.BINARY` in `FetchOptions`. The response content is then written to a file. ```python from box_sdk_gen import FetchResponse, FetchOptions, ResponseFormat file_id = "1234567" response: FetchResponse = client.make_request( FetchOptions( method="GET", url="".join(["https://api.box.com/2.0/files/", file_id, "/content"]), response_format=ResponseFormat.BINARY, ) ) print("Received status code: ", response.status) with open("file.txt", "wb") as file: file.write(response.content) ``` -------------------------------- ### List File Versions with Box SDK Source: https://github.com/box/box-python-sdk-gen/blob/main/docs/file_versions.md Retrieve a list of past versions for a specific file. This requires a premium Box account. Use the `get_file_versions` function. ```python client.file_versions.get_file_versions(file.id) ```