Move a file to Deleted items through the API

Trash a file idempotently with trash_only, verify it in the deleted listing, and avoid a second bare DELETE that permanently erases every version.

Last reviewed

Use DELETE /api/files/:id?trash_only=1 when automation intends a recoverable delete. The safeguard makes repeated delivery harmless. A bare DELETE is state-dependent: it trashes a live file, but permanently purges an already trashed file.

Four workflow panels show reading the live target, sending a recoverable delete, accepting its safe receipt, and finding the same ID in Deleted items.
The diagram covers reading the live target, sending a recoverable delete, accepting its safe receipt, and finding the same ID in Deleted items. Open full-size screenshot.

Before you start

  • Use a full-access API key. The workspace role needs delete_own_files for the caller’s files or delete_any_file for other owners’ files.
  • Record the file ID, name, version count, and current parent before deletion.
  • Deleted items continue to consume storage until permanent purge. Purge is irreversible.

Steps

  1. Read the target metadata and confirm the ID belongs to the intended workspace. Stop if it is already deleted unless the job explicitly handles that state.
  2. Send DELETE /api/files/file_id?trash_only=1 with the bearer key. Keep permanent=1 out of the request; the two flags must not be combined.
  3. Accept { "ok": true, "permanent": false } for the first trash action. A repeated safe request may return { "ok": true, "already_trashed": true }.
  4. Query GET /api/files?deleted=1 and locate the same ID. Its absence from the normal listing alone is insufficient evidence because filters and pagination can also hide an item.
  5. Store the trash receipt with the job record. Do not issue an unqualified second DELETE as a generic retry because the server would interpret the trashed state as permission to purge.
  6. If permanent removal is explicitly approved, send DELETE /api/files/file_id?permanent=1 and verify disappearance from the deleted listing. Treat that action and all versions as unrecoverable.
Dosya developer overview with API and SDK entry points for move a file to deleted items through the api.
The developer overview supplies the API and SDK entry points referenced by “Move a file to Deleted items through the API”. Open full-size screenshot.

Expected result

The safe request moves a live file to Deleted items, and repeating it reports already_trashed instead of purging. Storage usage falls only after a separately requested permanent deletion.

Troubleshooting

The file is not in the deleted listing. Check pagination, workspace, and the response status before retrying.

The request returns 403. Confirm full key scope, ownership permission, and lock rules.

A bare DELETE response was lost. Inspect both normal and deleted listings before any new call. Never use an unqualified retry against an item that might already be trashed.

Was this helpful?

Loading helpfulness results…

Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.

Questions and replies

Ask about the steps in this guide. Questions are reviewed before publication.

Keep account details, credentials and private files out of public questions. Use private support for those.

Loading questions…

    Sign in to your Dosya account to ask a question.

    Check the outcome before you retry

    Use these shared checks when a task needs a second look.