```javascript JavaScript theme={null}
// 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 Go theme={null}
// 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)
}
```

```hcl Terraform theme={null}
# Requires Terraform provider v4.0.0 or later
resource "pinecone_api_key" "example" {
  name       = "Example API Key"
  project_id = "YOUR_PROJECT_ID"
  roles      = ["ProjectEditor"]
}
```

```bash curl theme={null}
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"]
	}'
```

```json curl theme={null}
{
  "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`

:::code-group
```bash title="cURL"
curl --request POST \
  --url https://api.pinecone.io/admin/projects/{project_id}/api-keys \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "devkey",
  "roles": [
    "ProjectEditor"
  ]
}'
```

```json title="201"
{
  "key": {
    "id": "<string>",
    "name": "<string>",
    "project_id": "<string>",
    "roles": [
      "ProjectEditor"
    ]
  },
  "value": "<string>"
}
```
:::

## Authorizations

- `Authorization` (header, string, required) — Bearer authentication header of the form `Bearer <token>`.

## Path Parameters

- `project_id` (path, string, required) — Project ID

## Headers

- `X-Pinecone-Api-Version` (header, string, required) — Required date-based version header

## Body

- `name` (body, string, required) — The name of the API key. The name must be 1-80 characters long.
- `roles` (body, string\[]) — The roles to create the API key with. Default is `["ProjectEditor"]`.

## Response

- `201` — API key created successfully.
- `400` — Bad request. The request body included invalid request parameters.
- `401` — Unauthorized. Possible causes: Invalid API key.
- `403` — Not enough available quota to complete this operation.
- `500` — Internal server error.
- `4XX` — Unexpected error on request.

## Related pages

- [List API keys](./admin-2-2026-07-admin-api-keys-list-api-keys.md)
- [Create an API key](./admin-2-2026-07-admin-api-keys-create-an-api-key.md)
- [Get API key details](./admin-2-2026-07-admin-api-keys-get-api-key-details.md)
- [Delete an API key](./admin-2-2026-07-admin-api-keys-delete-an-api-key.md)
- [Update an API key](./admin-2-2026-07-admin-api-keys-update-an-api-key.md)
- [Create an API key](./admin-2-2026-04-admin-create-api-key.md)
- [List API keys](./admin-2-2026-04-admin-assistant-list-api-keys.md)
- [Get API key details](./admin-2-2026-04-admin-assistant-fetch-api-key.md)
- [Update an API key](./admin-2-2026-04-admin-assistant-update-api-key.md)
- [Delete an API key](./admin-2-2026-04-admin-assistant-delete-api-key.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
