> For the complete documentation index, see [llms.txt](https://assetstore.essentialkit.voxelbusters.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://assetstore.essentialkit.voxelbusters.com/features/task-services/playmaker/use-cases/use-case-2-quota-management.md).

# Quota Management (Emergency Save)

## Goal

If background time is about to expire, switch to a minimal “save critical data and stop” path.

## Actions used

* `TaskServicesStartTaskAndAllowInBackground`
* `TaskServicesCancelTask`

## Flow

1. When app is suspending:
   * Start background allowance (`TaskServicesStartTaskAndAllowInBackground`) and do your normal save/upload work.
2. If `quotaWillExpireEvent` fires:
   * State: `EmergencySaveMinimal`
     * Stop optional work.
     * Save only critical state (fastest possible).
     * Call `TaskServicesCancelTask` to end the task and exit quickly.

## Notes

* Assign `quotaWillExpireEvent` on `TaskServicesStartTaskAndAllowInBackground` and add it as a Global Transition to your emergency state.
