Skip to navigation

Move a Box to a New Location Using the V3 SDK

Find a box by name, then update its parent storage to move it.

This recipe uses the V3 API through the V3 Python SDK. The box list and update endpoints are stable, so the client doesn’t need early_access.

  1. SDK boilerplate

    Import the V3 SDK and instantiate the client. Pass your tenant’s root URL and your API key; the SDK adds /api/v3 itself.

  2. Find the box's API ID from its name

    Moving a box means referring to it by API ID, so start with box.list() filtered on the box’s name and print the IDs it comes back with. name_any_of matches case-insensitively; use name_any_of_case_sensitive for an exact match. Iterating the pager fetches every page for you. Paste the ID you want into box_id below.

  3. Move the box to the new location

    box.update() takes the box’s API ID and the fields to change as keyword arguments. Set parent_storage_id to the API ID of the location you want the box in. The commented-out arguments show what else you can change in the same call, such as the box’s name, barcode, schema fields, or project. Arguments you leave out are not sent, so they stay as they are.

  4. Handle the update response

    box.update() returns the updated box. Its new location is parent_storage, a reference with the location’s id. This example keeps the name, ID, and new location in case a later step needs them.

from benchling_v3_sdk import Benchling
benchling = Benchling(
base_url="https://yourcompany.benchling.com",
api_key="<your-api-key>",
)
box_name = "FreezerBox1"
def get_box_id(box_name):
for box in benchling.box.list(name_any_of=[box_name]):
print(box.id)
get_box_id(box_name)
box_id = "box_fooBar"
def move_box(box_id):
box = benchling.box.update(
box_id,
parent_storage_id="loc_oR1099Ds",
# name="",
# barcode="",
# schema_fields={},
# project_id="",
)
updated_box = {}
updated_box["name"] = box.name
updated_box["id"] = box.id
updated_box["new_location"] = box.parent_storage.id
return updated_box
new_location = move_box(box_id)
print(new_location)