Skip to main content
Pinecone Docs

Search documentation

Type to search this documentation.

On this pageOverview

Create a collection

Serverless indexes do not support collections.

Python
# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="API_KEY")
pc.create_collection("example-collection", "docs-example")
JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'

const pc = new Pinecone({
  apiKey: 'YOUR_API_KEY'
});

await pc.createCollection({
  name: "example-collection",
  source: "docs-example",
});
Java
import io.pinecone.clients.Pinecone;

public class CreateCollectionExample {
    public static void main(String[] args) {
        Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();

        pc.createCollection("example-collection", "docs-example");
    }
}
curl
PINECONE_API_KEY="YOUR_API_KEY"

curl -s "https://api.pinecone.io/collections" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "X-Pinecone-Api-Version: 2024-04" \
  -d '{
        "name": "example-collection",
        "source": "docs-example"
  }'

POST /collections

  • name (body, string, required) — The name of the collection to be created. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
  • source (body, string, required) — The name of the index to be used as the source for the collection.
  • 201 — The collection has been successfully created.
  • 400
  • 401
  • 403
  • 409 — Collection of given name already exists.
  • 422
  • 500
Suggest an edit

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

Export
Documentation menu