Deploy and run
Functions
Deploy one file of Node or Python code as an HTTPS endpoint that sleeps when idle. No repo, no Dockerfile.
A function is one file of code that becomes a web address: good for webhook receivers, small APIs, or hiding a secret key from the browser. It sleeps after five quiet minutes and wakes on the next request, so one nobody calls costs nothing.
How to do it: in a project, press Add and choose Function, pick Node or Python, paste your code and save. You can edit the code in the dashboard later.
"Make a function that receives Stripe webhooks and logs them."
A function is one file of code that CLI turns into an HTTPS endpoint. It suits webhook receivers, small APIs, proxies that keep a key away from the browser, and targets for cron or keepers. It sleeps after five quiet minutes and wakes on the next request, so a function nobody calls costs nothing.
Node
Export a handler that takes a Request and returns a Response. That's the same shape as Cloudflare Workers, Vercel and Deno, so most examples paste straight in.
export default async (request) => {
const name = new URL(request.url).searchParams.get("name") ?? "world";
return Response.json({ hello: name });
};Returning a string or a plain object also works: strings are sent as text, objects as JSON. Variables are in process.env.
Python
Define handler(request). request has method, path, query, headers, body (bytes), text() and json().
def handler(request):
if request.method == "POST":
event = request.json()
return {"received": event.get("type")}
return "ok"Return a string, a dict or list (sent as JSON), or a tuple: (body, status) or (body, status, headers). async def works too.
Create one
In a project, New function. Or:
POST /v1/projects/:id/functions
{"name": "stripe-webhook", "runtime": "node", "code": "export default async (r) => …", "dependencies": ["stripe@17"]}dependencies are npm packages (name@version) or pip requirements (requests==2.32.3), installed at build time. Leave them out and nothing needs installing, so builds take seconds.
A function is an ordinary service underneath: 0.25 vCPU and 256 MB to start, with variables, domains, logs, metrics and edge rules like any app. Set sleepAfterMinutes to change when it sleeps, or null to keep it always on (no wake-up delay).
Change the code
Edit it on the service's settings under Function code and choose Deploy, or:
PUT /v1/services/:id/function {"code": "…"}
GET /v1/services/:id/functionA file over 256 KB, or one that doesn't define a handler, is refused with an example before anything builds. For more than one file, deploy it as an app (cli up or a repo). Agents use cli_function.