Delete a file
SDK platic.files.delete()
Deletes the file from the workspace. All the agents that use it stop using it, and it cannot be undone. To remove it from a single agent and keep it in the workspace, use Disconnect a file.
Before you delete
- Read the file with
include=affectedAgentsand followaffectedAgents.nextPageTokento the last page. - Show the person which agents use it and confirm with them.
- Take the
confirmationTokenfrom the last page (valid for 10 minutes).
Example
curl -X DELETE "https://api.platic.ai/v1/files/$FILE_ID" \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "confirmationToken": "'"$CONFIRMATION_TOKEN"'" }' await platic.files.delete("file_123"); Path parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
fileId | string | The file | ✓ |
Request body
{ "confirmationToken": "del1...." } | Field | Type | Description | Required |
|---|---|---|---|
confirmationToken | string | affectedAgents.confirmationToken from the last page of Get a file | ✓ |
Response
202 Accepted while it is being deleted:
{
"status": "success",
"data": {
"fileId": "fH3kL9mQ2xR7",
"lifecycle": "deleting",
"operationId": "deletion_5Gt2Rk9Mw1"
}
} From that moment no agent uses it and the file appears with lifecycle: "deleting". When it finishes deleting, repeating the same request answers 204 No Content, with no body, and reading it answers 410 FILE_DELETED.
Response fields
| Field | Type | Description |
|---|---|---|
fileId | string | The file. |
lifecycle | string | Always deleting. |
operationId | string | The delete operation. |
Errors
| Status | details.code | When |
|---|---|---|
400 | INVALID_INPUT | confirmationToken is missing. |
403 | RESOURCE_NOT_ACCESSIBLE | Integrations is missing. |
410 | FILE_DELETED | It was already deleted. |
409 | CONFLICT | Who uses the file changed or the confirmationToken expired. Request the list of agents again and confirm again. |
The ones that apply to all operations are in common errors.
Notes
- In the SDK,
platic.files.delete(fileId)gets theconfirmationTokenfor you right before deleting. If you first want to show a person which agents use the file, callplatic.files.get(fileId, { include: ["affectedAgents"] })and pass{ confirmationToken }todelete.
Warning
There is no trash or history: the content is erased. Download links already issued may work until they expire (5 minutes).