Create an API key
curl --request POST \
--url https://api.pinecone.io/admin/projects/{project_id}/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Pinecone-Api-Version: <x-pinecone-api-version>' \
--data '
{
"name": "devkey",
"roles": [
"ProjectEditor"
]
}
'import requests
url = "https://api.pinecone.io/admin/projects/{project_id}/api-keys"
payload = {
"name": "devkey",
"roles": ["ProjectEditor"]
}
headers = {
"X-Pinecone-Api-Version": "<x-pinecone-api-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Pinecone-Api-Version': '<x-pinecone-api-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: 'devkey', roles: ['ProjectEditor']})
};
fetch('https://api.pinecone.io/admin/projects/{project_id}/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pinecone.io/admin/projects/{project_id}/api-keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'devkey',
'roles' => [
'ProjectEditor'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Pinecone-Api-Version: <x-pinecone-api-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pinecone.io/admin/projects/{project_id}/api-keys"
payload := strings.NewReader("{\n \"name\": \"devkey\",\n \"roles\": [\n \"ProjectEditor\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Pinecone-Api-Version", "<x-pinecone-api-version>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pinecone.io/admin/projects/{project_id}/api-keys")
.header("X-Pinecone-Api-Version", "<x-pinecone-api-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"devkey\",\n \"roles\": [\n \"ProjectEditor\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pinecone.io/admin/projects/{project_id}/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Pinecone-Api-Version"] = '<x-pinecone-api-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"devkey\",\n \"roles\": [\n \"ProjectEditor\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"key": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"roles": [
"ProjectEditor"
]
},
"value": "<string>"
}{
"error": {
"code": "INVALID_ARGUMENT",
"message": "Bad request. The request body included invalid request parameters."
},
"status": 400
}{
"error": {
"code": "UNAUTHENTICATED",
"message": "Invalid API key."
},
"status": 401
}{
"error": {
"code": "QUOTA_EXCEEDED",
"message": "The index exceeds the project quota of 5 pods by 2 pods. Upgrade your account or change the project settings to increase the quota."
},
"status": 429
}{
"error": {
"code": "UNKNOWN",
"message": "Internal server error"
},
"status": 500
}{
"error": {
"code": "QUOTA_EXCEEDED",
"message": "The index exceeds the project quota of 5 pods by 2 pods. Upgrade your account or change the project settings to increase the quota."
},
"status": 429
}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
Create an API key
curl --request POST \
--url https://api.pinecone.io/admin/projects/{project_id}/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Pinecone-Api-Version: <x-pinecone-api-version>' \
--data '
{
"name": "devkey",
"roles": [
"ProjectEditor"
]
}
'import requests
url = "https://api.pinecone.io/admin/projects/{project_id}/api-keys"
payload = {
"name": "devkey",
"roles": ["ProjectEditor"]
}
headers = {
"X-Pinecone-Api-Version": "<x-pinecone-api-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Pinecone-Api-Version': '<x-pinecone-api-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: 'devkey', roles: ['ProjectEditor']})
};
fetch('https://api.pinecone.io/admin/projects/{project_id}/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pinecone.io/admin/projects/{project_id}/api-keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'devkey',
'roles' => [
'ProjectEditor'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Pinecone-Api-Version: <x-pinecone-api-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pinecone.io/admin/projects/{project_id}/api-keys"
payload := strings.NewReader("{\n \"name\": \"devkey\",\n \"roles\": [\n \"ProjectEditor\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Pinecone-Api-Version", "<x-pinecone-api-version>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pinecone.io/admin/projects/{project_id}/api-keys")
.header("X-Pinecone-Api-Version", "<x-pinecone-api-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"devkey\",\n \"roles\": [\n \"ProjectEditor\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pinecone.io/admin/projects/{project_id}/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Pinecone-Api-Version"] = '<x-pinecone-api-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"devkey\",\n \"roles\": [\n \"ProjectEditor\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"key": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"roles": [
"ProjectEditor"
]
},
"value": "<string>"
}{
"error": {
"code": "INVALID_ARGUMENT",
"message": "Bad request. The request body included invalid request parameters."
},
"status": 400
}{
"error": {
"code": "UNAUTHENTICATED",
"message": "Invalid API key."
},
"status": 401
}{
"error": {
"code": "QUOTA_EXCEEDED",
"message": "The index exceeds the project quota of 5 pods by 2 pods. Upgrade your account or change the project settings to increase the quota."
},
"status": 429
}{
"error": {
"code": "UNKNOWN",
"message": "Internal server error"
},
"status": 500
}{
"error": {
"code": "QUOTA_EXCEEDED",
"message": "The index exceeds the project quota of 5 pods by 2 pods. Upgrade your account or change the project settings to increase the quota."
},
"status": 429
}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?