E2B icon indicating copy to clipboard operation
E2B copied to clipboard

AuthenticationError: Unauthorized, please check your credentials. - Invalid API key

Open bilalmalkoc opened this issue 3 months ago • 7 comments

I am using the new template system. I already added .env api key but still got the error

AuthenticationError: Unauthorized, please check your credentials. - Invalid API key, please visit https://e2b.dev/docs/api-key for more information. authorization header is missing

bilalmalkoc avatar Oct 21 '25 07:10 bilalmalkoc

ENG-3202

linear[bot] avatar Oct 21 '25 07:10 linear[bot]

Hi @bilalmalkoc, when using the .env file, do you have also the the dotenv installed and imported in the build file?

(https://e2b.dev/docs/template/quickstart#create-a-development-build-script) JS

import "dotenv/config";

Python

from dotenv import load_dotenv

load_dotenv() 

If none of this works, you can also specify the API Key directly: https://e2b.dev/docs/template/build

Template.build(template, {
  ...
  apiKey: 'your-api-key', // Override API key
})

dobrac avatar Oct 21 '25 08:10 dobrac

yes alread installed dotent (node) and imported, still not working.

it is working when i put config directly.

bilalmalkoc avatar Oct 21 '25 09:10 bilalmalkoc

and if you set it in your env?

export E2B_API_KEY=...

mishushakov avatar Oct 21 '25 10:10 mishushakov

make sure also that you load the env variable in your build script, not template file (if you have them separate)

mishushakov avatar Oct 21 '25 10:10 mishushakov

@mishushakov tried both no luck.

bilalmalkoc avatar Oct 21 '25 12:10 bilalmalkoc

can you share the code? how are you running it?

mishushakov avatar Oct 21 '25 13:10 mishushakov