# Cleaning up

Remove only your test run after producers and waits have finished.

<a id="guide-content"></a>



For the Bash commands below, continue in the same terminal after the Bash / curl tab of the [first-email quickstart](https://www.inboxspec.com/docs/markdown/first-email.md#first-email-bash). Its run ID, inbox and matched message variables are used below.

<a id="cleanup"></a>



<a id="clean-up-this-test-run"></a>

## Clean up this test run

Optional, after inspection: this permanently deletes inboxes with this run’s tag prefix, their messages and stored content.

Keep the generated run ID; do not replace it with a shared prefix. Cleanup needs inbox write permission.

```bash
if [[ "$RUN_ID" =~ ^first-[a-f0-9]{24}$ ]]; then
  curl --fail-with-body --silent --show-error "$INBOXSPEC_API_URL/v1/inboxes/cleanup" \
    -H "Authorization: Bearer $INBOXSPEC_API_KEY" \
    -H "content-type: application/json" \
    -d "$(jq -n --arg tag_prefix "$RUN_ID" '{tag_prefix: $tag_prefix}')"
else
  printf '%s\n' 'Use the complete run ID created in step 1; cleanup was not sent.' >&2
  false
fi
```

<a id="fixture-cleanup"></a>

## Clean up CI fixtures

For a fixture manifest, use the exact run ID passed to fixture setup. The example below matches the run in the [OTP test recipe](https://www.inboxspec.com/docs/markdown/otp-tests.md); replace it with your own run ID.

```bash
inboxspec fixtures cleanup --run ci.4182.a1.w1 --json
```

Run cleanup after producers and waits finish, in a finally block or an always-run CI step. Check for complete cleanup and resume an incomplete cleanup with the same run ID. Cleanup does not reset usage or remove accounting history.
