# Functions Functions are serverless Python and Node handlers with fast cold starts and scale-to-zero. You paste a handler and get a public URL - no repo, no Dockerfile, no server to manage. They're ideal for webhooks, small APIs, scheduled tasks, and MCP endpoints. ## Creating a function 1. Go to **Functions -> New Function**. 2. Pick a runtime (Python 3.10-3.13 or Node 18-24). 3. Paste your handler code, and dependencies if you need any. 4. Deploy. You get a URL like `fn-{name}.orkestr.run`. ```python # Python - return JSON def handler(event): name = event.get("query", {}).get("name", "world") return {"hello": name} ``` ```javascript // Node.js - echo the request back exports.handler = async (event) => { return { method: event.method, path: event.path, query: event.query }; }; ``` ## The event object Your handler receives an `event` describing the incoming request - method, path, query parameters, headers, and body. Return a value and orkestr serializes it as the response. Functions are plain request/response, so they fit anything that speaks HTTP. ## Dependencies Declare dependencies alongside the handler (for example a requirements-style list for Python or packages for Node). They are installed when the function is built, so imports are available at runtime. ```bash httpx==0.27.0 pydantic==2.9.0 ``` ## Function vs project A function is a single handler with no repo or Dockerfile that scales to zero between requests and is sized by your plan. A [project](https://orkestr.eu/docs/features/projects) is a full application built from a repo and kept running. Reach for a function when you just need an endpoint; reach for a project when you have an app. For running a command inside an existing app, use a [job](https://orkestr.eu/docs/features/jobs). ## Cold starts and scale-to-zero Functions scale to zero when idle and cold-start on the next request. Higher plans allocate more CPU and memory, so cold starts are faster. Because you only run during invocations, an idle function costs nothing in resources. ## Authentication Functions are public by default. Switch a function to `api_key` mode and orkestr issues a key callers must send in the `X-Orkestr-API-Key` header. You can rotate the key at any time; the old key stops working immediately. ## Testing and metrics - Use the built-in test console on the function page to send a request and see the status, body, headers, and duration. - View request metrics per function over a selectable time window. - Fetch recent logs from the function page. ## Resources and limits - CPU and memory are plan-driven (faster cold starts on higher tiers), not user-configurable. - Starter: 1 function. Pro: 10. Enterprise: custom. - Idle functions scale to zero and cold-start on the next request. > **Schedule a function** > > Use a [Cron](https://orkestr.eu/docs/features/crons) to call a function on a recurring schedule - nightly reports, cache warmers, polling integrations. ## FAQ ### Can a function reach a database? Yes, over the network with credentials you provide as configuration. For work that needs your app's exact environment and code, a job is usually the better fit. ### What languages are supported? Python 3.10-3.13 and Node 18-24. ### Can I use a function as an MCP endpoint? Yes - functions are a common way to host small MCP servers and webhooks with a stable URL. ### How do I secure a function? Switch it to api_key mode and send the issued key in the X-Orkestr-API-Key header; rotate the key whenever you need.