Skip to main content
Pinecone Docs

Search documentation

Type to search this documentation.

On this pageOverview

Delete documents

Delete documents from a namespace. Exactly one of ids, filter, or delete_all must be specified.

  • ids: Delete documents with the given IDs.
  • filter: Delete every document matching a metadata filter expression. Text-match operators ($match_phrase, $match_all, $match_any) are not supported in a filtered delete; they are only supported in search. The response reports matched_records, the number of documents the filter matched.
  • delete_all: Delete all documents in the namespace.
Python
# pip install --upgrade pinecone
import os
from pinecone import Pinecone

pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
index = pc.Index(name="articles")

NAMESPACE = "example-namespace"

# Delete by IDs
index.documents.delete(namespace=NAMESPACE, ids=["doc1", "doc2"])

# Delete by metadata filter
index.documents.delete(namespace=NAMESPACE, filter={"category": {"$eq": "news"}})

# Delete every document in the namespace
index.documents.delete(namespace=NAMESPACE, delete_all=True)
curl
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="articles-abc123.svc.us-east-1.pinecone.io"

# EXAMPLE REQUEST 1: Delete by IDs
curl "https://$INDEX_HOST/namespaces/__default__/documents/delete" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2026-07" \
  -d '{ "ids": ["doc1", "doc2"] }'

# EXAMPLE REQUEST 2: Delete by metadata filter
curl "https://$INDEX_HOST/namespaces/__default__/documents/delete" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2026-07" \
  -d '{ "filter": { "category": { "$eq": "news" } } }'

# EXAMPLE REQUEST 3: Delete all documents in a namespace
curl "https://$INDEX_HOST/namespaces/__default__/documents/delete" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2026-07" \
  -d '{ "delete_all": true }'

POST /namespaces/{namespace}/documents/delete

  • X-Pinecone-Api-Version (header, string, required) — Required date-based version header
  • namespace (path, string, required) — The namespace to delete documents from.
  • ids (body, string[]) — A list of document IDs to delete. Mutually exclusive with filter and delete_all.
  • filter (body, object) — A metadata filter expression selecting the documents to delete. Must not be empty; an empty filter is rejected rather than matching every document. To delete every document in the namespace, set delete_all. Text-match operators ($match_phrase, $match_all, $match_any) are not supported here, since documents are selected on metadata alone. Mutually exclusive with ids and delete_all.
  • delete_all (body, boolean) — If true, delete all documents in the namespace. Mutually exclusive with ids and filter. false is treated as if the field were omitted.
  • 202 — The delete request was successfully accepted.
  • 400 — Bad request. The request body included invalid request parameters.
  • 401 — Unauthorized. Possible causes: missing or invalid API key.
  • 4XX — An unexpected error response.
  • 5XX — An unexpected error response.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu