> For the complete documentation index, see [llms.txt](https://docs.codemash.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.codemash.io/api/database/collections/delete.md).

# Delete

Use this API method when you want to find one document by a specified filter or id and delete it. If many documents are found, only the first one will be deleted.

{% openapi src="/files/xbBaDgC6opDYR2pG5sLT" path="/{version}/db/{CollectionName}/{Id}" method="delete" expanded="true" %}
[openapi.json](https://760328771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwSkuCpTNI_AerL8J2a%2Fuploads%2FCpzJktmKXD6FMPSah1nK%2Fopenapi.json?alt=media\&token=854cdd6a-61b2-49a5-99f4-6bc091e5c3d6)
{% endopenapi %}

{% tabs %}
{% tab title=".NET" %}

```csharp
var client = new CodeMashClient(apiKey, projectId);
var service = new CodeMashRepository<Person>(client);

await service.DeleteOneAsync(
    x => x.Id == "record_id"
);
```

{% hint style="info" %}
Check the information about [entities](broken://pages/-M-6_vT8PDXfwQxGKlF9) on how your filter parameters are mapped.
{% endhint %}
{% endtab %}

{% tab title="Node" %}

```javascript
import { db } from 'codemash';

export async function deleteEmployee(id) {
    return await db.deleteRecord('employees', { _id: id });
}
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashDb;

class CodemashService
{
    protected CodemashDb $codemashDb;
    protected string $collectionName = '{YOUR_COLLECTION_NAME}';

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $this->codemashDb = new CodemashDb($client);
    }

    public function deleteOne()
    {
        $responseData = $this->codemashDb->deleteOneWithFilter([
        	'collectionName' => 'employees',
        	'filter' => [
        		'email' => 'john@example.com',
        	],
        ]);
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Check the docs on how to form [filters](/other-topics/list-parameters/filter.md).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.codemash.io/api/database/collections/delete.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
