# Deleting Vectors

You can easily delete vectors from our vector database, ensuring your data remains organized and up-to-date.

Our SDK allows you to delete vector data from indexes and/or namespaces.

## Delete

Every vector in our database has an ID defined by you. This ID is used to reference the vectors you want to delete.

We'll use the `delete()` method to instruct the SDK to delete vectors 1, 2, and 3, as shown below:

<CodeGroup>
```php simple
use Upstash\Vector\Index;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->delete(['1', '2', '3']);
```

```php using namespaces
use Upstash\Vector\Index;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->namespace('my-namespace')->delete(['1', '2', '3']);
```
</CodeGroup>

### Delete using ID prefixes

In the case that you logically group your vectors by a common prefix, you can delete all those vectors at once using the code below:

<CodeGroup>
```php simple
use Upstash\Vector\Index;
use Upstash\Vector\VectorDeleteByPrefix;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->delete(new VectorDeleteByPrefix(
  prefix: 'users:',
));
```

```php using namespaces
use Upstash\Vector\Index;
use Upstash\Vector\VectorDeleteByPrefix;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->namespace('my-namespace')->delete(new VectorDeleteByPrefix(
  prefix: 'users:',
));
```
</CodeGroup>

### Delete using a metadata filter

If you want to delete vectors based on some query result over the metadata, you can use the `VectorDeleteByMetadataFilter` class as shown below:


<CodeGroup>
```php simple
use Upstash\Vector\Index;
use Upstash\Vector\VectorDeleteByMetadataFilter;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->delete(new VectorDeleteByMetadataFilter(
  filter: 'salary > 1000',
));
```

```php using namespaces
use Upstash\Vector\Index;
use Upstash\Vector\VectorDeleteByMetadataFilter;

$index = new Index(
  url: "<UPSTASH_VECTOR_REST_URL>",
  token: "<UPSTASH_VECTOR_REST_TOKEN>",
);

$index->namespace('my-namespace')->delete(new VectorDeleteByMetadataFilter(
  filter: 'salary > 1000',
));
```
</CodeGroup>

You can read more about [Namespaces](/vector/features/namespaces) on our docs.
