### Install SDK using setup.py Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ADVANCED.md Installs the Smartsheet SDK for Python after cloning the source code and installing dependencies. This command should be run from the SDK's root directory. ```bash python setup.py install ``` -------------------------------- ### Basic Smartsheet Operations Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/index.md Example demonstrating how to create a Smartsheet client, list sheets, get a sheet by ID, and print sheet information. Assumes SMARTSHEET_ACCESS_TOKEN is set. ```default import smartsheet # Create a Smartsheet client (uses SMARTSHEET_ACCESS_TOKEN environment variable) smart = smartsheet.Smartsheet() # Or create with explicit token: # smart = smartsheet.Smartsheet(access_token='your_token_here') # List all sheets response = smart.Sheets.list_sheets() # Get the ID of the first sheet sheet_id = response.data[0].id # Load the sheet by using its ID sheet = smart.Sheets.get_sheet(sheet_id) # Print information about the sheet print(f"The sheet {sheet.name} has {sheet.total_row_count} rows") ``` -------------------------------- ### Install Smartsheet Python SDK Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/README.md Install the Smartsheet Python SDK using pip. ```bash pip install smartsheet-python-sdk ``` -------------------------------- ### Install SDK Packages Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ADVANCED.md Installs the required packages for the Smartsheet SDK for Python. Ensure you have cloned the source code and are in the SDK directory. ```bash pip install setuptools six requests ``` -------------------------------- ### Configure SDK Logging (Basic Setup) Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Sets up basic logging for the Smartsheet SDK, directing debug messages to a file named 'smartsheet.log'. ```python import logging import smartsheet # Basic logging setup logging.basicConfig( filename='smartsheet.log', level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' ) # Create client - logging will capture all API requests/responses smart = smartsheet.Smartsheet() ``` -------------------------------- ### Smartsheet API Documentation Reference Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ISSUE-FIRST.md A Markdown example showing how to reference the Smartsheet API documentation for a specific endpoint. ```markdown According to the [Smartsheet API documentation for Get Sheet](https://developers.smartsheet.com/api/smartsheet/openapi/sheets/get-sheet), the response should include... ``` -------------------------------- ### Get Share Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves the details of a specific share within a workspace. ```APIDOC ## GET /workspaces/{workspace_id}/shares/{share_id} ### Description Get the specified Share. ### Method GET ### Endpoint `/workspaces/{workspace_id}/shares/{share_id}` ### Parameters #### Path Parameters - **workspace_id** (int) - Required - Workspace ID - **share_id** (str) - Required - Share ID ### Response #### Success Response (200) - **share** (Share) - The details of the specified share. #### Error Response (4xx/5xx) - **error** (Error) - An Error object if the request fails. ``` -------------------------------- ### Create Smartsheet Client and List Sheets Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/README.md Create a Smartsheet client, list sheets, get the ID of the first sheet, load the sheet by ID, and print its name and row count. Ensure SMARTSHEET_ACCESS_TOKEN is set in your environment. ```python import smartsheet smart = smartsheet.Smartsheet() # Create a Smartsheet client response = smart.Sheets.list_sheets() # Call the list_sheets() function and store the response object sheetId = response.data[0].id # Get the ID of the first sheet in the response sheet = smart.Sheets.get_sheet(sheetId) # Load the sheet by using its ID print(f"The sheet {sheet.name} has {sheet.total_row_count} rows") # Print information about the sheet ``` -------------------------------- ### Configure SDK Logging (Set Level) Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Demonstrates how to set the logging level for the Smartsheet SDK logger, for example, to log only errors. ```python # Logging levels: # ERROR - API errors and JSON serialization errors # INFO - API resources being requested # DEBUG - Request/response bodies and object attribute changes # Example: Log only errors logging.getLogger('smartsheet').setLevel(logging.ERROR) ``` -------------------------------- ### Get Workspace Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a workspace and its top-level contents. Can optionally load all nested items. ```APIDOC ## GET /workspaces/{workspace_id} ### Description Get the specified Workspace and list its contents. By default, this operation only returns top-level items in the Workspace. To load all of the contents, including nested Folders, include the **loadAll** parameter with a value of true. *Deprecated: 3.1.0 - Use get_workspace_metadata and get_workspace_children instead.* ### Method GET ### Endpoint `/workspaces/{workspace_id}` ### Parameters #### Path Parameters - **workspace_id** (int) - Required - Workspace ID #### Query Parameters - **load_all** (bool) - Optional - Load all contents, including nested items. - **include** (list[str]) - Optional - A comma-separated list of optional elements to include in the response. Valid list values: ownerInfo, sheetVersion, source. ### Response #### Success Response (200) - **workspace** (Workspace) - The details of the specified workspace. #### Error Response (4xx/5xx) - **error** (Error) - An Error object if the request fails. ``` -------------------------------- ### Get Webhook Details Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Fetches detailed information about a specific webhook, including its current status. ```python webhook = smart.Webhooks.get_webhook(webhook_id) print(f"Status: {webhook.status}") ``` -------------------------------- ### Add Rows to a Smartsheet Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/index.md Example of how to build and add new rows to a Smartsheet. Requires a sheet ID and column ID. ```default import smartsheet smart = smartsheet.Smartsheet() # Build new row new_row = smart.models.Row() new_row.to_top = True new_row.cells.append({ 'column_id': 123456789, 'value': 'New Value' }) # Add rows to sheet response = smart.Sheets.add_rows(sheet_id, [new_row]) ``` -------------------------------- ### Adding Rows Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Provides examples for adding one or more rows to a Smartsheet. It covers adding rows at the top, bottom, as children of other rows, after a specific sibling, and handling partial successes. ```APIDOC ## Adding Rows ### Description Inserts one or more rows into a sheet with options for positioning and hierarchy. ### Method POST ### Endpoint `/sheets/{sheetId}/rows` ### Parameters #### Path Parameters - **sheetId** (integer) - Required - The ID of the sheet to add rows to. #### Query Parameters None #### Request Body - **rows** (array of Row objects) - Required - An array containing the row objects to add. - **Row object**: - **to_top** (boolean) - Optional - If true, adds the row to the top of the sheet. - **to_bottom** (boolean) - Optional - If true, adds the row to the bottom of the sheet. - **parent_id** (integer) - Optional - The ID of the parent row if creating a child row. - **sibling_id** (integer) - Optional - The ID of the sibling row to insert the new row after. - **cells** (array of Cell objects) - Required - An array of cell objects for the row. - **Cell object**: - **column_id** (integer) - Required - The ID of the column. - **value** (any) - Required - The value for the cell. - **hyperlink** (object) - Optional - Hyperlink object for the cell. ### Request Example ```python import smartsheet smart = smartsheet.Smartsheet() sheet_id = 1234567890123456 # Get column IDs first sheet = smart.Sheets.get_sheet(sheet_id) columns = {col.title: col.id for col in sheet.columns} # Create a single row at the top row = smart.models.Row() row.to_top = True row.cells.append({'column_id': columns['Task Name'], 'value': 'New Task'}) row.cells.append({'column_id': columns['Status'], 'value': 'Not Started'}) row.cells.append({'column_id': columns['Due Date'], 'value': '2024-12-31'}) response = smart.Sheets.add_rows(sheet_id, [row]) new_row = response.result[0] print(f"Added row ID: {new_row.id}") # Add multiple rows at the bottom rows = [] for i in range(3): row = smart.models.Row() row.to_bottom = True row.cells.append({'column_id': columns['Task Name'], 'value': f'Task {i+1}'}) rows.append(row) response = smart.Sheets.add_rows(sheet_id, rows) # Add row as child of another row (indent) child_row = smart.models.Row() child_row.parent_id = 7777777777777777 # Parent row ID child_row.cells.append({'column_id': columns['Task Name'], 'value': 'Subtask'}) response = smart.Sheets.add_rows(sheet_id, [child_row]) # Add row below a specific sibling sibling_row = smart.models.Row() sibling_row.sibling_id = 8888888888888888 # Sibling row ID sibling_row.cells.append({'column_id': columns['Task Name'], 'value': 'After sibling'}) response = smart.Sheets.add_rows(sheet_id, [sibling_row]) # Add rows with partial success (continues even if some fail) response = smart.Sheets.add_rows_with_partial_success(sheet_id, rows) if response.message == 'PARTIAL_SUCCESS': for failure in response.failed_items: print(f"Row {failure.index} failed: {failure.error.message}") ``` ### Response #### Success Response (200) - **Result** (array of Row objects) - Contains the newly added rows. - **message** (string) - Indicates success or partial success. - **failed_items** (array) - If `add_rows_with_partial_success` is used and there are failures, this contains details about the failed rows. #### Response Example ```json { "result": [ { "id": 1234567890123456, "cells": [ { "columnId": 1111111111111111, "value": "New Task", "displayValue": "New Task" } ] } ], "message": "SUCCESS" } ``` ``` -------------------------------- ### Defining Scope for Code Changes Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ISSUE-FIRST.md Markdown example outlining the scope of work for a code change, specifying what is in and out of scope. ```markdown **In Scope**: - Update the `Cell` model in `smartsheet/models/cell.py` - Add handling for cell link objects - Update tests in `tests/mock_api/test_mock_api_sheets.py` **Out of Scope**: - Changes to other models - API authentication changes ``` -------------------------------- ### Update Cell Values in a Smartsheet Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/index.md Example demonstrating how to update cell values in a Smartsheet. Requires a sheet ID, row ID, and column ID. ```default import smartsheet smart = smartsheet.Smartsheet() # Build new cell value new_cell = smart.models.Cell() new_cell.column_id = 123456789 new_cell.value = 'Updated Value' new_cell.strict = False # Build the row to update new_row = smart.models.Row() new_row.id = 987654321 new_row.cells.append(new_cell) # Update rows response = smart.Sheets.update_rows(sheet_id, [new_row]) ``` -------------------------------- ### Passthrough POST Request Example Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ADVANCED.md Demonstrates how to use the passthrough POST method to send raw JSON data to the Smartsheet API. This is useful for creating new sheets with specified column configurations. ```python payload = {"name": "my new sheet", "columns": [ {"title": "Favorite", "type": "CHECKBOX", "symbol": "STAR"}, {"title": "Primary Column", "primary": True, "type": "TEXT_NUMBER"} ] } response = client.Passthrough.post('/sheets', payload) ``` -------------------------------- ### Smartsheet API Reference for Sheet Summary Endpoints Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ISSUE-FIRST.md Markdown links to the Smartsheet API documentation for listing and getting sheet summary fields. ```markdown - - ``` -------------------------------- ### Build Documentation Locally Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/CONTRIBUTING.md Navigate to the docs-source directory and run 'make html' to build the documentation locally. Open index.html in a browser to review changes. ```bash cd docs-source make html ``` -------------------------------- ### Initialize Smartsheet Client with HTTP Proxy Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ADVANCED.md Demonstrates how to initialize the Smartsheet client with an HTTP proxy configured. Ensure the proxy URL is correctly specified. ```python # Initialize client proxies = { 'https': 'http://127.0.0.1:8888' } smartsheet_client = smartsheet.Smartsheet(proxies=proxies) ``` -------------------------------- ### Passthrough API GET Request Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Makes a raw GET request to the Smartsheet API for features not directly implemented in the SDK. Supports query parameters. ```python import smartsheet smart = smartsheet.Smartsheet() # GET request response = smart.Passthrough.get('/sheets') sheets = response.data['data'] # GET with query parameters response = smart.Passthrough.get('/sheets', {'includeAll': True}) ``` -------------------------------- ### Get Filter Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a specific filter from a sheet. ```APIDOC ## GET /sheets/{sheetId}/filters/{filterId} ### Description Get the Filter. ### Method GET ### Endpoint /sheets/{sheetId}/filters/{filterId} ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **filter_id** (int) - Required - Filter ID ### Response #### Success Response (200) - **SheetFilter** - The retrieved filter object. #### Error Response (4xx/5xx) - **Error** - An error object if the request fails. ``` -------------------------------- ### Get Workspace Metadata Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves the metadata for a specified workspace. ```APIDOC ## GET /workspaces/{workspace_id}/metadata ### Description Get metadata of a workspace. ### Method GET ### Endpoint `/workspaces/{workspace_id}/metadata` ### Parameters #### Path Parameters - **workspace_id** (int) - Required - Workspace ID #### Query Parameters - **include** (list[str]) - Optional - A list of optional elements to include in the response. Valid list values: source ### Response #### Success Response (200) - **workspace** (Workspace) - The metadata of the specified workspace. #### Error Response (4xx/5xx) - **error** (Error) - An Error object if the request fails. ``` -------------------------------- ### Get Columns Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves all columns belonging to a specified sheet. ```APIDOC ## GET /sheets/{sheetId}/columns ### Description Get all columns belonging to the specified Sheet. ### Method GET ### Endpoint /sheets/{sheetId}/columns ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID #### Query Parameters - **include** (str) - Optional - (future) - **page_size** (int) - Optional - The maximum number of items to return per page. - **page** (int) - Optional - Which page to return. - **include_all** (bool) - Optional - If true, include all results (i.e. do not paginate). - **level** (int) - Optional - compatibility level ### Response #### Success Response (200) - **IndexResult[Column]** - An object containing a list of columns. #### Error Response (4xx/5xx) - **Error** - An error object if the request fails. ``` -------------------------------- ### Get Column Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a specific column from a sheet by its ID. ```APIDOC ## GET /sheets/{sheetId}/columns/{columnId} ### Description Get the specified Column. ### Method GET ### Endpoint /sheets/{sheetId}/columns/{columnId} ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **column_id** (int) - Required - Column ID #### Query Parameters - **include** (str) - Optional - (future) ### Response #### Success Response (200) - **Column** - The retrieved column object. #### Error Response (4xx/5xx) - **Error** - An error object if the request fails. ``` -------------------------------- ### Initialize Smartsheet Client with Direct Token Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/index.md Initialize the Smartsheet client by passing the access token directly to the constructor. ```default import smartsheet smart = smartsheet.Smartsheet(access_token='your_token_here') ``` -------------------------------- ### Enable a Webhook Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Activates a previously created webhook. This should be done after verifying the callback URL. ```python webhook = smart.models.Webhook({'enabled': True}) response = smart.Webhooks.update_webhook(webhook_id, webhook) ``` -------------------------------- ### Initialize Smartsheet Client with Environment Variable Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/index.md Initialize the Smartsheet client without parameters when the SMARTSHEET_ACCESS_TOKEN environment variable is set. ```default import smartsheet smart = smartsheet.Smartsheet() ``` -------------------------------- ### Get Cross-Sheet Reference Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a specific cross-sheet reference from a sheet. ```APIDOC ## GET /sheets/{sheetId}/crosssheetreferences/{crossSheetReferenceId} ### Description Get the CrossSheetReference. ### Method GET ### Endpoint /sheets/{sheetId}/crosssheetreferences/{crossSheetReferenceId} ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **cross_sheet_reference_id** (int) - Required - CrossSheetReferenceID ### Response #### Success Response (200) - **CrossSheetReference** - The retrieved cross-sheet reference object. #### Error Response (4xx/5xx) - **Error** - An error object if the request fails. ``` -------------------------------- ### Basic Smartsheet Client Initialization and Sheet Retrieval Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ISSUE-FIRST.md Demonstrates how to initialize the Smartsheet client and retrieve a sheet. This snippet is often used to show the context of an error. ```python import smartsheet client = smartsheet.Smartsheet(access_token='your_token') # This raises an error sheet = client.Sheets.get_sheet(1234567890) print(sheet.rows[0].cells[0].value) # TypeError here ``` -------------------------------- ### Get Share Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves details for a specific share associated with a report. ```APIDOC ## GET /reports/{report_id}/shares/{share_id} ### Description Get the specified Share. ### Method GET ### Endpoint /reports/{report_id}/shares/{share_id} ### Parameters #### Path Parameters - **report_id** (int) - Required - Report ID - **share_id** (str) - Required - Share ID ### Response #### Success Response (200) - **Share** (Share) - The retrieved share object. #### Response Example ```json { "id": "share123", "email": "user@example.com", "access_level": "VIEWER" } ``` ``` -------------------------------- ### GET /smartsheet/{sheetId}/discussion/comment/{commentId} Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a specific comment. ```APIDOC ## GET /smartsheet/{sheetId}/discussion/comment/{commentId} ### Description Get the specified Comment. ### Method GET ### Endpoint /smartsheet/{sheetId}/discussion/comment/{commentId} ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **comment_id** (int) - Required - Comment ID ### Response #### Success Response (200) - **comment** (object) - The Comment object. #### Error Response (4xx/5xx) - **error** (object) - An Error object if the request fails. ``` -------------------------------- ### GET /smartsheet/{sheetId}/discussion/{discussionId} Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a specific discussion. ```APIDOC ## GET /smartsheet/{sheetId}/discussion/{discussionId} ### Description Get the specified Discussion. ### Method GET ### Endpoint /smartsheet/{sheetId}/discussion/{discussionId} ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **discussion_id** (int) - Required - Discussion ID ### Response #### Success Response (200) - **discussion** (object) - The Discussion object. #### Error Response (4xx/5xx) - **error** (object) - An Error object if the request fails. ``` -------------------------------- ### GET /smartsheet/{sheetId}/discussions Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a list of all discussions on a sheet. ```APIDOC ## GET /smartsheet/{sheetId}/discussions ### Description Get a list of all Discussions on the specified Sheet. ### Method GET ### Endpoint /smartsheet/{sheetId}/discussions ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID #### Query Parameters - **include** (list[str]) - Optional - A comma-separated list of optional elements to include in the response. Valid list values: comments, attachments - **page_size** (int) - Optional - The maximum number of items to return per page. - **page** (int) - Optional - Which page to return. - **include_all** (bool) - Optional - If true, include all results (i.e. do not paginate). ### Response #### Success Response (200) - **indexResult** (object) - Contains a list of Discussion objects. #### Error Response (4xx/5xx) - **error** (object) - An Error object if the request fails. ``` -------------------------------- ### Create a Webhook Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Sets up a webhook to receive real-time notifications for events on a specific sheet. The webhook is created disabled and must be enabled separately. ```python webhook = smart.models.Webhook({ 'name': 'My Sheet Webhook', 'callback_url': 'https://myapp.example.com/webhook', 'scope': 'sheet', 'scope_object_id': sheet_id, 'events': ['*.*'], # All events 'version': 1 }) response = smart.Webhooks.create_webhook(webhook) webhook_id = response.result.id print(f"Created webhook: {webhook_id}") ``` -------------------------------- ### Initialize Smartsheet Client Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Instantiate the Smartsheet client with an API access token. The token can be provided directly or via an environment variable. Supports configuration for different regions, enabling exceptions for API errors, and proxy configuration. ```python import smartsheet # Create client using environment variable SMARTSHEET_ACCESS_TOKEN smart = smartsheet.Smartsheet() # Or provide access token directly smart = smartsheet.Smartsheet(access_token='YOUR_ACCESS_TOKEN') # Configure for EU region smart = smartsheet.Smartsheet(api_base=smartsheet.__eu_base__) # Configure for Government endpoint smart = smartsheet.Smartsheet(api_base=smartsheet.__gov_base__) # Enable exceptions for API errors (instead of returning Error objects) smart.errors_as_exceptions() # Configure with proxy proxies = {'https': 'http://127.0.0.1:8888'} smart = smartsheet.Smartsheet(proxies=proxies) ``` -------------------------------- ### Get Automation Rule Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a specific automation rule associated with a sheet. ```APIDOC ## GET /sheets/{sheetId}/automations/{automationRuleId} ### Description Get the AutomationRule. ### Method GET ### Endpoint /sheets/{sheetId}/automations/{automationRuleId} ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **automation_rule_id** (long) - Required - AutomationRuleID ### Response #### Success Response (200) - **AutomationRule** - The retrieved automation rule object. #### Error Response (4xx/5xx) - **Error** - An error object if the request fails. ``` -------------------------------- ### Python Code Snippet for Smartsheet SDK Initialization Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ISSUE-FIRST.md This Python code demonstrates how to import the Smartsheet SDK and initialize a client object with an API token. Ensure you replace 'your_token' with your actual Smartsheet API key. ```python import smartsheet client = smartsheet.Smartsheet('your_token') ``` -------------------------------- ### Get Report as CSV Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a specified report and downloads it as a CSV file. ```APIDOC ## GET /reports/{report_id}/rows/csv ### Description Get the specified Report as a CSV file. ### Method GET ### Endpoint /reports/{report_id}/rows/csv ### Parameters #### Path Parameters - **report_id** (int) - Required - Report ID #### Query Parameters - **download_path** (str) - Required - Directory path on local machine to save file. - **alternate_file_name** (str) - Optional - Filename to use instead of name suggested by Content-Disposition. ### Response #### Success Response (200) - **DownloadedFile** (DownloadedFile) - Information about the downloaded CSV file. #### Response Example ```json { "file_name": "report.csv", "content_length": 1024, "content_type": "text/csv" } ``` ``` -------------------------------- ### ProjectSettings Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_models.md Represents project settings in Smartsheet. ```APIDOC ## ProjectSettings ### Description Smartsheet ProjectSettings data model. ### Class smartsheet.models.project_settings.ProjectSettings ### Properties - **length_of_day** (integer) - The length of a working day in hours. - **non_working_days** (list of strings) - A list of non-working days (e.g., 'Saturday', 'Sunday'). - **working_days** (list of strings) - A list of working days (e.g., 'Monday', 'Tuesday'). ### Methods - **to_dict()**: Converts the object to a dictionary. - **to_json()**: Converts the object to a JSON string. ``` -------------------------------- ### Create Workspace Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Creates a new Smartsheet Workspace. ```APIDOC ## POST /workspaces ### Description Create a Workspace. ### Method POST ### Endpoint /workspaces ### Parameters #### Request Body - **workspace_obj** (Workspace) - Required - A Workspace object. ### Response #### Success Response (200) - **result** (Result[[Workspace]]) - The result of the operation. #### Error Response - **error** (Error) - An Error object if the request fails. ``` -------------------------------- ### Get Report as Excel Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a specified report and downloads it as an Excel (.xls) document. ```APIDOC ## GET /reports/{report_id}/rows/xls ### Description Get the specified Report as an Excel .xls document. ### Method GET ### Endpoint /reports/{report_id}/rows/xls ### Parameters #### Path Parameters - **report_id** (int) - Required - Report ID #### Query Parameters - **download_path** (str) - Required - Directory path on local machine to save file. - **alternate_file_name** (str) - Optional - Filename to use instead of name suggested by Content-Disposition. ### Response #### Success Response (200) - **DownloadedFile** (DownloadedFile) - Information about the downloaded Excel file. #### Response Example ```json { "file_name": "report.xls", "content_length": 2048, "content_type": "application/vnd.ms-excel" } ``` ``` -------------------------------- ### Get Folder Metadata Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves the metadata for a specific folder, including its details and contents. ```APIDOC ## GET /folders/{folder_id}/metadata ### Description Get the metadata of a folder. ### Method GET ### Endpoint /folders/{folder_id}/metadata ### Parameters #### Path Parameters - **folder_id** (int) - Required - Folder ID #### Query Parameters - **include** (list[str]) - Optional - A list of optional elements to include in the response. ### Response #### Success Response (200) - **Folder** (object) - Metadata of the folder. - **Error** (object) - Error details if the request fails. #### Response Example ```json { "id": 12345, "name": "Example Folder", "parentFolderId": null, "createdAt": "2023-01-01T10:00:00Z", "modifiedAt": "2023-01-01T10:00:00Z" } ``` ``` -------------------------------- ### Set SMARTSHEET_ACCESS_TOKEN Environment Variable Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/index.md Set the SMARTSHEET_ACCESS_TOKEN environment variable for authentication. This is the recommended method. ```default export SMARTSHEET_ACCESS_TOKEN="your_token_here" ``` -------------------------------- ### Move, Update, and Delete Folders Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Demonstrates moving, renaming, and deleting folders within Smartsheet. ```python destination = smart.models.ContainerDestination({ 'destination_type': 'FOLDER', 'destination_id': 8888888888888888 }) response = smart.Folders.move_folder(folder_id, destination) ``` ```python response = smart.Folders.update_folder(folder_id, 'Renamed Folder') ``` ```python response = smart.Folders.delete_folder(folder_id) ``` -------------------------------- ### Get Folder Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves information about a specific folder and lists its contents. This method is deprecated. ```APIDOC ## GET /smartsheet/folders/{folder_id} ### Description Get the specified Folder (and list its contents). Deprecated: 3.1.0 : Use get_folder_metadata and get_folder_children instead. ### Method GET ### Endpoint /smartsheet/folders/{folder_id} ### Parameters #### Path Parameters - **folder_id** (int) - Required - Folder ID #### Query Parameters - **include** (list[str]) - Optional - A comma-separated list of optional elements to include in the response. Valid list values: ownerInfo, sheetVersion, source. ### Response #### Success Response (200) - **folder** (Folder) - The retrieved folder object. #### Error Response (4xx/5xx) - **error** (Error) - An Error object if the request fails. ``` -------------------------------- ### Get Workspace Children Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves the children resources (sheets, reports, sights, folders) of a workspace. ```APIDOC ## GET /workspaces/{workspace_id}/children ### Description Get children of a workspace. ### Method GET ### Endpoint `/workspaces/{workspace_id}/children` ### Parameters #### Path Parameters - **workspace_id** (int) - Required - Workspace ID #### Query Parameters - **children_resource_types** (list[str]) - Optional - The types of the children resources. If not provided, returns children of all types. Valid list values: sheets, reports, sights, folders. - **include** (list[str]) - Optional - A list of optional elements to include in the response. Valid list values: source, ownerInfo. - **last_key** (str) - Optional - The token from a previous request that will allow this one to fetch the next page of results. - **max_items** (int) - Optional - The maximum number of items to return in the response. ### Response #### Success Response (200) - **paginatedChildrenResult** (PaginatedChildrenResult) - The paginated result of children resources. #### Error Response (4xx/5xx) - **error** (Error) - An Error object if the request fails. ``` -------------------------------- ### Create a new workspace Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Creates a new workspace with a specified name. The response includes the ID of the newly created workspace. ```python import smartsheet smart = smartsheet.Smartsheet() # Create a new workspace workspace = smart.models.Workspace({'name': 'My New Workspace'}) response = smart.Workspaces.create_workspace(workspace) workspace_id = response.result.id ``` -------------------------------- ### Create Smartsheet Client for Europe Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ADVANCED.md Instantiate the Smartsheet client object with the Smartsheet.eu API base URI to access European Smartsheet regions. Ensure the `smartsheet._eu_base_` constant is used for the `api_base` parameter. ```python client = smartsheet.Smartsheet(api_base=smartsheet._eu_base_) ``` -------------------------------- ### GET /sheets/{sheetId}/updateRequests/{updateRequestId} Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a specific UpdateRequest for a sheet that has a future schedule. ```APIDOC ## GET /sheets/{sheetId}/updateRequests/{updateRequestId} ### Description Get the UpdateRequest for Sheet that has a future schedule. ### Method GET ### Endpoint /sheets/{sheetId}/updateRequests/{updateRequestId} ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **update_request_id** (int) - Required - UpdateRequest ID ### Response #### Success Response (200) - **UpdateRequest** (UpdateRequest) - The UpdateRequest object. #### Response Example ```json { "id": 1, "schedule": { "dailyRecurrence": { "time": "10:00:00" } } } ``` #### Error Response (4xx/5xx) - **Error** (Error) - An error object if the request fails. ``` -------------------------------- ### Run Test Suite Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/CONTRIBUTING.md Execute the test suite using the command 'python -m pytest tests/'. Ensure all tests pass before submitting a PR. ```bash python -m pytest tests/ ``` -------------------------------- ### GET /sheets/{sheetId}/version Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves the version of a sheet without loading its entire content. ```APIDOC ## GET /sheets/{sheetId}/version ### Description Get the Sheet version without loading the entire Sheet. ### Method GET ### Endpoint /sheets/{sheetId}/version ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID ### Response #### Success Response (200) - **Version** (Version) - The version information of the sheet. #### Response Example ```json { "version": 5 } ``` #### Error Response (4xx/5xx) - **Error** (Error) - An error object if the request fails. ``` -------------------------------- ### Connect to Smartsheetgov.com Account Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/ADVANCED.md Instantiates the Smartsheet client to connect to Smartsheetgov.com by specifying the correct API base URI. ```python client = smartsheet.Smartsheet(api_base=smartsheet.__gov_base__) ``` -------------------------------- ### Get Publish Status Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves the publish status of a sheet, including any enabled publishing URLs. ```APIDOC ## GET /sheets/{sheetId}/publish ### Description Get the Publish status of the Sheet. Get the status of the Publish settings of the Sheet, including URLs of any enabled publishings. ### Method GET ### Endpoint /sheets/{sheetId}/publish ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID ### Response #### Success Response (200) - **SheetPublish** - The publish status object for the sheet. #### Error Response (4xx/5xx) - **Error** - An error object if the request fails. ``` -------------------------------- ### GET /smartsheet/{sheetId}/row/{rowId}/discussions Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves all discussions associated with a specific row. ```APIDOC ## GET /smartsheet/{sheetId}/row/{rowId}/discussions ### Description Get a list of all Discussions associated with the specified Row. ### Method GET ### Endpoint /smartsheet/{sheetId}/row/{rowId}/discussions ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **row_id** (int) - Required - Row ID #### Query Parameters - **include** (list[str]) - Optional - A comma-separated list of optional elements to include in the response. Valid list values: comments, attachments. (Attachments is effective only if comments is present, otherwise ignored.) - **page_size** (int) - Optional - The maximum number of items to return per page. - **page** (int) - Optional - Which page to return. - **include_all** (bool) - Optional - If true, include all results (i.e. do not paginate). ### Response #### Success Response (200) - **indexResult** (object) - Contains a list of Discussion objects. #### Error Response (4xx/5xx) - **error** (object) - An Error object if the request fails. ``` -------------------------------- ### Create Sheet in Folder Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Allows creation of a new Smartsheet from scratch within a specified folder. ```APIDOC ## POST /smartsheet/folders/{folder_id}/sheets ### Description Create a Sheet from scratch in the specified Folder. ### Method POST ### Endpoint /smartsheet/folders/{folder_id}/sheets ### Parameters #### Path Parameters - **folder_id** (int) - Required - Folder ID #### Request Body - **sheet_obj** (Sheet) - Required - Sheet object. ### Response #### Success Response (200) - **result** (Result[[Sheet]]) - The result of the operation. #### Error Response (4xx/5xx) - **error** (Error) - An Error object if the request fails. ``` -------------------------------- ### GET /sheets/{sheetId}/attachments/{attachmentId} Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Fetches a specific attachment by its ID from a given sheet. ```APIDOC ## GET /sheets/{sheetId}/attachments/{attachmentId} ### Description Fetch the specified Attachment. ### Method GET ### Endpoint /sheets/{sheet_id}/attachments/{attachment_id} ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **attachment_id** (int) - Required - Attachment ID ### Response #### Success Response (200) - **Attachment** (object) - The attachment object if successful. - **Error** (object) - An error object if the request fails. #### Response Example { "id": 12345, "name": "example.pdf", "size": 10240, "mimeType": "application/pdf", "createdAt": "2023-10-27T10:00:00Z", "modifiedAt": "2023-10-27T10:00:00Z", "url": "https://smartsheet.com/path/to/attachment" } ``` -------------------------------- ### Download an Attachment Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Downloads a specified attachment to a local directory. The directory must exist. ```python download_path = '/tmp/downloads' smart.Attachments.download_attachment(attachment, download_path) ``` -------------------------------- ### List All Webhooks Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Retrieves a list of all webhooks configured for the Smartsheet account. Use include_all=True for comprehensive results. ```python webhooks = smart.Webhooks.list_webhooks(include_all=True) for wh in webhooks.data: print(f"Webhook: {wh.name} (Enabled: {wh.enabled})") ``` -------------------------------- ### Get a Specific User Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Retrieves details for a single user based on their unique user ID. ```python user_id = 1234567890123456 user = smart.Users.get_user(user_id) ``` -------------------------------- ### List All Users in Organization Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Fetches a list of all users within the Smartsheet organization. Use include_all=True for complete results. ```python users = smart.Users.list_users(include_all=True) for user in users.data: print(f"User: {user.email} (ID: {user.id})") ``` -------------------------------- ### Get Current Authenticated User Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Retrieves information about the user currently logged into the Smartsheet API. ```python me = smart.Users.get_current_user() print(f"Logged in as: {me.email}") ``` -------------------------------- ### Create New Sheet Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Create a new Smartsheet from scratch by defining its name and columns, including their titles, types, and options. Sheets can be created at the top level, within a workspace, or within a folder. ```python import smartsheet smart = smartsheet.Smartsheet() # Define sheet with columns sheet_spec = smart.models.Sheet({ 'name': 'Project Tasks', 'columns': [ {'title': 'Task Name', 'type': 'TEXT_NUMBER', 'primary': True}, {'title': 'Status', 'type': 'PICKLIST', 'options': ['Not Started', 'In Progress', 'Complete']}, {'title': 'Due Date', 'type': 'DATE'}, {'title': 'Assigned To', 'type': 'CONTACT_LIST'}, {'title': 'Priority', 'type': 'CHECKBOX'} ] }) # Create sheet at top level response = smart.Home.create_sheet(sheet_spec) new_sheet = response.result print(f"Created sheet: {new_sheet.name} (ID: {new_sheet.id})") # Create sheet in a workspace workspace_id = 9876543210987654 response = smart.Workspaces.create_sheet_in_workspace(workspace_id, sheet_spec) # Create sheet in a folder folder_id = 5555555555555555 response = smart.Folders.create_sheet_in_folder(folder_id, sheet_spec) ``` -------------------------------- ### GET /sheets/{sheetId}/sent_update_requests/{sentUpdateRequestId} Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves details of a sent update request for a specific sheet. ```APIDOC ## GET /sheets/{sheetId}/sent_update_requests/{sentUpdateRequestId} ### Description Get the SentUpdateRequest for Sheet. ### Method GET ### Endpoint /sheets/{sheetId}/sent_update_requests/{sentUpdateRequestId} ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID - **sent_update_request_id** (int) - Required - SentUpdateRequest ID ### Response #### Success Response (200) - **SentUpdateRequest** (SentUpdateRequest) - The retrieved SentUpdateRequest object. #### Error Response (4xx/5xx) - **Error** (Error) - An Error object if the request fails. ### Response Example { "example": "SentUpdateRequest object or Error object" } ``` -------------------------------- ### Add a New User Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Creates a new user in the Smartsheet organization. Optionally sends an email invitation. ```python new_user = smart.models.User({ 'email': 'newuser@example.com', 'admin': False, 'licensed_sheet_creator': True, 'first_name': 'New', 'last_name': 'User' }) response = smart.Users.add_user(new_user, send_email=True) ``` -------------------------------- ### Create Sheet from Template Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Use this to create a new sheet based on an existing template. Specify the template ID and desired includes for the new sheet. ```python import smartsheet smart = smartsheet.Smartsheet() template_sheet = smart.models.Sheet({ 'name': 'New Project from Template', 'from_id': 1111111111111111 # Template ID }) response = smart.Home.create_sheet_from_template(template_sheet, include=['data', 'attachments']) ``` -------------------------------- ### Get Column by Title Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Retrieves a column from a sheet by its title. Returns the first matching title found. ```APIDOC ## GET /sheets/{sheetId}/columns?title={title} ### Description Get the specified Column by its title. ### Method GET ### Endpoint /sheets/{sheetId}/columns ### Parameters #### Path Parameters - **sheet_id** (int) - Required - Sheet ID #### Query Parameters - **title** (str) - Required - Title search string - **include** (str) - Optional - (future) ### Response #### Success Response (200) - **Column** - The first matching column object. - **bool** - False if no matching column is found. ``` -------------------------------- ### Get workspace metadata Source: https://context7.com/smartsheet/smartsheet-python-sdk/llms.txt Retrieves metadata for a specific workspace, excluding its children (sheets, folders, reports). ```python import smartsheet smart = smartsheet.Smartsheet() # Get workspace metadata (without children) workspace = smart.Workspaces.get_workspace_metadata(workspace_id) ``` -------------------------------- ### Create Sheet in Folder from Template Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_api.md Enables the creation of a new Smartsheet within a folder using a specified template. ```APIDOC ## POST /smartsheet/folders/{folder_id}/sheets/fromtemplate ### Description Create a Sheet in the specified Folder from the specified Template. ### Method POST ### Endpoint /smartsheet/folders/{folder_id}/sheets/fromtemplate ### Parameters #### Path Parameters - **folder_id** (int) - Required - Folder ID #### Query Parameters - **include** (list[str]) - Optional - A list of optional elements to include from the source Template. Valid list values: data, attachments, discussions, cellLinks, forms. #### Request Body - **sheet_obj** (Sheet) - Required - Sheet object with 'name' and 'fromId' (template ID). ### Response #### Success Response (200) - **result** (Result[[Sheet]]) - The result of the operation. #### Error Response (4xx/5xx) - **error** (Error) - An Error object if the request fails. ``` -------------------------------- ### AssetSharesPaginatedResult Model Source: https://github.com/smartsheet/smartsheet-python-sdk/blob/mainline/docs-source/smartsheet_models.md Represents a paginated result for Smartsheet AssetShares, used for deserializing responses from GET /2.0/shares. ```APIDOC ## AssetSharesPaginatedResult Model ### Description Smartsheet AssetSharesPaginatedResult data model with generic type support. Use only for deserializing the response from GET /2.0/shares. ### Properties - **items** (List[T]): A list of AssetShare objects. - **last_key** (string) ### Methods - **to_dict()**: Converts the AssetSharesPaginatedResult object to a dictionary. - **to_json()**: Converts the AssetSharesPaginatedResult object to a JSON string. ```