Temporary Storage Cleanup API
Temporary storage maintenance methods manage files and task records owned by the SDK Runtime and are called through Command WS.
storage.cleanup_temp
Cleans temporary capture files, task files, and completed task caches across the entire Runtime. The current connection must have a valid session bound through auth.create_session. This maintenance method does not require an additional business capability and does not consume call quota.
Request
There are no public business parameters; use an empty params object. Clients cannot supply work_dir or an arbitrary deletion path.
{
"request_id": "req-cleanup-001",
"method": "storage.cleanup_temp",
"params": {}
}Cleanup Scope and Preconditions
Save any results you need to keep first
Cleanup affects the entire Runtime, not just tasks owned by the current connection, and can affect other connections. Save required results outside the cleanup scope before calling this method, and call it only when no tasks are active.
- Deletes the
capture/andtasks/directories and their contents under the Runtime working directory, and clears completed task caches and associated asset indexes. - Original images, processed images, thumbnails, and exported files within these directories may be deleted. Custom output files outside the working directory are not deleted, but their associated task records and asset indexes may still be cleared.
- After cleanup, old task queries and related managed asset URLs may no longer work. Do not rely on old task IDs or asset links to retrieve results.
- Returns
1800 / STORAGE_BUSYimmediately if tasks are active or the storage lifecycle lock is in use. It does not wait for or automatically cancel tasks. Acceptance of a cancellation request does not mean underlying execution has ended; wait for it to finish before retrying cleanup. - File deletion is not transactional. A failed cleanup may have already deleted some files, and no automatic rollback is performed.
Successful Response
{
"request_id": "req-cleanup-001",
"code": 0,
"message": "ok",
"data": {
"capture_removed": true,
"tasks_removed": true,
"cleared_task_count": 3
},
"ts": 1710000000
}| Field | Type | Description |
|---|---|---|
capture_removed | boolean | true if capture/ existed and was successfully deleted. false if it did not exist; this does not indicate cleanup failure. |
tasks_removed | boolean | true if tasks/ existed and was successfully deleted. false if it did not exist; this does not indicate cleanup failure. |
cleared_task_count | non-negative integer | Number of completed task records cleared, not the number of deleted files or assets. |
Busy Response
When active tasks are detected, the response may include data.active:
{
"request_id": "req-cleanup-001",
"code": 1800,
"message": "temporary storage is busy",
"data": {
"active": {
"capture": 0,
"image_enhance": 0,
"ocr": 1,
"sane": 0,
"twain": 0
}
},
"ts": 1710000000
}The fields in active report active task counts by type for diagnostics only. The object may be absent, for example when the lifecycle lock is in use. Detect a busy state using code=1800; do not require active to be present or use its summed counts instead of the status code.
Error Handling
| code | Name | Description and Action |
|---|---|---|
1100 | AUTH_REQUIRED | The current connection has no valid bound session. Call auth.create_session first. |
1800 | STORAGE_BUSY | Tasks are active or temporary storage is in use. Wait for current operations to finish before retrying. |
1901 | PROVIDER_NOT_READY | Storage Provider is not ready. Check Runtime startup and Provider configuration. |
1902 | PROVIDER_CALL_FAILED | Directory deletion failed. Check file permissions, files in use, and Runtime logs. Failure does not guarantee that no files were deleted. |
1002 | INVALID_PARAMS | The server's working-directory configuration is invalid. Check Runtime configuration rather than adding a deletion path to the request. |
See Protocol Model for the common response structure and Error Codes for the full status-code reference.