# Retention & deletion

> What you can delete through the API, what deleting it changes, and what stays.

You can delete the files your jobs produced. Deleting is permanent. How long each kind of data is kept when you do nothing is on
[Data retention & storage](https://docs.refabric.com/task-apis/data-retention-and-storage).

## How it works

- `DELETE /v1/files/{ref}` deletes one produced file (`art:…`) of yours, and answers
  `{"file": "art:…", "deleted": true}`.
- Deletion applies to produced files; other handles (an upload, a record, a library item) answer `422 file_not_deletable`.
- A handle that is not yours answers `404`, as if it did not exist.
- A deleted file is permanent.

## Delete a produced file

::::code-group
```python
r = s.delete(f"{API}/files/art:x1")
print(r.json())  # {"file": "art:x1", "deleted": true}
```

```javascript
const r = await fetch(`${API}/files/art:x1`, { method: "DELETE", headers });
console.log(await r.json()); // { file: "art:x1", deleted: true }
```

```bash
curl -s -X DELETE "https://api.refabric.com/v1/files/art:x1" -H "Authorization: Key $REFABRIC_API_KEY"
```
::::

The same is in **Panel › Developers › Files & records**, for the kinds that can be deleted.

:::warning
Deleting is permanent. A `url` you already received keeps its bytes.
:::

## What deleting changes

| Action | Effect | What stays |
|---|---|---|
| Delete a produced file (`art:…`) | `GET /v1/files/art:…` answers `404` | the job that made or used it keeps its record; its result lists its remaining files |
| Delete an upload (`file:…`) | kept (`422 file_not_deletable`) | the upload |
| Delete a record or a library item | kept (`422 file_not_deletable`) | the record or item |
| Delete a job's data | kept | the job |
| Restore a deleted file | — (deleting is permanent) | — |

## Related

::::cards
:::card{title="Data retention & storage" href="/task-apis/data-retention-and-storage"}
How long each kind of data is kept.
:::
:::card{title="Using the Files & Records API" href="/records-and-libraries/using-the-files-and-records-api"}
What the API does.
:::
::::
