# Functions

> One HTTP endpoint or webhook, alone or next to another app.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://run.docs.sypnia.com/apps/functions/

For agents: Functions in Run: single HTTP handler (standard Request/Response via @sypnia/run/function handler), standalone or under a path in another app; env vars in process.env, SYPNIA_DEPLOY_ID/SYPNIA_APP/SYPNIA_ENV; TS/JS bundled, Python/Go/Rust via container image or prebuilt zip; memory 128 MB–10 GB (default 512), timeout 1–900 s (default 10), concurrency cap.

A function is a single handler that answers HTTP requests. It can be an app on its own (a webhook receiver, a small API) or live inside another app's deploy, under a path.

```ts
// functions/pay.ts — receives the payment provider's webhook
import { handler } from '@sypnia/run/function';

export default handler(async (req) => {
  const event = await req.json();
  // verify the signature, record the payment…
  return Response.json({ ok: true });
});
```

`sypnia.toml`

```toml
[run.apps.laespiga.functions.pay]
file = "functions/pay.ts"
path = "/api/pay"
memory = 512
timeout = 10
```

## What a function receives

A standard `Request` and returns a standard `Response`, the same objects as `fetch`. Environment variables and secrets are in `process.env`. The deploy id is in `SYPNIA_DEPLOY_ID`, and `SYPNIA_APP`/`SYPNIA_ENV` name the app and environment.

## Languages

TypeScript and JavaScript are bundled by Run. Python, Go and Rust functions are supported through a `Dockerfile` (a Lambda container image) or a prebuilt zip with `runtime` set in the config.

## Settings

| Field         | Default          | Range                           |
| ------------- | ---------------- | ------------------------------- |
| `memory`      | 512 MB           | 128 MB to 10 GB                 |
| `timeout`     | 10 s             | 1 s to 900 s                    |
| `concurrency` | none             | a cap on simultaneous instances |
| `regions`     | the app's region | one region (us-east-1)          |
