> For a complete page index of the Captain API documentation, fetch https://docs.captain.dev/llms.txt?excludeSpec=true

# Delete Masking Report

DELETE https://api.captain.dev/v2/jobs/{job_id}/pii

Permanently delete a job's PII masking report before its automatic 90-day expiry. Later GET calls return 410 with `deleted_at`; the report is never regenerated. Refused while the job is still running. Requires a key with the `index` permission.

Reference: https://docs.captain.dev/reference/jobs/pii/delete

## Request

### Path parameters

- `job_id` (string, required) — ID of the job whose masking report to act on, as returned by the indexing endpoint that started it.

## Response

### 200

Successful Response

- `job_id` (string, required)
- `deleted` (boolean, required)
- `deleted_at` (string, required) — When the report was destroyed (RFC3339).
- `objects_deleted` (integer, required)

## Errors

### 401 Unauthorized Error

Missing or invalid API key

- `error` (string, required) — Always `HTTP_ERROR`.
- `message` (string, required)
- `status_code` (integer, required)
- `path` (string, optional) — Request path.

### 403 Forbidden Error

`missing_permission`: the key lacks the `index` permission

- `code` (string, required) — Machine-readable reason, listed per status code below.
- `message` (string, required)
- `deleted_at` (string, optional, nullable) — Only on 410 `deleted`: when the report was destroyed (RFC3339).
- `path` (string, optional) — Request path.

### 404 Not Found Error

Job not found, or it belongs to another organization

- `error` (string, required) — Always `HTTP_ERROR`.
- `message` (string, required)
- `status_code` (integer, required)
- `path` (string, optional) — Request path.

### 409 Conflict Error

`job_running`: the job is still processing. `not_masked`: the job did not run with `mask_pii`. `predates_feature`: the job was indexed before reports were kept

- `code` (string, required) — Machine-readable reason, listed per status code below.
- `message` (string, required)
- `deleted_at` (string, optional, nullable) — Only on 410 `deleted`: when the report was destroyed (RFC3339).
- `path` (string, optional) — Request path.

### 410 Gone Error

`deleted`: already deleted (`deleted_at` is included). `expired`: 90 days passed since the job ran and the report was removed automatically

- `code` (string, required) — Machine-readable reason, listed per status code below.
- `message` (string, required)
- `deleted_at` (string, optional, nullable) — Only on 410 `deleted`: when the report was destroyed (RFC3339).
- `path` (string, optional) — Request path.

### 503 Service Unavailable Error

`report_signer_unconfigured`, `registry_unavailable`, `report_store_unavailable`, or `job_status_unavailable`. Retry

- `code` (string, required) — Machine-readable reason, listed per status code below.
- `message` (string, required)
- `deleted_at` (string, optional, nullable) — Only on 410 `deleted`: when the report was destroyed (RFC3339).
- `path` (string, optional) — Request path.

## Examples

**Response**

```json
{
  "job_id": "job_01HZP5G8N3",
  "deleted": true,
  "deleted_at": "2025-01-21T14:02:11Z",
  "objects_deleted": 1
}
```

**SDK Code**

```python Python REST
import requests
import json

BASE_URL = "https://api.captain.dev"
API_KEY = "your_api_key"
JOB_ID = "job_01HZP5G8N3"

headers = {
    "Authorization": f"Bearer {API_KEY}",
}

response = requests.delete(
    f"{BASE_URL}/v2/jobs/{JOB_ID}/pii",
    headers=headers,
    timeout=30.0
)

if response.status_code == 200:
    data = response.json()
    print(f"Deleted {data['objects_deleted']} object(s) at {data['deleted_at']}")
else:
    print(f"Error: {response.status_code} {response.json().get('code')}")
```

```typescript TypeScript REST
const BASE_URL = "https://api.captain.dev";
const API_KEY = "your_api_key";
const JOB_ID = "job_01HZP5G8N3";

const response = await fetch(`${BASE_URL}/v2/jobs/${JOB_ID}/pii`, {
    method: "DELETE",
    headers: { "Authorization": `Bearer ${API_KEY}` },
});

if (response.ok) {
    const data = await response.json();
    console.log(`Deleted ${data.objects_deleted} object(s) at ${data.deleted_at}`);
} else {
    console.error(`Error: ${response.status}`);
}
```