Skip to main content
Pinecone Docs
current

Search documentation

Type to search this documentation.

Update an API key

Update an API key's name and roles.

PATCH/admin/api-keys/{api_key_id}

Update an API key

2 parameters
  • X-Pinecone-Api-Versionstringheaderrequired

    Required date-based version header

  • api_key_idstringpathrequired

    API key ID

cURL
curl --request PATCH \
  --url https://api.pinecone.io/admin/api-keys/{api_key_id} \
  --header 'Authorization: Bearer <token>' \
  --header 'X-Pinecone-Api-Version: <x-pinecone-api-version>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "devkey",
  "roles": [
    "ProjectEditor"
  ]
}'
Python
import requests

url = "https://api.pinecone.io/admin/api-keys/{api_key_id}"

payload = {
  "name": "devkey",
  "roles": [
    "ProjectEditor"
  ]
}
headers = {
    "Authorization": "Bearer <token>",
    "X-Pinecone-Api-Version": "<x-pinecone-api-version>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
JavaScript
const options = {method: "PATCH", headers: {"Authorization": "Bearer <token>", "X-Pinecone-Api-Version": "<x-pinecone-api-version>", "Content-Type": "application/json"}, body: JSON.stringify({
  "name": "devkey",
  "roles": [
    "ProjectEditor"
  ]
})};

fetch("https://api.pinecone.io/admin/api-keys/{api_key_id}", options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.pinecone.io/admin/api-keys/{api_key_id}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS => "{\"name\":\"devkey\",\"roles\":[\"ProjectEditor\"]}",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "X-Pinecone-Api-Version: <x-pinecone-api-version>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
Go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.pinecone.io/admin/api-keys/{api_key_id}"

	payload := strings.NewReader("{\"name\":\"devkey\",\"roles\":[\"ProjectEditor\"]}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("X-Pinecone-Api-Version", "<x-pinecone-api-version>")
	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))

}
Java
HttpResponse<String> response = Unirest.patch("https://api.pinecone.io/admin/api-keys/{api_key_id}")
  .header("Authorization", "Bearer <token>")
  .header("X-Pinecone-Api-Version", "<x-pinecone-api-version>")
  .header("Content-Type", "application/json")
  .body("{\"name\":\"devkey\",\"roles\":[\"ProjectEditor\"]}")
  .asString();
Ruby
require 'uri'
require 'net/http'

url = URI("https://api.pinecone.io/admin/api-keys/{api_key_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["X-Pinecone-Api-Version"] = '<x-pinecone-api-version>'
request["Content-Type"] = 'application/json'
request.body = "{\"name\":\"devkey\",\"roles\":[\"ProjectEditor\"]}"

response = http.request(request)
puts response.read_body
200
{
  "id": "<string>",
  "name": "<string>",
  "project_id": "<string>",
  "roles": [
    "ProjectEditor"
  ]
}
400
{
  "error": {
    "code": "INVALID_ARGUMENT",
    "message": "Bad request. The request body included invalid request parameters."
  },
  "status": 400
}
401
{
  "error": {
    "code": "UNAUTHENTICATED",
    "message": "Invalid API key."
  },
  "status": 401
}
403
{
  "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
}
500
{
  "error": {
    "code": "UNKNOWN",
    "message": "Internal server error"
  },
  "status": 500
}
4XX
{
  "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
}
Authorizationstringrequired

An access token must be provided in the Authorization header using the Bearer scheme.

X-Pinecone-Api-Versionstringrequired

Required date-based version header

Typestring
Default2026-07
api_key_idstringrequired

API key ID

Typestring

Updated name and roles for the API key.

name?string

A new name for the API key. The name must be 1-80 characters long. If omitted, the name will not be updated.

Required string length: 1 - 80. Example: devkey

Typestring
roles?string[]

A new set of roles for the API key. Existing roles will be removed if not included. If this field is omitted, the roles will not be updated.

Typestring[]

200 — API key updated successfully.

The details of an API key, without the secret.

idstringrequired

The unique ID of the API key.

Typestring
namestringrequired

The name of the API key.

Typestring
project_idstringrequired

The ID of the project containing the API key.

Typestring
rolesstring[]required

The roles assigned to the API key.

Typestring[]
Suggest an edit

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

Export
Documentation menu