# CasePatch API quickstart

Production data anonymization for AI agent evals, from Python or any HTTP client.

## 1. Install

```sh
pip install casepatch              # cloud client, no dependencies
pip install "casepatch[local]"     # adds the local engine (runs on your machine, nothing uploaded)
casepatch setup-local              # one-time model download (~210 MB) for local mode
```

## 2. Anonymize

Local (no key, nothing leaves your machine):

```python
from casepatch import CasePatch
cp = CasePatch(mode="local")
cp.anonymize("statement.pdf", out="statement.anon.pdf")
```

Cloud: create a key on your account page (shown once), then:

```sh
export CASEPATCH_API_KEY=cpk_...
casepatch anonymize ./docs --out ./anon --cloud
```

## 3. REST

```sh
curl -X POST https://casepatch.com/api/v1/anonymize -H "Authorization: Bearer $CASEPATCH_API_KEY" \
     -H "Content-Type: application/pdf" --data-binary @statement.pdf            # -> {"id": "...", "status": "queued"}
curl https://casepatch.com/api/v1/jobs/$ID -H "Authorization: Bearer $CASEPATCH_API_KEY"   # status, summary, changes
curl -o anon.pdf https://casepatch.com/api/v1/jobs/$ID/result -H "Authorization: Bearer $CASEPATCH_API_KEY"
curl -X DELETE https://casepatch.com/api/v1/jobs/$ID -H "Authorization: Bearer $CASEPATCH_API_KEY"
```

OpenAPI: `https://casepatch.com/api/v1/openapi.json`.

## Limits and data handling

* PDF, PNG, JPG; same size and page limits as web uploads.
* Billing: free monthly pages first, then prepaid credits (5 credits = $0.05 per page). Local mode is free.
* Per key: 60 documents an hour, 2 at a time, 120 requests a minute.
* Cloud uploads are deleted when processing ends; results are deleted on `DELETE` or 15 minutes after they are ready.
* Detection can miss values. Review every output. Not a compliance certification.
