Perma admin X-Metabase-Session

Hello this curl is working great:

curl -H “X-Metabase-Session: YOUR_SESSION_HERE” https://metabase.svc.bird.co/api/dataset/csv -d query=’{“database”: 2, “native”: {“query”: “select count(*) from foo”}, “type”: “native”}’

And I’m using my user’s X-Metabase-Session on my local dev machine. But in production I’d like to use a session token not associated with me. Is there a way for the admin to create a perma token I can use?

Hi @andrewarrow
Yes, you should be able to do it with X-Metabase-ApiKey - but I haven’t tested it, so please comment if it works:
https://github.com/metabase/metabase/blob/6f271dbe7ec7598b6878dcdede88ffdfc68dcaac/docs/operations-guide/environment-variables.md#mb_api_key

EDIT: For reference: https://github.com/metabase/metabase/issues/13026

Thanks! Will do. I’m not an admin on my company’s metabase system but I assume there is way to generate this system wide api-key thru the admin section?

And then once the admin does that, I simply replace X-Metabase-Session with X-Metabase-ApiKey and use the value he provides me?

@andrewarrow No, it’s an environment variable that is defined before Metabase starts.

I see, so if we are starting metabase now with just ./metabase we should change that to MB_API_KEY=foo123 ./metabase where foo123 is whatever token we want.

Then requests sending X-Metabase-ApiKey with foo123 will work?

@andrewarrow That sounds correct. Again I haven’t tested.