PayWeavePayWeaveBack to Home
Functions

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.

If you already have a running API, consider Gateways (zero code changes) or Apps (SDK middleware) instead.

Functions vs Apps vs Gateways

FunctionsAppsGateways
InfrastructureFully managedYou manageYou manage upstream
CodeWrite in dashboard editorAdd middleware to your serverNo code changes
PricingPer-handler in dashboardPer-route in codePer-endpoint in dashboard
Best forNew APIs from scratchExisting server appsWrapping existing APIs

Creating a Function

From the dashboard, navigate to Functions → Create Function. You will configure:

FieldRequiredDescription
NameYesA human-readable label for the function
DescriptionNoWhat 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:

Plain Text
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.

Functions are deployed instantly when you save. There is no build step or cold start - your handler is available at its URL within seconds.

Limits

LimitValue
Execution timeout30 seconds
Response size10 MB
Request body5 MB
Minimum price$0.0001 per request