---
title: "Release daily PII counts from Philter with a per-day privacy budget"
description: "Read the PII counts Philter records through its API and release them every day with Philter Diffuse, which keeps the privacy budget per UTC day so daily reports do not use it up."
url: "https://philterd.ai/guides/release-daily-pii-counts-from-philter-with-philter-diffuse/"
---

[Knowledge base](https://philterd.ai/guides/) [How-to](https://philterd.ai/guides/?kind=how-to)

# Release daily PII counts from Philter with a per-day privacy budget

Read the PII counts Philter records through its API and release them every day with Philter Diffuse, which keeps the privacy budget per UTC day so daily reports do not use it up.

For [Philter Diffuse](https://philterd.ai/support/philter-diffuse/) and [Philter](https://philterd.ai/support/philter/)

Philter can record how many documents contained each PII type, one bucket per UTC day, and [Philter Diffuse](https://philterd.ai/philter-diffuse/) can release those counts with noise. A daily report is a release every day, though, and if every release drew on one budget, a ceiling of 10 at 1.5 a release would stop the report after six days.

Philter Diffuse avoids that by keeping the budget for a Philter deployment per UTC day. Each document is recorded under one day, so releases over separate days do not add up for any one document. A release is charged to every day in its window, and the ceiling applies to each day. A daily report then spends one day’s budget each day, and a monthly report over the same days spends a second share of each.

This guide sets that up. For choosing the PII types, the noise scale, and the threshold, see [Publish PII counts with differential privacy](https://philterd.ai/guides/publishing-pii-counts-with-differential-privacy/).

![Philter records PII counts per UTC day, and each document is recorded under one day. In this example, a daily release costs epsilon 1.5 and is charged only to its own day, and a weekly release from November 25 to December 1 costs 1.5 and is charged to each of those seven days. Each day has then spent 3.0 of its 10.0 ceiling. A release is refused when any day in its window would pass the ceiling.](https://philterd.ai/images/guides/guide-diffuse-per-day-budget.svg)

> **Note:** Per-day budgets are in Philter Diffuse’s main branch, after the `0.1.0` release. Version `0.1.0`, including its Docker image, keeps one budget for the whole deployment and does not require `--from` and `--to`. Build from the repository until the next release.

## 1\. Turn on count recording in Philter

Philter 4.0 and later record counts only while the `diffuseCountsEnabled` setting is on. It is off by default. An administrator turns it on:

```bash
curl -sk -X PATCH https://localhost:8080/api/settings \
  -H "Authorization: Bearer $PHILTER_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"diffuseCountsEnabled": true}'
```

Create a key for Philter Diffuse that can only read the counts. Its user must be an administrator, because the counts cover the whole deployment:

```bash
curl -sk -X POST https://localhost:8080/api/api-keys \
  -H "Authorization: Bearer $PHILTER_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scopes": ["pii-counts:read"]}'
```

The response holds the new key in `apiKey`. Philter records counts from redactions made after recording is turned on. Each redaction that finds PII adds one to every type it redacted, whatever the number of matches, and a redaction that finds none is not recorded.

Philter’s Docker image serves HTTPS with a self-signed certificate. Export it so Philter Diffuse can verify the connection:

```bash
docker cp philter:/opt/philter/ssl/philter.p12 .
openssl pkcs12 -in philter.p12 -clcerts -nokeys -passin pass:philter -out philter.pem
```

## 2\. Install Philter Diffuse from the repository

```bash
git clone https://github.com/philterd/philter-diffuse.git
cd philter-diffuse
python3 -m venv venv
venv/bin/pip install -r requirements.txt
```

A build from the main branch still reports `Philter Diffuse 0.1.0` from `--version`. Check for per-day budgets with `--help`: the description of `--budget-ceiling` ends “and with –philter-url per UTC day.”

## 3\. Release one day

Put the key in `PHILTER_API_KEY`, and the budget file somewhere it will be kept and backed up:

```bash
export PHILTER_API_KEY=<the pii-counts:read key>
export PHILTER_DIFFUSE_BUDGET_FILE=/var/lib/philter-diffuse/privacy_budget.json

venv/bin/python main.py \
  --philter-url https://localhost:8080 \
  --philter-ca-cert philter.pem \
  --context claims-intake \
  --pii-types ssn,email-address,person \
  --from 2026-12-01 --to 2026-12-01 \
  --output pii-counts-2026-12-01.csv
```

`--from` and `--to` are required with `--philter-url`. They are UTC days, both inclusive. `--context` is optional and narrows the counts to one context. In Philter 4.0.1, a context filter also narrows the counts to the API key’s own user unless `ADMIN_CROSS_USER_ACCESS_ENABLED` is set, so redactions made with other users’ keys are left out. Use Philter’s type names: names are counted as `person`.

Output, which differs on every run because the noise is random:

```text
Reading PII counts from Philter at https://localhost:8080...

========================================
PRIVACY AUDIT REPORT
========================================
Privacy Loss (Epsilon): 1.5000
Protection Strength:   MODERATE
Influence Limit:      e^1.50 (4.48x)
Output File:          pii-counts-2026-12-01.csv
----------------------------------------
PII Type        | Private 
----------------------------------------
ssn             | 4       
email-address   | 10      
person          | 4       
----------------------------------------
Results successfully written to pii-counts-2026-12-01.csv
========================================
```

Three types at the default scale of 2.0 cost epsilon 1.5. The counts behind this run were 2, 3, and 3, from six invented test texts. At counts that small, the noise is about as large as the counts, which is the point: a day with few documents reveals little about any one of them. Add `--threshold` to print small noised counts as `None`.

## 4\. How the per-day budget adds up

The budget file keeps each release’s window and epsilon under the deployment’s URL:

```json
{
  "pii_count_aggregates@https://localhost:8080": {
    "spent_on_every_day": 0.0,
    "releases": [
      {"from": "2026-12-01", "to": "2026-12-01", "epsilon": 1.5},
      {"from": "2026-11-01", "to": "2026-11-30", "epsilon": 1.5},
      {"from": "2026-11-25", "to": "2026-12-01", "epsilon": 1.5}
    ]
  }
}
```

A day has spent the sum of the releases whose windows include it. After these three releases, December 1 and November 25 to 30 have each spent 3.0, and November 1 to 24 have spent 1.5. The monthly release cost 1.5 in total, not 1.5 for each of its 30 days.

A release is refused when any day in its window would pass `--budget-ceiling` (default 10.0). The error names that day:

```text
Error: This release costs epsilon 1.5, and 2026-12-01 has spent 9 of its budget ceiling of 10 at pii_count_aggregates@https://localhost:8080. Nothing was released and no budget was spent. Raise --scale or list fewer types to spend less, or release days with budget left.
```

The run exits with status 1 and leaves any existing output file unchanged. Philter Diffuse reads the counts before it checks the budget, so Philter’s audit log records a `pii_counts_retrieved` event for a refused run too, although nothing was released.

Every read from one Philter URL draws on the same per-day budget, whatever `--context` it uses. Keep one budget file for each deployment, and use the same URL every time: the budget is keyed by the URL, so `https://philter.internal:8080` and `https://10.0.4.12:8080` would be tracked separately.

## 5\. Release yesterday, every day

Release a day once it is over. Today’s counts are still growing, and releasing the same day again later charges it twice. This script releases yesterday’s counts. Save it as `/opt/philter-diffuse/release-yesterday.sh` in the clone from step 2 (here at `/opt/philter-diffuse`), and make it executable with `chmod +x`:

```bash
#!/bin/bash
# Release yesterday's PII counts (a UTC day) from Philter. Run once a day from cron.
set -euo pipefail

DAY=$(date -u -d yesterday +%F)
export PHILTER_API_KEY=$(cat /etc/philter-diffuse/api-key)
export PHILTER_DIFFUSE_BUDGET_FILE=/var/lib/philter-diffuse/privacy_budget.json

cd /opt/philter-diffuse
venv/bin/python main.py \
  --philter-url https://philter.internal.example.com:8080 \
  --philter-ca-cert /etc/philter-diffuse/philter.pem \
  --pii-types ssn,email-address,person \
  --threshold 5 \
  --from "$DAY" --to "$DAY" \
  --output "/var/lib/philter-diffuse/reports/pii-counts-$DAY.csv"
```

Run it once a day from cron:

```text
15 0 * * * /opt/philter-diffuse/release-yesterday.sh
```

The script releases the previous UTC day, which is complete whatever the server’s time zone, so each day is released once. `date -d yesterday` is GNU `date`. With the default ceiling, a day released daily at 1.5 can still be included in five more releases of the same size, such as a weekly and a monthly report.

Point dashboards at the CSV files, not at Philter Diffuse. Reading a released file costs nothing, and every run is a new release.

## Where to go next

- [Run Philter Diffuse on a schedule](https://philterd.ai/guides/run-philter-diffuse-on-a-schedule/) covers keeping the budget file, alerting on a refused run, and raising the ceiling.
- [Publish PII counts with differential privacy](https://philterd.ai/guides/publishing-pii-counts-with-differential-privacy/) covers what the bound means and how to pick the scale and types.
- The [Philter Diffuse documentation](https://philterd.github.io/philter-diffuse/privacy-budget/) describes the budget file and resetting it.

Differential privacy limits what a release reveals about one document. A person who appears in many documents is protected less, in proportion, and the released counts are not anonymous in a legal sense. It is one control that supports your compliance efforts, so validate the settings against how your own data is structured.
