# Leaked Prefect API Key? Revoke It and Audit Flows

> Prefect API key exposed on GitHub? Revoke it, check workspaces, deployments and work pools, then rotate. Step-by-step guide.

Source: https://leakwatch.net/secrets/prefect-api-key

---

[LeakWatch](/)

[Product](/product)[Live feed](/leaks)[Guides](/secrets)[Blog](/blog)[Free scan](/)

1.  [Home](/)
2.  [Secrets](/secrets)
3.  Prefect API Key

Code & CI · Secret guide

# Leaked Prefect API Key: what to do in the first hour

High severityDetected onlyLast verified October 30, 2026 · 4 min read

A Prefect Cloud API key authenticates the Prefect CLI, the Python client and automation to your Prefect Cloud account. It acts as the user, or the service account, that created it, in the workspaces that identity can reach. With it, someone can read flow runs and their logs, change or trigger deployments, edit variables and blocks, and manage work pools. Because Prefect runs your code, control over deployments can become code execution wherever your workers run. Revoke the key first, then investigate what was changed.

[Check your GitHub account for leaked secrets — free](/)

Provider

Prefect

Severity

High

Impact

SaaS account access and billing

Checked live by LeakWatch

No

## What a Prefect API key looks like

A Prefect Cloud key starts with `pnu_` followed by 36 letters and digits:

```text
pnu_XXXX…XXXX   Prefect API key (masked: 36 letters and digits after the prefix)
```

The key is commonly found in `PREFECT_API_KEY`, next to `PREFECT_API_URL`, which holds the account and workspace identifiers in the form of a URL. It is passed by `prefect cloud login --key` or as an `Authorization: Bearer` header to the API. Service account keys, available on plans that offer them, follow the same shape but are not tied to a person, so a leaked one affects the automation rather than someone’s login. The URL on its own is not a secret, but it tells an attacker exactly which workspace the key opens.

## How Prefect API keys get leaked

-   **Deployment and CI files.** `PREFECT_API_KEY` written in a workflow, a Dockerfile or a `prefect.yaml` instead of a secret.
-   **Environment files.** The key and the API URL in a `.env` or compose file that is committed.
-   **Login commands in scripts.** A `prefect cloud login --key ...` line in a setup script, a README or a notebook output.
-   **Worker and container images.** A key baked into an image or a Kubernetes manifest, then pushed to a registry.
-   **Shared notebooks and logs.** A debug cell or a pipeline log that prints the environment.

## What to do in the first hour

1.  **Revoke the key.** Sign in to Prefect Cloud, open the API keys page of your profile (see the link below) and delete the exposed key. The CLI also offers a command to revoke a key by its identifier.
2.  **Create a new key** with an expiration date, and where your plan allows, use a service account so that the key is not tied to a person.
3.  **Deploy the new key** to your secret store, CI and workers, then run a small flow to confirm it works.
4.  **Review the workspaces.** Look at recent flow runs, deployments and schedules for the period since the exposure. Check for runs you did not start, deployments with changed code, images or entrypoints, and new schedules.
5.  **Review work pools, blocks and variables.** Look for new pools or workers, changed credentials blocks, and variables with unfamiliar values. Blocks may hold cloud credentials: rotate any that the key could have read.
6.  **Review the account.** Check members, service accounts and other keys, and the audit events your plan provides.
7.  **Clean up the code** and look for neighbours such as cloud keys in the same file. See [I accidentally pushed an API key to GitHub](/blog/i-accidentally-pushed-an-api-key-to-github).

Not sure what else leaked from the same repository? [Run a free scan](/).

[Not sure what else leaked? Run a free scan.](/)

## Revoke it at Prefect

According to the Prefect documentation at [https://docs.prefect.io/latest/cloud/users/api-keys/](https://docs.prefect.io/latest/cloud/users/api-keys/), keys are managed from the API keys page of Prefect Cloud, reached from the account menu at the bottom of the interface, and a key is revoked by deleting it there. Sign in to Prefect Cloud with the account that owns the key, or ask an administrator if it belongs to a service account. A deleted key stops working at once. A person has not confirmed the exact menu wording for this guide, and the interface can change, so if the page differs from this description, look for the section where keys are listed, and follow the Prefect documentation.

## How LeakWatch detects it

The rule is called Prefect API Token. It recognizes `pnu_` followed by exactly 36 letters or digits, preceded by a word boundary and followed by a quote, a backtick, whitespace, a semicolon, an escaped newline or the end of the text. A value of another length, or one glued to other characters, is not reported, and it does not need a variable name. The severity is **high**. This type is not checked live: LeakWatch does not send any request to Prefect with the key it found.

LeakWatch detects this format but does **not** check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.

## FAQ

Can a stolen key run code in my infrastructure?

Potentially. It can change deployments that your workers execute, so the effect depends on your setup. Review deployments and work pools, not only the run history.

Should I use a service account key instead?

Where your plan offers it, yes. A service account is not tied to a person, so you can revoke it without affecting anyone’s login.

Does deleting the key stop runs already started?

No. Deleting prevents new calls, but flows already running keep going. Check the active runs and cancel any you do not recognize.

## Related

-   [CircleCI Personal Access Token](/secrets/circleci-personal-access-token)
-   [Sentry Access Token](/secrets/sentry-access-token)
-   [Snyk API Token](/secrets/snyk-api-token)
-   [I accidentally pushed an API key to GitHub](/blog/i-accidentally-pushed-an-api-key-to-github)
-   [Which vendors leak most this week](/leaks/trends)
-   [All secret guides](/secrets)

[Get alerted next time a secret leaks — create a free account](/)

LeakWatch is not affiliated with Prefect.

![Gabriel Diyan, founder of LeakWatch](/brand/Photo-Gabriel-Diyan.webp)

Gabriel Diyan (0xCr0c0)

Cybersecurity student, founder of LeakWatch. I built and run the scanner described here — the detection patterns, the false-positive classifier and the provider validators are mine. [More about who I am](/about).

[GitHub](https://github.com/Leakwatch-Scan) · [X](https://x.com/LeakwatchScan) · [LinkedIn](https://www.linkedin.com/in/gabriel-diyan-80a378375) · [GitHub (personal)](https://github.com/crocogab)

LeakWatch

Secrets leak into public commits every minute. This watches the forges for yours. Built and run by [Gabriel Diyan](/about), a cybersecurity student — [why LeakWatch exists](/about).

Scan

-   [Product](/product)
-   [Live feed](/leaks)
-   [Trends](/leaks/trends)
-   [API docs](/docs)
-   [CI/CD](/docs?tab=ci)

Read

-   [Blog](/blog)
-   [Secret guides](/secrets)
-   [Changelog](/changelog)
-   [About](/about)

Verify

-   [Security](/security)
-   [Privacy](/privacy)
-   [Terms](/terms)
-   [Legal](/legal)
-   [Contact](/contact)
-   [Status](https://status.leakwatch.net)

© 2026 LeakWatch

[GitHub](https://github.com/Leakwatch-Scan)[X](https://x.com/LeakwatchScan)
