TofuPilotTofuPilot
Settings

API Keys

Authenticate test scripts using API keys.

API Key management interface

Overview

The TofuPilot platform is designed to receive test data directly from your test scripts or test stations. To authenticate API requests made from our Python client or REST API, you need to use secure API keys.

Create API Keys

User API key

To create an API key linked to your user account, follow these steps:

Click the user menu at the bottom of the navigation bar and select Settings.

Go to the User API Key section on the Account page and click Generate API Key.

Copy your API key from the dialog.

User API key generation dialog

A user API key gives you the same permissions as your account on the web app. They are ideal for developers during implementation, debugging, or script development.

Station API keys

You can generate an API key for each station in your test environment. These keys have limited permissions: they can only create test runs for procedures assigned to that specific station. Refer to the Stations page for more details.

To generate a station key:

Go to the Stations page in the app.

Create a new station or open an existing one.

In the API Key section of the station page, click Generate API Key.

Station API key configuration

Station API keys have restricted permissions. They are designed for use in production environments, where access should be limited to specific stations. This ensures that only authorized stations can send test data, making it a secure option for your production line.

Configure Environment Variables

We strongly recommend saving your API key to a local environment variable named TOFUPILOT_API_KEY. This helps avoid accidental exposure through version control or logs.

Open a terminal.

Copy and paste the following command for your environment:

Terminal
echo "export TOFUPILOT_API_KEY=<your_key_here>" >> ~/.zshenv
source ~/.zshenv
setx TOFUPILOT_API_KEY "<your_key_here>"
echo "export TOFUPILOT_API_KEY=<your_key_here>" >> ~/.bash_profile
source ~/.bash_profile

Optionally, verify the environment variable with:

Terminal
echo $TOFUPILOT_API_KEY
echo %TOFUPILOT_API_KEY%
echo $TOFUPILOT_API_KEY

Regenerate API Keys

If you suspect your API key has been compromised, regenerate it immediately. Go to Settings > Account, locate the API Key section, and click Regenerate.

How is this guide?