Automating ShotGrid Asset Status Updates with the Python API
Bridge the gap between pipeline tools and ShotGrid by automating asset status transitions with the Python API. Learn connection setup, targeted queries, batch updates, and handling partial failures.
14 Aug 2025, 19:03 UTC

In high-velocity production environments, the gap between a technical task finishing and a project manager seeing it is often where bottlenecks are born. When an artist finishes a render but forgets to manually toggle the ShotGrid status to 'Ready for Review,' the next person in the pipeline sits idle. Relying on manual status updates is prone to human error and latency.
The solution is to bridge the gap between your pipeline tools and ShotGrid using the ShotGrid Python API. By automating entity status transitions based on technical events, you ensure that the state of your project always reflects the reality of your file system without manual intervention.
Establishing the Connection
To interact with ShotGrid, you must initialize a shotgrid.Connect instance. This requires your site URL, a script name (created in ShotGrid), and an API key. Avoid hardcoding these credentials into your scripts; instead, use environment variables or a secure configuration-management service.
import shotgrid # Configuration - use environment variables in production server_url = "https://yourstudio.shotgrid.autodesk.com" script_name = "pipeline_bot" script_key = "your_api_key_here" # Initialize the connection sg = shotgrid.Connect(server_url, script_name, script_key)
Querying for Specific Assets
You rarely want to update every asset in the database. Instead, use the find method to target specific entities based on criteria. A common use case is finding all assets that are in a specific status, such as 'In Progress', to check if their associated renders are complete.
In this example, we search for Assets where the status is 'In Progress' and they belong to a specific sequence-named code.
# Define the filter: status is 'in_progress'
filters_ = [["sg_status_list", "is", "in_progress"]]
fields = ["id", "code"]
# Execute the query
assets = sg.find("Asset", filters_, fields)
for asset in assets:
print(f"Found Asset: {asset['code']} (ID: {asset['id']})")
Executing Batch Updates
Once you have identified the entities, you use the update method to modify their fields. While you can update entities one by one, it is significantly more efficient to pass a list of dictionaries for a batch update. This reduces HTTP overhead and minimizes hitting rate limits.
Note: Always use the internal field name (e.g., sg_status_list) rather than the display name (e.g., "Status").
# Prepare data for a batch update
data = [
{"id": 1234, "sg_status_list": "ready_for_review"},
{"id": 1235, "sg_status_list": "ready_for_review"}
]
# Perform the batch update
try:
sg.update_batch("Asset", data)
print("Batch update successful.")
except Exception as e:
print(f"Update failed: {e}")
Technical Limitations and Safety
The ShotGrid API does not support traditional multi-entity transactions. If a batch update of ten items fails at the fifth item due to a permission error or validation, the first four remain updated. You must implement custom logic to handle these partial failures and log which specific IDs failed to ensure data integrity.
Additionally, be cautious of tight loops. Running a find query inside a loop that processes thousands of files can cause performance degradation for other studio users. Always aim to fetch data in bulk and process it locally.
Verification
To verify your script works, run a test pass against a single known entity. Check the console output, then refresh the ShotGrid web UI to ensure the sg_status_list has changed as expected. If the UI does not update, verify that your API key has 'Edit' permissions on the target entity type.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.