Skip to main content
Pinecone Docs

Search documentation

Type to search this documentation.

Create an API key

JavaScript
// 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);
Go
// 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)
}
Terraform
# Requires Terraform provider v4.0.0 or later
resource "pinecone_api_key" "example" {
  name       = "Example API Key"
  project_id = "YOUR_PROJECT_ID"
  roles      = ["ProjectEditor"]
}
curl
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"]
	}'
curl
{
  "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-keys

Create an API key

2 parameters
  • X-Pinecone-Api-Versionstringheaderrequired

    Required date-based version header

  • project_idstringpathrequired

    Project ID

Suggest an edit

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

Export
Documentation menu