---
title: "Delete Document Command"
description: "Delete documents from RavenDB using the low-level DeleteDocumentCommand with optional change vector concurrency checks."
url: "https://docs.ravendb.net/7.2/client-api/commands/documents/delete"
version: "7.2"
language: "csharp"
---

# Delete Document Command

> Client language: C#. Also available for [Java](https://docs.ravendb.net/7.2/client-api/commands/documents/delete.java.md), [Python](https://docs.ravendb.net/7.2/client-api/commands/documents/delete.python.md), [PHP](https://docs.ravendb.net/7.2/client-api/commands/documents/delete.php.md), [Node.js](https://docs.ravendb.net/7.2/client-api/commands/documents/delete.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - Use the low-level `DeleteDocumentCommand` to remove a document from the database.
>
> - To delete a document using a higher-level method, see [deleting entities](https://docs.ravendb.net/7.2/client-api/session/deleting-entities.md).
>
> - In this page:
>
>   - [Examples](#examples)
>   - [Syntax](#syntax)

## Examples

> **Note**
>
> **Delete document command - using the Store's request executor**:
>
> ### Delete\_document
>
> ```csharp
> using (var store = new DocumentStore())
> using (store.GetRequestExecutor().ContextPool.AllocateOperationContext(out var context))
> {
>   var command = new DeleteDocumentCommand("employees/1-A", null);
>   store.GetRequestExecutor().Execute(command, context);
> }
> ```
>
> ### Delete\_document\_async
>
> ```csharp
> using (var store = new DocumentStore())
> using (store.GetRequestExecutor().ContextPool.AllocateOperationContext(out var context))
> {
>   var command = new DeleteDocumentCommand("employees/1-A", null);
>   await store.GetRequestExecutor().ExecuteAsync(command, context);
> }
> ```

> **Note**
>
> **Delete document command - using the Session's request executor**:
>
> ### Delete\_document
>
> ```csharp
> var command = new DeleteDocumentCommand("employees/1-A", null);
> session.Advanced.RequestExecutor.Execute(command, session.Advanced.Context);
> ```
>
> ### Delete\_document\_async
>
> ```csharp
> var command = new DeleteDocumentCommand("employees/1-A", null);
> await asyncSession.Advanced.RequestExecutor.ExecuteAsync(command, asyncSession.Advanced.Context);
> ```

> **Note**
>
> **Delete document command - with concurrency check**:
>
> ### Delete\_document
>
> ```csharp
> // Load a document
> var employeeDocument = session.Load<Employee>("employees/2-A");
> var cv = session.Advanced.GetChangeVectorFor(employeeDocument);
>
> // Modify the document content and save changes
> // The change-vector of the stored document will change
> employeeDocument.Title = "Some new title";
> session.SaveChanges();
>
> try
> {
>   // Try to delete the document with the previous change-vector
>   var command = new DeleteDocumentCommand("employees/2-A", cv);
>   session.Advanced.RequestExecutor.Execute(command, session.Advanced.Context);
> }
> catch (Exception e)
> {
>   // A concurrency exception is thrown
>   // since the change-vector of the document in the database
>   // does not match the change-vector specified in the delete command
>   Assert.IsType<Raven.Client.Exceptions.ConcurrencyException>(e);
> }
> ```
>
> ### Delete\_document\_async
>
> ```csharp
> // Load a document
> var employeeDocument = await asyncSession.LoadAsync<Employee>("employees/2-A");
> var cv = asyncSession.Advanced.GetChangeVectorFor(employeeDocument);
>
> // Modify the document content and save changes
> // The change-vector of the stored document will change
> employeeDocument.Title = "Some new title";
> asyncSession.SaveChangesAsync();
>
> try
> {
>   // Try to delete the document with the previous change-vector
>   var command = new DeleteDocumentCommand("employees/2-A", cv);
>   await asyncSession.Advanced.RequestExecutor.ExecuteAsync(command, asyncSession.Advanced.Context);
> }
> catch (Exception e)
> {
>   // A concurrency exception is thrown
>   // since the change-vector of the document in the database
>   // does not match the change-vector specified in the delete command
>   Assert.IsType<Raven.Client.Exceptions.ConcurrencyException>(e);
> }
> ```

## Syntax

```csharp
public DeleteDocumentCommand(string id, string changeVector)
```

| Parameter | Type | Description |
| - | - | - |
| **id** | `string` | The ID of the document to delete. |
| **changeVector** | `string` | The change-vector of the document you wish to delete,<br />used for [optimistic concurrency control](https://docs.ravendb.net/7.2/server/clustering/replication/change-vector.md#concurrency-control--change-vectors).<br />Pass `null` to skip the check and force the deletion. |

## See also

- [Get document](https://docs.ravendb.net/7.2/client-api/commands/documents/get.md)
- [Put document](https://docs.ravendb.net/7.2/client-api/commands/documents/put.md)
- [Send multiple commands using a batch](https://docs.ravendb.net/7.2/client-api/commands/batches/how-to-send-multiple-commands-using-a-batch.md)
