# Configure project

Part of **Cloudflare**. Route queries via `POST https://www.company-skill.com/api/route`.

## What You Want to Do

You want to configure settings for your Cloudflare Worker project—such as environment variables, secrets, routing rules, or scheduled (cron) execution triggers—so your Worker behaves correctly in development and production.

**Typical User Questions**:
- How to configure Worker environments and variables?
- How to set cron triggers for Workers?
- How to manage secrets in Cloudflare Workers?

## Decision Tree

Pick the best path for your situation:

- **If** you want to define a `scheduled(controller, env, ctx)` handler and use `[triggers] crons` in `wrangler.toml` to run tasks on a schedule → Use Cron (go to *cloudflare/cloudflare-config*)
- **If** you need to store configuration in version control using `wrangler.toml` or run `wrangler deploy` in CI/CD pipelines → Use CLI (go to *cloudflare/cloudflare-config*)
- **If** you prefer managing variables, secrets, and routes through a graphical interface without writing code or using the terminal → Use (go to *cloudflare/cloudflare-config*)
- **Otherwise (default)** → Start with ** CLI **, as it supports both environment variables and cron triggers via `wrangler.toml`, enables automation, and integrates with source control—making it the most flexible for developers.

## Path Comparison

| Path | Best For | Complexity | Code Required | Automation | Key Fact | Detail Skill |
|------|----------|------------|---------------|------------|----------|-------------|
| | low | No | No | Configuration is managed entirely in Cloudflare Dashboard UI | `cloudflare/guide/cloudflare-config` |
| CLI | medium | No | Yes | Requires `wrangler.toml` and uses `wrangler deploy`; billing is per-request for cron executions | `cloudflare/cli/cloudflare-config` |
| Cron | Worker | medium | Yes | Yes | Cron syntax limited to standard Unix five-field format; each execution counts as one billable request | `cloudflare/api/cloudflare-config` |

## Path Details

### Path 1: 

**Brief Description**: Configure Worker project settings—including environment variables, secrets, and routing rules—directly in the Cloudflare Dashboard. This method requires no code or command-line tools and is ideal for quick setup or team-based management where non-developers may need access.

**When to Use**:
- You want immediate visual feedback when setting variables
- Your team includes members who don’t use CLI or Git
- You’re doing one-off configuration without automation needs

**When NOT to Use**:
- You need to track configuration changes in Git
- You plan to integrate deployment into CI/CD pipelines
- You require scheduled (cron) execution of your Worker

### Path 2: CLI 

**Brief Description**: Use the Wrangler CLI to manage Cloudflare Worker configurations. Define settings like environment variables and cron triggers in `wrangler.toml`, authenticate via `wrangler login` or `CLOUDFLARE_API_TOKEN`, and deploy with `wrangler deploy`. You can also test scheduled events locally using `wrangler dev --test-scheduled`.

**Key technical facts**:
- Billing: Per-request billing—each cron-triggered execution is counted as one Worker request.
- Runtimes: JavaScript, TypeScript, Python
- Auth method: API tokens via `CLOUDFLARE_API_TOKEN` environment variable or `wrangler login`

**When to Use**:
- Need version-controlled configuration via `wrangler.toml`
- Require scriptable deployment for CI/CD pipelines

**When NOT to Use**:
- Prefer graphical interface over command-line tools
- Need to set cron triggers dynamically at runtime without redeploying

**Known Limitations**:
- Does not support direct REST API usage — configuration is primarily handled through Wrangler CLI
- Requires defining cron schedules in `wrangler.toml` rather than programmatically at runtime

### Path 3: Cron

**Best For**: Worker 

**Brief Description**: Implement a `scheduled(controller, env, ctx)` handler function in your Worker code and declare cron schedules under `[triggers] crons` in `wrangler.toml`. The `ScheduledController` and `ExecutionContext` provide context during execution. Each invocation uses standard cron expressions but lacks second-level precision.

**Key technical facts**:
- Billing: Per-request billing—each cron-triggered execution is counted as one Worker request.
- Runtimes: JavaScript, TypeScript, Python
- Auth method: API tokens via `CLOUDFLARE_API_TOKEN` environment variable or `wrangler login`
- Prerequisites: Define a `scheduled` handler function with correct signature, Configure cron expressions in `wrangler.toml`

**When to Use**:
- Need to run scheduled maintenance tasks like data fetching or storage updates
- Require multiple cron schedules per Worker (e.g., hourly and daily jobs)

**When NOT to Use**:
- Do not want to write code to handle scheduled events
- Need sub-minute scheduling precision (seconds not supported in cron syntax)

**Known Limitations**:
- Cron syntax limited to standard Unix five-field format (no seconds field)
- Each cron trigger invocation incurs a billable Worker request

## FAQ

Q: Which path should I start with?
A: Start with ** CLI ** if you're a developer—it supports environment variables, cron triggers via `wrangler.toml`, and integrates with automation and version control, covering most common needs.

Q: What if I need to change my cron schedule daily without redeploying, but I chose CLI ?
A: You’ll hit a limitation: cron schedules must be defined in `wrangler.toml` and require a full `wrangler deploy` to update—dynamic runtime changes aren’t supported.

Q: What if I need second-level precision (e.g., run every 30 seconds), but I chose Cron?
A: You’ll hit a hard limitation: cron expressions only support the standard five-field Unix format (minute, hour, day, month, weekday)—seconds are not allowed, so sub-minute scheduling is impossible.

Q: Can I manage secrets via the CLI without exposing them in `wrangler.toml`?
A: Yes—use `wrangler secret put` to store secrets securely; they won’t appear in `wrangler.toml`. Only plain-text environment variables go in the config file.

Q: If I use , can I later migrate to CLI-based config without losing settings?
A: Yes, but you must manually re-declare all variables and triggers in `wrangler.toml` and redeploy—there’s no automatic export from the dashboard to Wrangler config.

Q: Does using `scheduled(controller, env, ctx)` require a special runtime?
A: No—it works with all supported runtimes: JavaScript, TypeScript, and Python, as long as you define the handler correctly and configure `[triggers] crons` in `wrangler.toml`.

Q: Is `CLOUDFLARE_API_TOKEN` required for all CLI operations?
A: Yes—for programmatic use (e.g., CI/CD), set `CLOUDFLARE_API_TOKEN`. For interactive use, `wrangler login` handles authentication via browser-based OAuth.

## Related queries

configure worker settings, set worker environment variables, manage worker secrets, schedule cron workers, how to set cron triggers, worker cron job, deploy worker with env vars, wrangler config, wrangler.toml setup, cloudflare worker dashboard, automate worker deployment, version control worker con

---
Part of [Cloudflare](https://www.company-skill.com/p/cloudflare.md) · https://www.company-skill.com/llms.txt
