> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getmillwork.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Save recent receipts

> Export recent content-free run records as NDJSON.

**Goal:** Save up to 200 receipts created after a chosen UTC time.

**You are done when:** every exported line is valid JSON and you know how many
records were saved.

## Export the receipts

```bash theme={null}
export RECEIPTS_SINCE="2026-08-01T00:00:00Z"

if ! curl --fail-with-body \
  --get \
  --header "Authorization: Bearer $MILLWORK_API_KEY" \
  --data-urlencode "since=$RECEIPTS_SINCE" \
  --data-urlencode "format=export" \
  --data-urlencode "limit=200" \
  --output receipts.ndjson \
  "$MILLWORK_API_URL/receipts"; then
  echo "The export failed. Read receipts.ndjson before retrying." >&2
  exit 1
fi

jq -e -c . receipts.ndjson > /dev/null
wc -l receipts.ndjson
```

**Expected result:** `jq` exits without an error. `wc` shows how many receipt
records were saved.

## Store the file safely

Receipts do not contain prompts or model output. They do contain operational
details such as model, provider, usage, cost, and run IDs. Store them as
business records.

<Warning>
  This endpoint returns at most 200 receipts and does not currently provide a
  next-page token. Export often enough to keep each result below that limit.
  The export may be incomplete. Do not move the start time forward and call
  the result complete when a file reaches 200 records.
</Warning>

## If it fails

| What happened             | What to do                                                                                                                           |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `jq` reports invalid JSON | Keep the HTTP response and content type, then contact support without sending the file if it contains sensitive operational details. |
| The file is empty         | Check the UTC start time and whether the organization has finished runs.                                                             |
| The file has 200 lines    | Keep the file, export more often going forward, and contact support if you need a complete missing period.                           |
