Using REST query - 'API key is missing or invalid for the environment '

I’ve had a hell of a time getting anything to work, and have abandoned using the javascript package in favor of going straight to the REST API but I can’t even get that working. I don’t know if this header is correct and its not clear to me if the example in the docs are actually the correct header properties or not. I am using this: (of course MY KEY is a string). I lifted the url and the key from the Pinecone Console.

async query(queryVector) {
await fetch(‘’, {
method: ‘POST’,
mode: ‘no-cors’,
headers: { ‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘Api-Key’: MY KEY,
body: JSON.stringify({
namespace: ‘dss’,
topK: 3,
includeMetadata: true,
vector: queryVector
}).then(response => { return response.json() })
.then(data => { console.log(data) })

and I get this 401 error:
API key is missing or invalid for the environment “northamerica-northeast1-gcp”. Check that the correct environment is specified.

I am not sure “Api-Key” is the right property, or even other properties are needed in the header, or what it is.
Any help appreciated, thanks.

Hi @drennenbrown,

“Api-Key” is the right field. Are you enclosing your API key in quotes or anything? It could be it’s getting munged somehow.

Why don’t you email me a screenshot showing how you’re constructing this, even with the API key present, but just edit the screenshot to obscure the API key? Email that to me directly at, and I’ll take a look at it.