---
agentTools:
  projectIndex: https://developers.pipefy.com/llms.txt
---

# Delete Assistant Knowledge Base Document

Delete a knowledge base document from an AI assistant

## Before You Begin

🔗 **Use the [GraphQL Playground](https://app.pipefy.com/graphiql)** to execute the queries in this guide.

➡️ **New to GraphQL?** Learn how to navigate the Playground with our **[Playground Basics Guide](https://developers.pipefy.com/reference/exploring-the-playground)**.

## Prerequisites

1. **Authentication**: Use a [Service Account token](https://developers.pipefy.com/reference/service-accounts) (Personal Access Tokens are deprecated).
2. **Permissions**: You must be a **super admin** of the organization.
3. **Document ID**: The `id` of the document to delete. See [Create Assistant Knowledge Base Document](https://developers.pipefy.com/reference/create-assistant-knowledge-base-document-mutation).
4. **Assistant ID**: The UUID of the assistant that owns the document.
5. **Organization UUID**: The UUID of the organization that owns the assistant.

## Delete an Assistant Knowledge Base Document

Use the `deleteAiAssistantKnowledgeBaseDocument` mutation to permanently remove a knowledge base document from an assistant. This action cannot be undone.

#### Inputs

* **assistantId**: UUID of the assistant that owns the document (required).
* **organizationUuid**: UUID of the organization that owns the assistant (required).
* **documentId**: ID of the document to delete (required).

```graphql
mutation {
  deleteAiAssistantKnowledgeBaseDocument(
    input: {
      assistantId: "assistant-uuid-123"
      organizationUuid: "org-uuid-456"
      documentId: "doc-uuid-789"
    }
  ) {
    success
    errors
  }
}
```

Response:

```json
{
  "data": {
    "deleteAiAssistantKnowledgeBaseDocument": {
      "success": true,
      "errors": []
    }
  }
}
```

### Response explained

* **success**: `true` when the document was deleted successfully.
* **errors**: Empty array on success. Contains error messages if the operation failed.

### Error handling

If the deletion fails (e.g., permission denied or organization not found), you'll receive an error response:

```json
{
  "data": {
    "deleteAiAssistantKnowledgeBaseDocument": null
  },
  "errors": [
    {
      "message": "Permission denied",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": ["deleteAiAssistantKnowledgeBaseDocument"]
    }
  ]
}
```

#### Error response explained

* **data.deleteAiAssistantKnowledgeBaseDocument**: Returns `null` when the operation fails.
* **errors**: Array containing error details when the operation fails.
* **errors\[].message**: Human-readable error description. Common messages:
  * `"Permission denied"` — the authenticated user is not a super admin of the organization.
  * `"Organization not found with id: <uuid>"` — the `organizationUuid` does not match an existing organization.

## Tips

* **Irreversible**: Deletion is permanent. Re-upload and re-create the document if needed.
* **Assistant scope**: This mutation works with any assistant regardless of which channel it is connected to (portal, Slack, pipe, etc.).
* **Finding your document ID**: The `id` is returned by the `createAiAssistantKnowledgeBaseDocument` mutation. See [Create Assistant Knowledge Base Document](https://developers.pipefy.com/reference/create-assistant-knowledge-base-document-mutation).