Skip to content

Environment variables and cron jobs

Give your project's code its settings and secrets, and run paths on a schedule.

On this page

Environment variables

Environment variables reach the code your project runs: builds and functions. A change takes effect from the next version: Perafly hands them to the hosting provider right before each deployment. The live version keeps the values it was built with.

Terminal
printf %s "$DATABASE_URL" | perafly env set DATABASE_URL   # from stdin
perafly env set FEATURE_FLAG --plain                       # asks without echo; --plain keeps it visible
perafly env ls
perafly env rm FEATURE_FLAG                                # asks to confirm

The CLI reads values from stdin or a hidden prompt, never from arguments, and never prints them. Leading and trailing spaces are kept; from a pipe only the final newline is dropped.

RuleValue
Name^[A-Z_][A-Z0-9_]{0,255}$
ReservedNames starting with PERAFLY_, VERCEL_, NOW_ or AWS_, and CRON_SECRET (env_reserved).
SizeAt most 100 variables; names and values together at most 64 KB (env_too_large).
SensitiveOn by default: after saving, the value never appears in any response or screen again. Turn it off (--plain) for values the team may see.
Writing environment variables needs a person's sign-in: agent credentials can read the list but not change it. Changing a live variable is a decision for a person.

System variables

Perafly sets these for every project with an account. They show up in the list and can't be changed.

VariableHolds
PERAFLY_PROJECT_IDThe project's id (prj_…).
PERAFLY_API_URLThe API address.
PERAFLY_PUBLISHABLE_KEYThe data API's publishable key (visible).
PERAFLY_SECRET_KEYThe data API's secret key, once created (hidden).
PERAFLY_WEBHOOK_SECRETThe change hook secret, once a hook exists (hidden).
CRON_SECRETSent with cron job requests (hidden).

Cron jobs

List the paths to call and when in perafly.jsonc. The live version's list is the project's schedule; the project's Settings page shows it. At most 40 jobs; path starts with / and schedule is a five-field cron expression.

perafly.jsonc
{
  "crons": [
    { "path": "/api/daily-report", "schedule": "0 6 * * *" }
  ]
}

Each call carries Authorization: Bearer <CRON_SECRET>. Check it so nobody else can trigger the path:

api/daily-report.js
export function GET(request) {
  if (request.headers.get("authorization") !== `Bearer ${process.env.CRON_SECRET}`) {
    return new Response("Unauthorized", { status: 401 });
  }
  // … the job
  return Response.json({ ok: true });
}
Cron jobs call your code, so they need a project that runs functions, published with an account.