Skip to main content

Overview

InsForge Schedules lets you run serverless functions on a recurring cron schedule. Jobs are managed entirely in PostgreSQL using the pg_cron extension, which executes HTTP requests to your function endpoints at the specified intervals.

Technology Stack

Core Components

ComponentTechnologyPurpose
Schedulerpg_cronPostgreSQL-native cron job scheduling
HTTP Clientpg http extensionExecute HTTP requests from within PostgreSQL
Encryptionpgcrypto (AES)Encrypt sensitive headers at rest
Job StorePostgreSQLJob definitions and execution logs
Service LayerNode.jsCron validation, secret resolution, CRUD

How It Works

When a schedule is created:
  1. The cron expression is validated (5-field format, no seconds)
  2. Secret placeholders (${{secrets.KEY}}) in headers are resolved and encrypted
  3. A pg_cron job is registered that calls execute_job() on the cron schedule
When pg_cron fires:
  1. execute_job() fetches the job definition and decrypts headers
  2. An HTTP request is made to the function endpoint
  3. The result (status code, duration, success/failure) is logged to schedules.job_logs

Execution Flow

Cron Expressions

Standard 5-field format — seconds are not supported.
ExpressionSchedule
*/5 * * * *Every 5 minutes
0 * * * *Every hour
0 0 * * *Daily at midnight
0 9 * * 1Every Monday at 9am
0 0 1 * *First of every month

Secret Management

Headers support ${{secrets.KEY_NAME}} template syntax. Secrets are resolved at creation time, encrypted with pgcrypto, and decrypted only at execution time. Template headers (without secret values) are stored separately for safe display in the dashboard.
If a referenced secret is deleted, scheduled jobs using it will fail. Update or disable affected schedules after removing secrets.

Best Practices

  1. Test First: Invoke your function manually before scheduling it
  2. Use Secrets: Pass API keys via header secrets instead of hardcoding
  3. Stay Fast: Functions should complete within the 30-second timeout
  4. Monitor Logs: Check execution logs for failures and unexpected status codes
  5. Disable, Don’t Delete: Pause schedules temporarily instead of recreating them

Limitations

  • Minimum Interval: 1 minute (pg_cron limitation)
  • No Seconds: 5-field cron expressions only
  • Admin Only: Schedules are managed by project admins
  • No Retry: Failed executions are logged but not automatically retried