Skip to navigation

User Management via the API

Read, create, update, and suspend Benchling users programmatically from an Enterprise tenant.

The Users API allows integrations installed in Enterprise tenants to programmatically manage Benchling users. This includes basic CRUD operations like reading and writing user data, batch and bulk create/update of users, and checking when a user was last seen.

This page uses the V3 API and the V3 Python SDK. If you’re new to the Benchling API, be sure to check out the Tutorial in our Overview page before proceeding.

The V3 user endpoints are beta. Set early_access="true" on the client, as in the examples below, or send the EARLY-ACCESS: true header on raw HTTP requests. See the V3 Stability Guidelines.

Every example below uses this client. Pass your tenant’s root URL; the SDK adds /api/v3 itself.

from benchling_v3_sdk import Benchling
benchling = Benchling(
base_url="https://yourcompany.benchling.com",
api_key="<your-api-key>",
early_access="true",
)

Users API Overview

The Users API includes a number of endpoints for managing Benchling users:

EndpointSDK methodDescription
GET /api/v3/user/itemsuser.listReturns a paginated list of Benchling users. Can filter on id.anyOf and name.anyOf.
POST /api/v3/useruser.createCreates a single Benchling user. Requires email, username, and name; accepts an optional organizationId.
GET /api/v3/user/{user_id}user.getReturns a single user by Benchling API ID.
PATCH /api/v3/user/{user_id}user.updateUpdates a single Benchling user’s email, username, name, or status. Setting status to SUSPENDED suspends the user.
POST /api/v3/user:batch-createuser.batch_createCreates up to 25 users synchronously in one transaction.
PATCH /api/v3/user:batch-updateuser.batch_updateUpdates up to 25 users synchronously in one transaction.
POST /api/v3/user:bulk-create and PATCH /api/v3/user:bulk-updateuser.bulk_create, user.bulk_updateCreate or update larger sets of users asynchronously from a JSONL file. See Bulk Import.

If you are coming from V2, a few fields changed:

V2V3
handleusername
isSuspended: true / falsestatus: "SUSPENDED" / "ACTIVE"
GET /api/v2/users/{user_id}/activity → lastSeenlastSeen on the user object itself

V3 does not put group filters on the user listing. To find a user’s teams and organizations, or a group’s members, use GET /api/v3/group-membership/items with memberId.eq or groupId.eq instead of V2’s ?memberOf= and ?adminOf=. See Getting Information on Project Collaborators for that pattern.

As in V2, one batch or bulk update can’t swap the emails of two users. Change them in separate requests.

Creating and reading users

user = benchling.user.create(
email="ada@example.com",
username="ada",
name="Ada Lovelace",
)
print(user.id, user.status)
for user in benchling.user.list(name_any_of="Ada Lovelace"):
print(user.id, user.username, user.last_seen)

To create several users in one all-or-nothing request, pass up to 25 CreateUserInput items to user.batch_create:

from benchling_v3_sdk import CreateUserInput
response = benchling.user.batch_create(
items=[
CreateUserInput(email="ada@example.com", username="ada", name="Ada Lovelace"),
CreateUserInput(email="alan@example.com", username="alan", name="Alan Turing"),
]
)
print([created.id for created in response.items])

Set organization_id on a CreateUserInput to add the new user to that organization as a MEMBER. It’s optional, even on tenants with more than one organization, unless your tenant is configured to require every user to belong to an organization.

Permissions

User management is a highly privileged activity; for this reason, creating and updating Benchling users requires tenant admin or User admin privileges. Apps cannot be made tenant admins, so the confirmed way to create and update Benchling users is with an API key generated by a tenant admin or User admin.

Reading Benchling user data (e.g. using GET /api/v3/user/items) doesn’t require any specific privileges, but the users returned depends on their organization membership. An app can only read a user’s information if they are both members of the same organization. The same principle applies when using an API key, based on the user who created the key.

Two organizations with overlapping membership, where an app in Alpha Lab can only see the five users who share that organization
In this example, the App is a member of the Alpha Lab organization. When reading user information, the app only has access to users A, B, C, D, and E.

Suspension

Suspending users can be accomplished using either the single or batch and bulk update endpoints. In the body of the user update object, setting the status property to SUSPENDED will suspend a user. Suspended users still exist on a tenant, but are logged out of Benchling and cannot re-authenticate. Set status back to ACTIVE to reinstate them. For example:

benchling.user.update("ent_a8asdp", status="SUSPENDED")

The SDK sends {"status": "SUSPENDED"} to PATCH /api/v3/user/ent_a8asdp. With raw HTTP:

curl -X PATCH "https://$YOUR_DOMAIN/api/v3/user/$USERID" \
-H "Content-Type: application/json" \
-H "EARLY-ACCESS: true" \
-u $YOUR_API_KEY: \
-d '{"status": "SUSPENDED"}'

To suspend several users in one transaction:

from benchling_v3_sdk import UpdateUserInputWithPathParams
benchling.user.batch_update(
items=[
UpdateUserInputWithPathParams(id=user_id, status="SUSPENDED")
for user_id in ["ent_a8asdp", "ent_rCgpcKrj"]
]
)