Shows how to create an API key that lets apps and other services access Labelbox APIs and endpoints.
Labelbox authenticates API requests using API keys, which grant access to the Python SDK and can also authorize third-party integrations, such as cloud providers. Depending on your roles and permissions, you can create, view, delete, and distribute API keys as needed.
API keys serve as access credentials to Labelbox on your behalf. Treat them with the same level of care as other sensitive credentials.
API keys of disabled accounts
API keys are tied to user accounts. If a user account is disabled, all API keys associated with that account are also disabled.
Create a new API key
To create a new API key:
- On the Labelbox home page, click Create API key.
- On the Create new API key prompt:
- Enter a descriptive name.
- Add a validity time period. The max value is 6 months.
- Select a role for the scope of access permissions.
- Your new key is displayed in the API key created prompt. Use the Copy button to copy the key to the clipboard. It's strongly recommended to save your new key in a safe location.
- Click Done to close the prompt. After closing the prompt, you won’t be able to retrieve the key.
View and delete API keys
Use the Workplace Settings > API keys tab to view and delete existing API keys. To delete an API key, locate the key you wish to delete and select ... > Delete.
Once an API key is deleted, it can no longer authenticate API requests. Any app, script, or service using the key loses access to Labelbox. To minimize disruptions, we recommend not deleting keys until you've created and replaced them with new ones.
Guidelines and best practices
For each active Labelbox account:
- API keys access to your Labelbox account and data. Treat API keys like passwords and other credentials.
- The value of an API key can only be retrieved once from the API key created prompt when the key is first created.
- If you lose the value of your API key (or cannot determine how it's being used), delete it and create a new one.
Client
The Labelbox Client is essential for all SDK workflows. It connects to a Labelbox server with your authentication API key and provides functions for querying and creating data assets.
Instantiate Labelbox Client
Use the API key to connect to the Labelbox client:
import labelbox as lb
## Option 1: List API_KEY in your Python script
API_KEY = "<YOUR_API_KEY>"
client = lb.Client(api_key=API_KEY)
## Option 2: Pass your API key as an environment variable $LABELBOX_API_KEY
# In your terminal:
user@machine:~$ export LABELBOX_API_KEY="<YOUR_API_KEY>"
# In Python:
client = lb.Client()