// 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();
// `value` is returned only at creation time and cannot be retrieved later
const apiKey = await admin.apiKeys.create('YOUR_PROJECT_ID', {
name: 'Example API Key',
roles: ['ProjectEditor'],
});
console.log(apiKey);
// 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{})
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 and cannot be retrieved later
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"
}
API keys
Create an API key
Create an API key for a project to authenticate Data Plane and Control Plane requests.
POST
/
admin
/
projects
/
{project_id}
/
api-keys
// 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();
// `value` is returned only at creation time and cannot be retrieved later
const apiKey = await admin.apiKeys.create('YOUR_PROJECT_ID', {
name: 'Example API Key',
roles: ['ProjectEditor'],
});
console.log(apiKey);
// 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{})
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 and cannot be retrieved later
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"
}
// 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();
// `value` is returned only at creation time and cannot be retrieved later
const apiKey = await admin.apiKeys.create('YOUR_PROJECT_ID', {
name: 'Example API Key',
roles: ['ProjectEditor'],
});
console.log(apiKey);
// 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{})
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 and cannot be retrieved later
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"
}
Authorizations
An access token must be provided in the Authorization header using the Bearer scheme.
Headers
Required date-based version header
Path Parameters
Project ID
Body
application/json
The details of the new API key.
The name of the API key. The name must be 1-80 characters long.
Required string length:
1 - 80Example:
"devkey"
The roles to create the API key with. Default is ["ProjectEditor"].
A role that can be assigned to an API key.
Possible values: ProjectEditor, ProjectViewer, ControlPlaneEditor, ControlPlaneViewer, DataPlaneEditor, or DataPlaneViewer.
Response
API key created successfully.
The details of an API key, including the secret. Only returned on API key creation.
Was this page helpful?
⌘I