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

  1. Read the file with include=affectedAgents and follow affectedAgents.nextPageToken to the last page.
  2. Show the person which agents use it and confirm with them.
  3. Take the confirmationToken from the last page (valid for 10 minutes).

Example

await platic.files.delete("file_123");

Path parameters

ParameterTypeDescriptionRequired
fileIdstringThe file✓

Request body

{ "confirmationToken": "del1...." }
FieldTypeDescriptionRequired
confirmationTokenstringaffectedAgents.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

FieldTypeDescription
fileIdstringThe file.
lifecyclestringAlways deleting.
operationIdstringThe delete operation.

Errors

Statusdetails.codeWhen
400INVALID_INPUTconfirmationToken is missing.
403RESOURCE_NOT_ACCESSIBLEIntegrations is missing.
410FILE_DELETEDIt was already deleted.
409CONFLICTWho 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 the confirmationToken for you right before deleting. If you first want to show a person which agents use the file, call platic.files.get(fileId, { include: ["affectedAgents"] }) and pass { confirmationToken } to delete.