Functions Overview
Functions let you deploy serverless TypeScript handlers directly on PayWeave without managing infrastructure. Write your code in the built-in editor, set a price, and PayWeave hosts it with a unique URL - complete with MPP payment verification built in.
When to use Functions
Functions are ideal when you want to build and monetize new APIs from scratch without deploying a server. Common use cases:
AI tool endpoints - Wrap an LLM or external API call in a handler and sell it per-request.
Data transformations - Parse, enrich, or convert data on the fly.
Lookup APIs - Query external databases or services and return structured results.
Webhook processors - Receive and process webhook events from third-party services.
Functions vs Apps vs Gateways
| Functions | Apps | Gateways | |
|---|---|---|---|
| Infrastructure | Fully managed | You manage | You manage upstream |
| Code | Write in dashboard editor | Add middleware to your server | No code changes |
| Pricing | Per-handler in dashboard | Per-route in code | Per-endpoint in dashboard |
| Best for | New APIs from scratch | Existing server apps | Wrapping existing APIs |
Creating a Function
From the dashboard, navigate to Functions → Create Function. You will configure:
| Field | Required | Description |
|---|---|---|
| Name | Yes | A human-readable label for the function |
| Description | No | What this function does - shown in Bazaar discovery if published |
The Function acts as a container for one or more handlers. Each handler is a separate endpoint with its own path, price, and code.
How it works
When a caller sends a request to a Function handler:
1. PayWeave checks for a valid payment credential. If missing, it responds with 402 Payment Required with MPP pricing for the handler.
2. The caller submits payment on Tempo and retries with Authorization: Payment <credential>.
3. PayWeave verifies the payment and executes your handler code in an isolated V8 runtime.
4. Your handler's response is returned to the caller with a Payment-Receipt header attached.
Function URLs
Each Function receives a base URL. Handlers within the function are accessible at sub-paths:
Base: https://fn.payweave.com/<function-id>
Handler: https://fn.payweave.com/<function-id>/<handler-path>Runtime environment
Functions run in an isolated V8 runtime with access to the standard fetch API, crypto, TextEncoder/TextDecoder, and other Web Platform APIs. There is no filesystem access - use fetch for external data. Secrets are available via process.env.
Limits
| Limit | Value |
|---|---|
| Execution timeout | 30 seconds |
| Response size | 10 MB |
| Request body | 5 MB |
| Minimum price | $0.0001 per request |
PayWeave