API keys
An API key is a long-lived token tied to one user account, and the recommended way to authenticate CI pipelines, the Playwright reporter and scripts once authentication is on. A key carries its owner's access: their instance role and the project roles they hold, directly or through their groups. A key for a Member with the Uploader role on one project can read that project and upload to it, and nothing else. The key a connected run target receives (the desktop app, Piwi Runner) is the one exception: it holds run:receive and, for the desktop app, project:read, and serves only that app's routes.
For CI, give the key to a dedicated account that can only upload: CI accounts says which role and where.
With authentication on, every endpoint needs a session cookie or an API key whose owner holds the permission the endpoint declares (listed per endpoint in the API docs). The exceptions are the health and version endpoints, the sign-in flows themselves, and live-run streaming, which uses per-run stream tokens.
Security properties
- Keys are generated with 256 bits of cryptographic entropy (
pd_prefix + 64-character hex string). - Only a SHA-256 hash of the key is stored in the database: the plaintext is shown once at creation time and is never retrievable again.
- Each key displays a short prefix (
pd_xxxxxxxx…) in the UI for identification without revealing the secret, with its creation date and when it was last used. - Keys are sent as
Authorization: Bearer <key>orX-API-Key: <key>headers. - Keys can be given an optional expiry date.
What a key cannot do
A key acts for its owner everywhere except on the account's own credentials. These take a signed-in session, and a request with a key gets a 403:
- creating an API key, for any account;
- allowing a browser extension, an editor or an MCP client to connect, which creates a key or a connection for the account;
- changing the account's password or its own email address, and disconnecting its OAuth provider.
A key therefore cannot create keys or change its own account's credentials, nor move the account's password reset to another address. An administrator's key still manages the other users, their email addresses included, and creates accounts with a password, so it is as powerful as the administrator's password: keep it with the same care.
Creating an API key
Every signed-in user manages their own keys under Settings → Account → API keys. An administrator can also manage any user's keys from Settings → Users, with the key icon next to the user; that is how you create a key for a dedicated CI account.
- Click Create API key, enter a descriptive name (e.g. "GitHub Actions"), and set an optional expiry.
- Click Generate key, and copy the key immediately: it will never be shown again.
- Store it as a CI secret (e.g.
PIWI_API_KEY).
Connecting the browser extension, an editor or the desktop app creates a key too, once you click Allow on the page it opens: it is named after the app ("Piwi Picker in Chrome on Windows") and listed under Settings → Account → Connected apps, not with these keys.

Revoking an API key
Click the trash icon next to the key, in the same place you created it. The key stops working immediately.
Using the API key in the reporter
The reporter needs a credential only once authentication is on, and sends its key as an Authorization: Bearer header. Settings → Connect a suite creates a key in place. The reporter reads it from PIWI_API_KEY, in the environment or in the .env beside the Playwright config (init --api-key writes it there, unless git tracks that file or cannot say whether it does, or the file is a link), so the config needs no change: store the key as a CI secret under that name, and locally in that .env. To read it from another variable, pass it as the apiKey option, in the wrapConfig options or the reporter entry:
// playwright.config.ts
import { defineConfig } from '@playwright/test'
import { wrapConfig } from '@piwitests/reporter'
export default wrapConfig(defineConfig({ testDir: './tests' }), {
serverUrl: 'https://your-dashboard.example.com',
projectName: 'my-project',
apiKey: process.env.MY_DASHBOARD_KEY,
})Using the API key in raw HTTP calls
# Authorization: Bearer header (recommended)
curl -X POST https://your-dashboard.example.com/api/test-runs/submit -H "Authorization: Bearer pd_<your-key>" -H "Content-Type: application/json" -d '{ ... }'
# X-API-Key header (alternative)
curl -X POST https://your-dashboard.example.com/api/test-runs/submit -H "X-API-Key: pd_<your-key>" -H "Content-Type: application/json" -d '{ ... }'# Authorization: Bearer header (recommended)
Invoke-RestMethod -Method Post -Uri https://your-dashboard.example.com/api/test-runs/submit `
-Headers @{ Authorization = 'Bearer pd_<your-key>' } `
-ContentType 'application/json' -Body '{ ... }'
# X-API-Key header (alternative)
Invoke-RestMethod -Method Post -Uri https://your-dashboard.example.com/api/test-runs/submit `
-Headers @{ 'X-API-Key' = 'pd_<your-key>' } `
-ContentType 'application/json' -Body '{ ... }'Using the reporter with a username and password
As an alternative to API keys, give the reporter the credentials of a dedicated CI account, created in Settings → Users: set PIWI_USERNAME (its username or email address) and PIWI_PASSWORD as secrets in your CI provider (or the username and password options). An API key wins when both are set.
The reporter signs in once per run, when it opens the run's stream (at the end of the run with streaming: false), and uses the session for every request of the run; the global setup step signs in once more, in its own process, when it registers the run. A sign-in that fails while the dashboard is down is tried again with the stream. API keys are still preferred for CI: they need no sign-in round-trip, and each one can be revoked on its own.
Related
- Authentication: turning sign-in on, instance roles and user management
- Access, roles and groups: the project roles a key's owner can hold
- Reporter: every reporter option
- Metrics and rollup export: scraping with an API key