# Delete objects

Weaviate allows object deletion by id or by a set of criteria.

::::accordion{title="Additional information"}
- To delete objects, you must provide the collection name as well as identifying criteria (e.g. object id or filters).
- For [multi-tenancy](../concepts/data.md#multi-tenancy) collections, you will also need to specify the tenant name when deleting objects. See [Manage data: multi-tenancy operations](../how-to-manage-collections/multi-tenancy.md) for details on how.

:::callout{intent="warning" title="Collection (class) Name in Object CRUD Operations"}
Collections act like namespaces, so two different collections could have duplicate IDs between them.

Prior to Weaviate `v1.14` you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate `v2.0.0`.

Starting in `v1.20`, you can have [multi-tenant](../concepts/data.md#multi-tenancy) datasets. When `multi-tenancy` is enabled, the tenant name is required.

Always include the collection name, and, when enabled, the tenant name.
:::
::::

## Delete object by id

To delete by id, specify the collection name and the object id.

:::code-group{sync="languages"}
```python title="Python"
uuid_to_delete = "..."  # replace with the id of the object you want to delete
```

```typescript title="JavaScript/TypeScript"
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')
```

```go title="Go"
idToDelete := "..." // replace with the id of the object you want to delete
```

```java title="Java"
collection.data.deleteById(uuidToDelete);
```

```csharp title="C#"
await collection.Data.DeleteByID(uuidToDelete);
```
:::

<!-- ## Error handling

If the id doesn't exist in the specified class, a 404 error will be returned.

You can handle errors as follows:

<Tabs className="code" groupId="languages">
  <TabItem value="py" label="Python">
    <FilteredTextBlock
      text=
      startMarker="# START DeleteError"
      endMarker="# END DeleteError"
      language="py"
    />
  </TabItem>

</Tabs> -->

## Delete multiple objects

To delete objects that match a set of criteria, specify the collection and a [`where` filter](../how-to-query-search/similarity.md).

:::code-group{sync="languages"}
```python title="Python" {5}
from weaviate.classes.query import Filter

collection = client.collections.use("EphemeralObject")
collection.data.delete_many(
    where=Filter.by_property("name").like("EphemeralObject*")
)
```

```typescript title="JavaScript/TypeScript"
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')
```

```go title="Go" {4-7}
response, err := client.Batch().ObjectsBatchDeleter().
  WithClassName("EphemeralObject").
  WithOutput("minimal").
  WithWhere(filters.Where().
    WithPath([]string{"name"}).
    WithOperator(filters.Like).
    WithValueText("EphemeralObject*")).
  Do(ctx)
if err != nil {
  // handle error
  panic(err)
}

fmt.Printf("%+v\n", *response)
```

```java title="Java" {2}
collection.data.deleteMany(
    Filter.property("name").like("EphemeralObject*")
);
```

```csharp title="C#" {2}
await collection.Data.DeleteMany(
    Filter.Property("name").IsLike("EphemeralObject*")
);
```
:::

:::accordion{title="Additional information"}
- There is a configurable [maximum limit (QUERY\_MAXIMUM\_RESULTS)](../database-configuration/overview.md#general) on the number of objects that can be deleted in a single query (default 10,000). To delete more objects than the limit, re-run the query.
:::

### ContainsAny / ContainsAll / ContainsNone

Use `ContainsAny` / `ContainsAll` / `ContainsNone` filters to delete of objects by a set of criteria.

:::code-group{sync="languages"}
```python title="Python" {5}
from weaviate.classes.query import Filter

collection = client.collections.use("EphemeralObject")
collection.data.delete_many(
    where=Filter.by_property("name").contains_any(["europe", "asia"])
)
```

```typescript title="JavaScript/TypeScript"
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')
```

```go title="Go" {6-7}
  response, err := client.Batch().ObjectsBatchDeleter().
    WithClassName("EphemeralObject").
    WithOutput("minimal").
    WithWhere(filters.Where().
      WithPath([]string{"name"}).
      WithOperator(filters.ContainsAny).
      WithValueText("asia", "europe")).  // Note the array syntax
    Do(ctx)
```

```java title="Java" {7}
CollectionHandle<Map<String, Object>> collection =
    client.collections.use(COLLECTION_NAME);
collection.data.insertMany(Map.of("name", "asia"),
    Map.of("name", "europe"));

collection.data.deleteMany(
    Filter.property("name").containsAny("europe", "asia")
);
```

```csharp title="C#" {5}
var collection = client.Collections.Use(COLLECTION_NAME);
await collection.Data.InsertMany(new[] { new { name = "asia" }, new { name = "europe" } });

await collection.Data.DeleteMany(
    Filter.Property("name").ContainsAny(["europe", "asia"])
);
```
:::

## Delete multiple objects by id

To delete multiple objects by their id values, use a filter (e.g. `ContainsAny`) with `id` based criteria.

:::accordion{title="Limitations"}
There is an upper limit (`QUERY_MAXIMUM_RESULTS`) to how many objects can be deleted using a single query. This protects against unexpected memory surges and very-long-running requests which would be prone to client-side timeouts or network interruptions.

Objects are deleted in the same order that they would be fetched, by order of UUID. To delete more objects than the limit, run the same query multiple times until no objects are matched anymore.

The default `QUERY_MAXIMUM_RESULTS` value is 10,000. This may be configurable, e.g. in [the environment variables](../database-configuration/overview.md).
:::

:::code-group{sync="languages"}
```python title="Python" {9}
from weaviate.classes.query import Filter

collection = client.collections.use("EphemeralObject")

response = collection.query.fetch_objects(limit=3)  # Fetch 3 object IDs
ids = [o.uuid for o in response.objects]  # These can be lists of strings, or `UUID` objects

collection.data.delete_many(
    where=Filter.by_id().contains_any(ids)  # Delete the 3 objects
)
```

```typescript title="JavaScript/TypeScript"
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')
```

```go title="Go" {6-7}
  response, err := client.Batch().ObjectsBatchDeleter().
    WithClassName("EphemeralObject").
    WithOutput("minimal").
    WithWhere(filters.Where().
      WithPath([]string{"id"}).
      WithOperator(filters.ContainsAny).
      WithValueText("12c88739-7a4e-49fd-bf53-d6a829ba0261", "3022b8be-a6dd-4ef4-b213-821f65cee53b", "30de68c1-dd53-4bed-86ea-915f34faea63")).  // Note the array syntax
    Do(ctx)
```

```java title="Java" {9}
QueryResponse<Map<String, Object>> queryResponse =
    collection.query.fetchObjects(q -> q.limit(3));
List<String> ids = queryResponse.objects()
    .stream()
    .map(WeaviateObject::uuid)
    .collect(Collectors.toList());

collection.data.deleteMany(
    Filter.uuid().containsAny(ids.toArray(new String[0])) // Delete the 3 objects
);
```

```csharp title="C#" {5}
var queryResponse = await collection.Query.FetchObjects(limit: 3);
var ids = queryResponse.Objects.Select(obj => obj.UUID.Value).ToList();

await collection.Data.DeleteMany(
    Filter.UUID.ContainsAny(ids) // Delete the 3 objects
);
```
:::

## Delete all objects

Objects must belong to a collection in Weaviate. Accordingly [deleting collections](../how-to-manage-collections/collection-operations.md#delete-a-collection) will remove all objects within them.

## Delete objects with Time-To-Live (TTL)

You can configure automatic deletion of objects after a specified time period using Time-To-Live (TTL) settings at the collection level. Read how to [set it up](../how-to-manage-collections/time-to-live.md) or learn more [about it](../concepts/data.md#time-to-live-ttl).

## Optional parameters

- You can use `dryRun` to check how many objects would be deleted, without actually performing the deletion.
- Set `output` to `'verbose'` to see more details (ID and deletion status) for each deletion.

:::code-group{sync="languages"}
```python title="Python" {6-7}
from weaviate.classes.query import Filter

collection = client.collections.use("EphemeralObject")
result = collection.data.delete_many(
    where=Filter.by_property("name").like("EphemeralObject*"),
    dry_run=True,
    verbose=True
)

print(result)
```

```typescript title="JavaScript/TypeScript"
await client.collections.delete('EphemeralObject')
await client.collections.create({ name: 'EphemeralObject'})
const myCollection = client.collections.use('EphemeralObject')
```

```go title="Go" {8-9}
response, err := client.Batch().ObjectsBatchDeleter().
  WithClassName("EphemeralObject").
  // Same `where` filter as in the GraphQL API
  WithWhere(filters.Where().
    WithPath([]string{"name"}).
    WithOperator(filters.Like).
    WithValueText("EphemeralObject*")).
  WithDryRun(true).
  WithOutput("verbose").
  Do(ctx)
if err != nil {
  // handle error
  panic(err)
}

fmt.Printf("%+v\n", *response)
```

```java title="Java" {3}
var result = collection.data.deleteMany(
    Filter.property("name").like("EphemeralObject*"),
    c -> c.dryRun(true).verbose(true)
);

System.out.println(result);
```

```csharp title="C#" {3}
var result = await collection.Data.DeleteMany(
    Filter.Property("name").IsLike("EphemeralObject*"),
    dryRun: true
);

Console.WriteLine(JsonSerializer.Serialize(result));
```
:::

:::accordion{title="Example response"}
It should produce a response like the one below:

```json
{
  "dryRun": true,
  "match": {
    "class": "EphemeralObject",
    "where": {
      "operands": null,
      "operator": "Like",
      "path": [
        "name"
      ],
      "valueText": "EphemeralObject*"
    }
  },
  "output": "verbose",
  "results": {
    "failed": 0,
    "limit": 10000,
    "matches": 5,
    "objects": [
      {
        "id": "208cf21f-f824-40f1-95cb-f923bc840ca6",
        "status": "DRYRUN"
      },
      {
        "id": "8b2dddd4-2dc7-422c-885d-f9d5ff4e80c8",
        "status": "DRYRUN"
      },
      {
        "id": "49b3b2b4-3a77-48cd-8e39-27e83c811fcc",
        "status": "DRYRUN"
      },
      {
        "id": "847b31d0-dab4-4c1c-8cd3-af07c9d3dc2c",
        "status": "DRYRUN"
      },
      {
        "id": "147d9cea-5f9c-40c1-884a-f99bc8e9bf06",
        "status": "DRYRUN"
      }
    ],
    "successful": 0
  }
}
```
:::

## Related pages

- [Connect to Weaviate](../connect-to-weaviate/index.md)
- [References: REST - /v1/objects](/weaviate/api/rest#tag/objects)

## Questions and feedback

Have a question or feedback? Here's how to reach us.

::::card-grid
:::card{title="Community Forum" href="https://forum.weaviate.io/c/support" icon="messages-square"}
Ask questions and connect with other developers on our **Community forum**.
:::

:::card{title="Support" href="/guides/support-overview" icon="life-buoy"}
Weaviate Cloud user or customer? Find the right channel on the **Support page**.
:::
::::

## Related pages

- [Agents](./agents-index.md)
- [AI-assisted Weaviate code generation](./ai-assisted-vibe-coding-index.md)
- [APIs](./apis-index.md)
- [Authorization and authentication](./authorization-and-authentication-index.md)
- [Benchmarks](./benchmarks-index.md)
- [Best practices](./best-practices-index.md)
- [Client libraries](./clients-index.md)
- [Client Libraries / SDKs](./client-libraries-index.md)
- [Cloud](./cloud-index.md)
- [Cloud account management](./cloud-account-management-index.md)

# Agent Instructions

This portal answers questions programmatically. To receive a synthesized,
source-cited answer instead of crawling page by page, append the `?ask=`
query parameter to any page URL on this site:

    /guides/quickstart?ask=how+do+I+authenticate

Optional parameters:

- `&goal=<what-you-are-trying-to-do>` steers the answer toward your
  objective (e.g. `&goal=write+a+python+client`).
- `&version=<label>` scopes the answer to a mounted version when the
  portal publishes more than one.

The response is `text/markdown`: the answer followed by a `# Sources` list
of the portal pages it was grounded in. Status codes are the contract:

- `200` — the answer; `402` — the portal owner’s plan or answer credits are
  exhausted (surface this to your operator; do NOT retry); `429` — you are
  rate-limited; back off for the `Retry-After` seconds; `503` — the answer
  lane is temporarily unavailable; fall back to crawling the `.md` pages.

For the full corpus map read `llms.txt` at the site root; for the tool
surface (search + page fetch as MCP tools) see `/mcp`.
