> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hydradb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Knowledge

> Permanently delete one or more knowledge sources by ID.

## When to use it

* **Cleanup** – remove outdated documents
* **Right-to-deletion** – fulfill GDPR/privacy requests for specific items
* **Reprocessing** – delete then re-ingest after changing metadata schema or content

For removing user memories, use [`DELETE /memories/delete_memory`](/api-reference/endpoint/delete-memory). To remove an entire tenant, use [`DELETE /tenants/delete`](/api-reference/endpoint/delete-tenant).

<Warning>
  **This operation is irreversible.** Deleted sources cannot be recovered.
</Warning>

## Endpoint

* **Auth:** Bearer token
* **Idempotency:** Re-sending a previously-deleted ID returns `deleted: false` for that item, but the request as a whole still returns `200`.
* **Async:** No

<Info>
  **Why POST and not DELETE?** This endpoint accepts a JSON body with an array of IDs. Some HTTP infrastructure strips bodies from `DELETE` requests, so HydraDB uses `POST` to ensure the bulk payload is reliably transmitted.
</Info>

## Example

<CodeGroup>
  ```bash cURL theme={"dark"}
  curl -X POST 'https://api.hydradb.com/knowledge/delete_knowledge' \
    -H "Authorization: Bearer <your_api_key>" \
    -H "Content-Type: application/json" \
    -d '{
      "tenant_id": "my_first_tenant",
      "ids": ["doc_12345", "doc_67890"]
    }'
  ```

  ```typescript TypeScript SDK theme={"dark"}
  const response = await client.data.delete({
    tenant_id: "my_first_tenant",
    ids: ["doc_12345", "doc_67890"]
  });
  ```

  ```python Python SDK theme={"dark"}
  response = client.data.delete(
      tenant_id="my_first_tenant",
      ids=["doc_12345", "doc_67890"],
  )
  ```
</CodeGroup>

## Request parameters

| Name            | Type      | Required | Description                                                   |
| --------------- | --------- | -------- | ------------------------------------------------------------- |
| `tenant_id`     | string    | Yes      | The tenant the sources belong to.                             |
| `ids`           | string\[] | Yes      | One or more `source_id` values to delete (minimum 1).         |
| `sub_tenant_id` | string    | No       | Sub-tenant scope. If omitted, the default sub-tenant is used. |

## Response

```json theme={"dark"}
{
  "success": true,
  "message": "Delete completed",
  "results": [
    {
      "id": "doc_12345",
      "deleted": true,
      "error": null
    },
    {
      "id": "doc_67890",
      "deleted": false,
      "error": "Source not found"
    }
  ],
  "deleted_count": 1
}
```

| Field               | Description                                                            |
| ------------------- | ---------------------------------------------------------------------- |
| `success`           | `true` if the request was processed (regardless of per-item outcomes). |
| `results[]`         | One entry per requested ID.                                            |
| `results[].id`      | The source ID that was processed.                                      |
| `results[].deleted` | `true` if the source was found and deleted, `false` otherwise.         |
| `results[].error`   | Error message if `deleted: false`.                                     |
| `deleted_count`     | Total number of sources successfully deleted.                          |

## Behavior notes

<Info>
  **Partial success is possible.** A request can return `success: true` while some individual items fail. Always inspect `results[]` to confirm each deletion outcome – don't rely on the top-level `success` flag alone.
</Info>

<Info>
  **Cascade scope.** Deleting a knowledge source removes its chunks, embeddings, and any graph entities/relations exclusively associated with it. Entities shared with other sources are retained.
</Info>

## Related endpoints

* **Browse before deleting:** [List data](/api-reference/endpoint/list-data) – confirm what you're about to remove
* **Delete a single memory:** [Delete memory](/api-reference/endpoint/delete-memory)
* **Delete an entire tenant:** [Delete tenant](/api-reference/endpoint/delete-tenant)

## Errors

Common codes: `400 INVALID_PARAMETERS`, `404 TENANT_NOT_FOUND`, `422 VALIDATION_ERROR`. See [Error Responses](/api-reference/error-responses) for the full list.


## OpenAPI

````yaml POST /knowledge/delete_knowledge
openapi: 3.1.0
info:
  title: HydraDB API
  description: REST APIs for the HydraDB retrieval engine
  version: 0.0.1
servers:
  - url: https://api.hydradb.com
    description: Production
    x-fern-server-name: hydradb-prod
security: []
paths:
  /knowledge/delete_knowledge:
    post:
      tags:
        - delete
      summary: Delete Source
      operationId: delete_source_knowledge_delete_knowledge_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SourceDeleteRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SourceDeleteResponse'
        '400':
          description: Bad Request - Invalid input parameters
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/cortex__models__response__commons__ActualErrorResponse
        '401':
          description: Unauthorized - Authentication required
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/cortex__models__response__commons__ActualErrorResponse
        '403':
          description: Forbidden - Access denied
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/cortex__models__response__commons__ActualErrorResponse
        '404':
          description: Not Found - Resource does not exist
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/cortex__models__response__commons__ActualErrorResponse
        '422':
          description: Unprocessable Entity - Validation failed
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/cortex__models__response__commons__ActualErrorResponse
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/cortex__models__response__commons__ActualErrorResponse
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/cortex__models__response__commons__ActualErrorResponse
      security:
        - HTTPBearer: []
components:
  schemas:
    SourceDeleteRequest:
      properties:
        tenant_id:
          type: string
          title: Tenant Id
          example: tenant_1234
        sub_tenant_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Sub Tenant Id
          example: sub_tenant_4567
        ids:
          items:
            type: string
          type: array
          minItems: 1
          title: Ids
          description: List of source IDs to delete.
          example:
            - HydraDoc1234
            - HydraDoc4567
      type: object
      required:
        - tenant_id
        - ids
      title: SourceDeleteRequest
      description: Request to delete sources by their IDs.
    SourceDeleteResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
          example: true
        message:
          type: string
          title: Message
          default: Delete completed
        results:
          items:
            $ref: '#/components/schemas/SourceDeleteResultItem'
          type: array
          title: Results
          example: []
        deleted_count:
          type: integer
          title: Deleted Count
          description: Number of sources deleted.
          default: 0
          example: 1
      type: object
      title: SourceDeleteResponse
      description: Response for delete request.
    cortex__models__response__commons__ActualErrorResponse:
      properties:
        detail:
          $ref: >-
            #/components/schemas/cortex__models__response__commons__ErrorResponse
      type: object
      required:
        - detail
      title: ActualErrorResponse
    SourceDeleteResultItem:
      properties:
        id:
          type: string
          title: Id
          description: ID of the source.
          example: HydraDoc1234
        deleted:
          type: boolean
          title: Deleted
          description: Whether deletion succeeded.
          default: false
          example: true
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Error message if deletion failed.
      type: object
      required:
        - id
      title: SourceDeleteResultItem
      description: Result for a single source deletion.
    cortex__models__response__commons__ErrorResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: false
          example: true
        message:
          type: string
          title: Message
          default: Error occurred
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
      type: object
      title: ErrorResponse
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````