Create an API key
// Requires Node.js SDK v8.2.0 or later
import { AdminClient } from '@pinecone-database/pinecone';
// Reads PINECONE_CLIENT_ID and PINECONE_CLIENT_SECRET from the environment
const admin = new AdminClient();
const apiKey = await admin.apiKeys.create('YOUR_PROJECT_ID', {
name: 'Example API Key',
roles: ['ProjectEditor'],
});
// `apiKey.value` is returned only at creation time and cannot be retrieved
// later. Store it securely and never log it.
console.log(apiKey.key);// Requires Go SDK v6.0.0 or later
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/pinecone-io/go-pinecone/v6/pinecone"
)
func main() {
ctx := context.Background()
adminClient, err := pinecone.NewAdminClientWithContext(ctx, pinecone.NewAdminClientParams{
ClientId: os.Getenv("PINECONE_CLIENT_ID"),
ClientSecret: os.Getenv("PINECONE_CLIENT_SECRET"),
})
if err != nil {
log.Fatalf("Failed to create AdminClient: %v", err)
}
roles := []string{"ProjectEditor"}
apiKey, err := adminClient.APIKey.Create(ctx, "YOUR_PROJECT_ID", &pinecone.CreateAPIKeyParams{
Name: "Example API Key",
Roles: &roles,
})
if err != nil {
log.Fatalf("Failed to create API key: %v", err)
}
// Value is returned only at creation time — store it securely and never log it
fmt.Printf("Successfully created API key: %v\n", apiKey.Key.Id)
}# Requires Terraform provider v4.0.0 or later
resource "pinecone_api_key" "example" {
name = "Example API Key"
project_id = "YOUR_PROJECT_ID"
roles = ["ProjectEditor"]
}PINECONE_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
PINECONE_PROJECT_ID="YOUR_PROJECT_ID"
curl "https://api.pinecone.io/admin/projects/$PINECONE_PROJECT_ID/api-keys" \
-H "X-Pinecone-Api-Version: 2026-04" \
-H "Authorization: Bearer $PINECONE_ACCESS_TOKEN" \
-d '{
"name": "Example API Key",
"roles": ["ProjectEditor"]
}'{
"key": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Example API key",
"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"roles": [
"ProjectEditor"
]
},
"value": "string"
}POST
/admin/projects/{project_id}/api-keysCreate an API key
2 parameters
- X-Pinecone-Api-Versionstringheaderrequired
Required date-based version header
- project_idstringpathrequired
Project ID