Quickstart
Deploy your first Amba function in under a minute. Amba runtime modules, no wrappers.
A function in 15 lines of code.
1. Write the function
functions/hello.ts:
The default export is the Amba runtime module shape ({ async fetch(req, env, ctx) }). The runtime injects env bindings at deploy time — see Runtime for the full list. There is no @layers/amba-* import; the bundle stays self-contained.
2. Deploy
Output (abridged):
amba functions deploy bundles with esbuild (--bundle --format=esm --platform=browser --target=es2022), checks the size against the 8 MB cap, POSTs to the admin API, and waits for the runtime to acknowledge.
3. Call it
Call it at the URL the deploy printed: the project id is the subdomain and the function name is the first path segment.
Functions require an API key by default; a request without X-Api-Key gets 401. A valid client key with no session token runs the function with an empty X-Amba-User-Id, so this handler answers anonymous. Add the end-user session token (Authorization: Bearer <session token>) and Amba signs that user's id into X-Amba-User-Id. To accept requests with no API key at all (an inbound webhook, for example), deploy with amba functions deploy --public and verify the caller inside the function.
4. Call back into Amba
To read a collection, send a push, grant currency, etc., fetch the project-scoped admin API using env.AMBA_INTERNAL_TOKEN. This token is scoped to this project only — it authenticates /v1/admin/projects/${env.AMBA_PROJECT_ID}/* and nothing else. Global admin operations (creating projects, listing developer-owned projects) require a developer PAT instead. See Token reference for the full breakdown.
Full endpoint catalog: /api-reference/admin.
Next
- Runtime contract — every binding, every header, every error code → fix.
- Local dev — iterate on a function without deploying.
- Deploy — the deploy lifecycle, rollback, scheduled invocations.