Types of API keys
W&B issues API keys to both people and service accounts.An organization-scoped API key and an organization-scoped service account are different things. An organization-scoped API key belongs to a person and authenticates that person, limited to a single organization. An organization-scoped service account is a non-human identity used for automation, and it has its own API keys. A user can hold an organization-scoped API key without any service account being involved.
Find and manage API keys
Organization admins, team admins, and members manage keys from the API Keys tab.- Multi-tenant Cloud
- Dedicated Cloud and Self-Managed
- Click your profile icon in the upper right, then select your organization.
-
Navigate to
https://wandb.ai/account-settings/[ORGANIZATION]/api-keys. Replace[ORGANIZATION]with your organization name. The API Keys tab lists the keys you have permission to see.
In Multi-tenant Cloud, users whose organization role is billing admin can’t see the API Keys tab. In Dedicated Cloud and Self-Managed, the tab isn’t restricted by billing role.
Key visibility by role
The keys listed in the API Keys tab depend on your role:Read the API keys table
The table lists each key with the following columns:- Key name: The descriptive name given to the key when it was created.
- Key ID: The first part of the key, used for identification.
- Owner: The user or service account that owns the key.
- Last used: When the key most recently authenticated a request.
- Created on: When the key was created.
For security, the table shows only the key ID. W&B displays the full secret key once, when you create it. If you no longer have the full secret for a key, rotate the key.
Create an API key
- Go to the API Keys tab.
- Click New key.
- Give the key a descriptive name.
- Click Create.
- Copy the key immediately and store it securely.
Rename an API key
Rename a key to record what uses it, which makes an unfamiliar key easier to trace later. Renaming doesn’t change the key’s secret and doesn’t interrupt anything that uses it.- Find the key in the table.
- Click the actions menu at the end of the key’s row, then click Edit.
- Enter a new name, then save.
Delete API keys
Delete a key when you no longer need it, or immediately if it may have been exposed. To delete a single key, find it in the table, click the actions menu at the end of its row, then click Delete and confirm. To delete several keys at once:- Select the checkbox next to each key you want to delete.
- Click Delete. The button shows the number of keys you selected.
- Confirm the deletion.
Rotate an API key
Rotate a key on a schedule that matches your security policy, and immediately if a key may have been exposed. Rotate a key rather than delete it when the workloads that use it must keep running. W&B has no single rotate action. Because a key’s full secret is shown only at creation, you rotate a key by replacing it:- Create a new API key. Give it a name that distinguishes it from the key you’re replacing.
- Update every script, job, and stored secret that uses the old key. For storage options, see Store and handle API keys securely.
- Confirm that your workloads authenticate with the new key.
- Delete the old key.
Restrict how members use API keys
Organization admins can restrict key creation and use. The available restrictions differ by deployment type, and each is set through theupdateOrganizationPrivacySettings GraphQL mutation rather than through the W&B App.
Require organization-scoped API keys
Available in Multi-tenant Cloud for Enterprise organizations. When enabled, only organization-scoped API keys can access the organization’s resources. Personal API keys that a member uses across several organizations no longer work against this organization, which prevents a key leaked from elsewhere from reaching your data. Replace[ORGANIZATION-ID] with the ID of your organization.
Disable API key creation
Available in Dedicated Cloud and Self-Managed v0.84.0 and above. When enabled, members of the organization can’t create new API keys. Existing keys keep working, so turning this on doesn’t interrupt running jobs. Use it when your organization issues keys through a controlled process and you want to prevent members from creating their own. Replace[ORGANIZATION-ID] with the ID of your organization.
GORILLA_DISABLE_TEAM_SERVICE_ACCOUNT_CREATION, which prevents the creation of new team-scoped service accounts in Dedicated Cloud and Self-Managed v0.83.0 and above.
Availability
API key capabilities differ by deployment type and, in Multi-tenant Cloud, by subscription. The following table summarizes where each capability is available.Store and handle API keys securely
API keys provide access to your W&B account and should be protected like passwords. The following sections describe recommended storage methods, practices to avoid, how to pass keys to your code, and SDK version requirements for newer keys.Recommended storage methods
Use one of the following methods to store your API key securely.- Secrets manager: Use a dedicated secrets management system such as AWS Secrets Manager, HashiCorp Vault, Azure Key Vault, or Google Secret Manager.
- Password manager: Use a reputable password manager application.
- OS-level keychains: Store keys in macOS Keychain, Windows Credential Manager, or Linux secret service. Not suggested for production.
What to avoid
Avoid the following practices, which can expose your API key:- Never commit API keys to version control systems such as Git.
- Don’t store API keys in plain text configuration files.
- Don’t pass API keys on the command line, because they’re visible in the output of OS commands like
ps. - Avoid sharing API keys through email, chat, or other unencrypted channels.
- Don’t hard-code API keys in your source code.
Environment variables
When you use API keys in your code, pass them through environment variables:SDK version compatibility
If you use a newer API key, confirm that your SDK version supports it. Newer API keys are longer than legacy keys. When you authenticate with older versions of thewandb or weave SDKs, you may encounter an API key length error.
Solution: Update to a newer SDK version:
-
wandbSDK v0.22.3+ -
weaveSDK v0.52.17+
WANDB_API_KEY environment variable as a workaround.