Skip to navigation

Create a Dropdown Field Using the V3 SDK

Build a list of dropdown options and create the dropdown in your tenant's registry.

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

  1. SDK boilerplate

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

  2. Name the dropdown and its options

    dropdown_values is a plain list of the option labels you want, in the order they should appear.

  3. Build the dropdown options

    The options have to be CreateDropdownOptionInput objects rather than strings, so build one per label.

  4. Create the dropdown in your tenant

    dropdown.create() takes the name, the options, and the registry the dropdown belongs to, sends the request, and returns the created dropdown.

    REGISTRY_ID must be the actual ID of your registry. If you don’t have it, benchling.registry.list() returns every registry you can see, with its id and name. That endpoint is beta, so it needs a client created with early_access="true"; see the V3 Stability Guidelines.

  5. Read the options back

    The returned dropdown doesn’t embed its options; options is a link. Call dropdown.list_options() with the new dropdown’s ID to get each option’s ID and name.

from benchling_v3_sdk import Benchling, CreateDropdownOptionInput
benchling = Benchling(
base_url="https://yourcompany.benchling.com",
api_key="<your-api-key>",
)
dropdown_name = "Dropdown Field"
dropdown_values = ["Option 1", "Option 2", "Option 3", "Option 4", "Option 5"]
dropdown_options = [CreateDropdownOptionInput(name=value) for value in dropdown_values]
newly_created_dropdown = benchling.dropdown.create(
name=dropdown_name,
options=dropdown_options,
registry_id=REGISTRY_ID,
)
for option in benchling.dropdown.list_options(newly_created_dropdown.id).items:
print(option.id, option.name)

To create up to 25 dropdowns in one all-or-nothing request, use dropdown.batch_create(). See Batch operations.