#Convex admin keys?
1 messages · Page 1 of 1 (latest)
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.shscript and then put it inCONVEX_SELF_HOSTED_ADMIN_KEYsonpx convex dev/deploycan 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:
- Expose the data you need via Convex queries/mutations/actions.
- Call those from your Bun server using the Convex client or HTTP actions.
- 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]