Skip to content

Function Types

Every function has a type that determines when and how it runs. Palpaca supports two function types: Trigger and Scheduled.

A trigger function runs whenever it receives an incoming HTTP request. This makes it ideal for:

  • Webhooks — receive events from HubSpot, Stripe, Slack, or any service that sends webhooks
  • API endpoints — expose a custom API that other systems can call
  • Form handlers — process form submissions from external websites

Trigger functions use standard HTTP request methods:

export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const url = new URL(request.url)
// Handle the request
return new Response("OK")
}
}

You can route by HTTP method (GET, POST, etc.) and URL path inside the handler.

A scheduled function runs automatically at intervals you define using a cron expression. Use these for:

  • Data syncs — periodically pull data from external systems into HubSpot
  • Reports — generate and send reports on a schedule
  • Cleanup tasks — archive old records, update stale properties
  • Monitoring — check external services and alert when something is wrong

Scheduled functions use the scheduled handler:

export default {
async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext): Promise<void> {
console.log("Running scheduled task:", controller.cron)
// Do work here
}
}
PatternRuns
* * * * *Every minute
*/15 * * * *Every 15 minutes
0 * * * *Every hour
0 */6 * * *Every 6 hours
0 9 * * 1-5Weekdays at 9:00 AM UTC
0 0 * * *Daily at midnight UTC
0 0 1 * *First day of each month

You set the cron expression when creating the function. The schedule is configured during deployment.

If your function needs to respond to external events in real time, choose Trigger. If it needs to run on its own at regular intervals, choose Scheduled. Each function can only have one type — it cannot be both.