Cloudflare Workers

A small public front door for bot systems.

Workers are useful when code should run because an HTTP request or scheduled trigger arrived. They are particularly good for webhook receivers, validation, routing and lightweight APIs.

Illustration of a bot handling code, API and connection problems
Illustration: Workers are often the small HTTP-facing piece that validates and routes requests.

What a Worker is

A Worker is serverless code deployed to Cloudflare. You do not keep a terminal window open. Cloudflare invokes the code when a matching event occurs. That makes it different from a Python loop running continuously on a VPS.

Practical example

Webhook receiver example

A TradingView alert sends JSON to a Worker. The Worker checks a shared secret, validates the fields, rejects duplicates and forwards only clean data. The trading process itself can stay on a VPS.

Good uses

Webhook receiver

Accept an incoming POST, authenticate it, parse JSON and reject invalid data.

API gateway

Put a narrow public interface in front of a private backend and normalize requests.

Small scheduled job

Run periodic work when a persistent server would be unnecessary.

What not to assume

A Worker is not simply “a VPS without a screen.” Long-running desktop applications, arbitrary local executables and continuously open Python processes belong elsewhere. If your bot needs persistent local processes or platform-specific software, use a VPS or the platform runtime and let the Worker handle the public edge.

Typical secure flow

POST /api/webhook
  → check method
  → authenticate sender
  → parse JSON
  → validate schema
  → reject stale/duplicate event
  → call trusted backend
  → return clear status code
  → log result without secrets
Do not put secrets in frontend code. Worker Secrets are for values that the Worker needs but visitors must not be able to read.

Useful next guides

Common questions

Does a Cloudflare Worker run all the time?

Not like a normal process on a PC or VPS. Worker code is invoked by requests, scheduled triggers and supported platform events.

Can a Worker receive TradingView webhooks?

Yes. It can expose an HTTPS endpoint, validate the request and forward a normalized event to another service.

Can I store secrets in Worker code?

Do not hard-code them in source. Use Worker Secrets or another appropriate secret-storage mechanism.