API Keys
API keys authenticate the @testrelic/playwright-analytics reporter when uploading test run data to the TestRelic cloud platform. Each key is scoped to your organization and can be labeled for different environments or CI configurations.
Accessing API Keys
Navigate to Settings → API Keys in the left sidebar. All organization members (not just admins) can view and manage API keys.
Creating an API key
- Click Generate new key.
- Enter a descriptive label (e.g.
ci-staging,local-dev,production-reporter). - Click Create.
- Copy the key immediately — it is only shown once at creation time.
The full API key value is shown only at the moment of creation. After you close the dialog, you cannot retrieve the key value. If you lose it, generate a new key and revoke the old one.
Using an API key with the reporter
Place the API key in your Playwright configuration:
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [
['@testrelic/playwright-analytics', {
apiKey: process.env.TESTRELIC_API_KEY,
repoId: 'YOUR_REPO_ID',
}]
],
});
Set the TESTRELIC_API_KEY environment variable in your CI environment or local .env file. Never commit API keys to source control.
In GitHub Actions, add the API key as a repository secret:
- Go to your repository → Settings → Secrets and variables → Actions.
- Click New repository secret, name it
TESTRELIC_API_KEY, and paste your key. - Reference it in your workflow:
env: TESTRELIC_API_KEY: ${{ secrets.TESTRELIC_API_KEY }}.
API key list
The API Keys page displays all keys for your organization:
| Column | Description |
|---|---|
| Label | The descriptive name you gave the key |
| Key prefix | The first few characters of the key (for identification) |
| Created | When the key was created |
| Last used | The last time the key was used for an upload |
| Actions | Revoke |
Revoking a key
Click Revoke next to any key to permanently invalidate it. Revoked keys cannot be re-activated. Any reporter using a revoked key will fail to upload data.
Generate a new key and update your reporter configuration before revoking an old one to avoid gaps in data upload.
Key rotation best practices
- Use separate keys for different environments (staging, production).
- Rotate keys regularly (e.g. every 90 days) as part of your security hygiene.
- Revoke keys immediately when a team member with CI access leaves the organization.
- Label keys clearly so you know where each one is used.