# Leaked keys

Reports of leaked keys: GitHub secret scanning, anyone's report, and your matched reports.

Related guide: [If a key leaks](https://provenanceauth.com/docs/account/if-a-key-leaks.md)

## Endpoints

- `GET /v1/leaked_key_reports`: [List leaked-key reports](#get-v1-leaked-key-reports)
- `POST /v1/public/leaked_keys`: [Report a leaked key](#post-v1-public-leaked-keys)

## The leaked key report object

### Attributes

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | no | Unique identifier for the object. |
| `object` | enum | no | The type of object. One of `leaked_key_report`. |
| `kind` | enum | no | What leaked. One of `api_key`, `webhook_secret`, `agent_signing_key`. |
| `key_ref` | string | no | The API key, webhook endpoint or signing key it matched. |
| `key_environment` | string \| null | no | The key's environment (`sandbox` or `live`). |
| `source` | enum | no | Who reported it. One of `github`, `public`. |
| `found_at` | string \| null | no | The URL from the report. |
| `outcome` | enum | no | What Provenance did. One of `revoked`, `reported`, `rotated`, `notify_only`, `already_revoked`. |
| `created_at` | string | no | When it was created. |

## Events

Sent to your [webhook endpoints](https://provenanceauth.com/docs/integrate/webhooks.md) when they subscribe:

- `api_key.leaked`

## List leaked-key reports

`GET /v1/leaked_key_reports`

Reports that matched one of your keys, newest first: what leaked, where it was found and what Provenance did. A hash of the value is kept, never the value.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `limit` | query | integer | no | Page size, 1–100 (default 20). Outside the range → 400 parameter_invalid. |
| `cursor` | query | string | no | Opaque; pass a response's `next_cursor` back to get the next page. |

### Returns

A page of reports.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl "$PROVENANCE_API/v1/leaked_key_reports" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/leaked_key_reports`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/leaked_key_reports", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "list",
  "data": [],
  "has_more": false,
  "next_cursor": null
}
```

## Report a leaked key

`POST /v1/public/leaked_keys`

Anyone can report a Provenance key, no account needed. Always 202 with the same body, whether the key is valid, unknown or revoked. 10 reports an hour per address.

Auth: none. No API key needed.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | body | string | yes | The whole key: an API key, a webhook signing secret, or an agent signing key's private JWK as JSON. |
| `url` | body | string | no | Where you found it. |

### Returns

Received.

### Errors

- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`parameter_missing`](https://provenanceauth.com/docs/platform/errors.md#parameter_missing)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
curl -X POST "$PROVENANCE_API/v1/public/leaked_keys" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "prv_live_notarealkeyatall000000000000000",
    "url": "https://github.com/example/repo/blob/main/.env"
  }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/public/leaked_keys`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "key": "prv_live_notarealkeyatall000000000000000",
    "url": "https://github.com/example/repo/blob/main/.env"
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/public/leaked_keys", json={
    "key": "prv_live_notarealkeyatall000000000000000",
    "url": "https://github.com/example/repo/blob/main/.env"
}).json()
```

### Response 202

```json
{
  "object": "leaked_key_report_receipt",
  "received": true,
  "message": "Thanks. If this is a Provenance key, its owner is told and it is handled."
}
```
