#Convex admin keys?

1 messages · Page 1 of 1 (latest)

north elbow
#

I want to set up a bun server that will be processing data and I'd like to be getting direct access to the db, how woudl I get admin keys to pull that off?

blazing dewBOT
#

Hi @north elbow. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

You can’t use an “admin key” to talk directly to the Convex database (SQL, etc.)—admin keys are for controlling a deployment (CLI, dashboard, self‑hosted backend), not for bypassing Convex functions.

From the docs:

  • An admin key provides complete control over a deployment and is used by the CLI / dashboard / self‑hosted tooling, not as a general DB API key.[Deploy keys]
  • For self‑hosted Convex, you generate an admin key with the backend’s generate_admin_key.sh script and then put it in CONVEX_SELF_HOSTED_ADMIN_KEY so npx convex dev / deploy can talk to that backend.[Self-hosted README; Self-hosted workflow]

Example (self‑hosted):

# Docker / local self-hosted backend
docker compose exec backend ./generate_admin_key.sh

# Then in your app’s .env.local
CONVEX_SELF_HOSTED_URL='<http://127.0.0.1:3210'>
CONVEX_SELF_HOSTED_ADMIN_KEY='<your admin key>'

For a Bun server that processes data, the supported pattern is:

  1. Expose the data you need via Convex queries/mutations/actions.
  2. Call those from your Bun server using the Convex client or HTTP actions.
  3. If you need server‑only access, protect those functions with a shared secret (env var in both Convex and Bun) and check it in the Convex function before doing any work.[Service auth thread; Server-only access thread; Non-user auth thread]
#

There’s no documented way in these sources to use an admin key as a general-purpose DB API key from Bun; it’s for deployment/admin control only.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: