Skip to main content
Ask AI

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

  1. Click Generate new key.
  2. Enter a descriptive label (e.g. ci-staging, local-dev, production-reporter).
  3. Click Create.
  4. Copy the key immediately — it is only shown once at creation time.
Save your key now

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:

playwright.config.ts
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.

CI environment variable

In GitHub Actions, add the API key as a repository secret:

  1. Go to your repository → Settings → Secrets and variables → Actions.
  2. Click New repository secret, name it TESTRELIC_API_KEY, and paste your key.
  3. 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:

ColumnDescription
LabelThe descriptive name you gave the key
Key prefixThe first few characters of the key (for identification)
CreatedWhen the key was created
Last usedThe last time the key was used for an upload
ActionsRevoke

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.