Create a Dropdown Field Using the V3 SDK
This recipe uses the V3 API through the
V3 Python SDK. The dropdown endpoints are stable, so the
client doesn’t need early_access.
SDK boilerplate
Import the V3 SDK and the
CreateDropdownOptionInputmodel, then instantiate the client. Pass your tenant’s root URL and your API key; the SDK adds/api/v3itself.Name the dropdown and its options
dropdown_valuesis a plain list of the option labels you want, in the order they should appear.Build the dropdown options
The options have to be
CreateDropdownOptionInputobjects rather than strings, so build one per label.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_IDmust be the actual ID of your registry. If you don’t have it,benchling.registry.list()returns every registry you can see, with itsidandname. That endpoint is beta, so it needs a client created withearly_access="true"; see the V3 Stability Guidelines.Read the options back
The returned dropdown doesn’t embed its options;
optionsis a link. Calldropdown.list_options()with the new dropdown’s ID to get each option’s ID and name.
To create up to 25 dropdowns in one all-or-nothing request, use dropdown.batch_create(). See
Batch operations.