Functions
Code that runs where your numbers live
Functions run your TypeScript or JavaScript on the Polymorfa server that holds your numbers and hosted messages. No round trip to a server of yours, and message data stays where it is.
- Run time by default, up to 30 s
- 10 s
- Memory for every run
- 256 MB
- Invocations a month on a Pro number
- 1,000,000
- Request or response bodies kept
- 0
Beside your numbers
No round trip to your server
A Flow step forwarded to your server crosses the internet and waits for the answer. A function answers from the server that already holds the number and its hosted messages.
WhatsApp Flows
Flow endpoints, keys included
WhatsApp encrypts every Flow data exchange. Polymorfa holds the number's key, decrypts each request and never stores what it contains.
- Run a function with the request JSON
- Or forward it to your HTTPS URL, signed
- Or bring your own key, and Polymorfa never decrypts
Isolation
A fresh sandbox for every run
Each invocation starts a new sandbox with no network of its own. Outbound requests pass through a broker that allows only the HTTPS origins you list.
Deploy
Deploy, test, then promote
Deployments are immutable and pin their secret versions. Test one, then promote it; calls pinned to an older deployment keep running it.
In your code
A Flow step in twenty lines
Write the handler, deploy it with its secrets and allowed origins, then promote it. The SDK and CLI cover the same operations as the Console.
import { defineFunction } from "@polymorfa/functions";
export default defineFunction({
async handler(request, event, ctx) {
if (ctx.trigger.kind !== "flow") {
return new Response("Not found", { status: 404 });
}
// The Flow data exchange, already decrypted.
const { data } = await request.json();
const res = await fetch(`https://api.acme.com/tables?date=${data.date}`, {
headers: { authorization: `Bearer ${ctx.env.ACME_API_KEY}` },
signal: ctx.signal,
});
const { times } = await res.json();
return Response.json({ screen: "PICK_TIME", data: { times } });
},
});Plans and limits
Invocations included with every number
Allowances reset monthly. Beyond them, invocations cost 100 credits per million.
| Number | Invocations a month |
|---|---|
| Free | 1,000 |
| Standard | 250,000 |
| Pro | 1,000,000 |
| Limit | Value |
|---|---|
| Run time | 10 s by default, 30 s at most |
| Response size | 1 MiB |
| Memory | 256 MB |
| Outbound requests | 10 per run |
| Source | 256 KiB |
| Allowed origins | 32 per deployment |
API surface
The Functions API
Manage Functions, deployments, secrets and invocations through the Platform API. Flow endpoints and keys live beside them.
Functions
- POST
/Create a Functionplatform/ functions - POST
/Build an immutable deploymentplatform/ functions/ {functionId}/ deployments - PUT
/Promote a deploymentplatform/ functions/ {functionId}/ promotion - POST
/Add a secret versionplatform/ functions/ {functionId}/ secrets - POST
/Run it with an idempotency keyplatform/ functions/ {functionId}/ invocations - GET
/Read receiptsplatform/ functions/ {functionId}/ invocations
WhatsApp Flows
- PUT
/Run a function, forward or go directplatform/ flows/ {flowId}/ endpoint - GET
/Data endpoint receiptsplatform/ flows/ {flowId}/ endpoint/ receipts - GET
/A number's Flow key custodyplatform/ flow-encryption-keys - POST
/Rotate the managed keyplatform/ flow-encryption-keys/ rotate
Start with a free number
Your first real number is free. Add more numbers on Pay-As-You-Go.