# Cloudflare Workers Serverless JavaScript/TypeScript on Cloudflare's global edge. POST code directly — instant deploy, no git needed. Supports cron triggers. ## Prerequisites Provision this resource before use. Edge requests without provisioning will error. ### Provision curl -s -X POST https://cohesivity.ai/api/resources/cloudflare-workers \ -H "Authorization: Bearer " ### Delete curl -s -X DELETE https://cohesivity.ai/api/resources/cloudflare-workers \ -H "Authorization: Bearer " **Important:** Provision this resource now, before building or running the application. Provisioning is the agent's job, not the application's. ## Worker Management All endpoints require `Authorization: Bearer ` header. - **List workers:** `GET https://cohesivity.ai/api/workers` - **Create worker:** `POST https://cohesivity.ai/api/workers` with `{ "name": "my-worker" }` - **Worker status:** `GET https://cohesivity.ai/api/workers/:name` - **Deploy code:** `PUT https://cohesivity.ai/api/workers/:name` with `{ "code": "...", "cron": "*/5 * * * *" }` - **Delete worker:** `DELETE https://cohesivity.ai/api/workers/:name` ## Examples **Create:** curl -s -X POST https://cohesivity.ai/api/workers \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{"name":"my-worker"}' **Deploy:** curl -s -X PUT https://cohesivity.ai/api/workers/my-worker \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{"code":"export default { async fetch(request) { return new Response(\\"Hello!\\"); } };"}' ## Writing Worker Code Use ES module syntax (Cloudflare Workers V8 runtime): ``` export default { async fetch(request) { return new Response("Hello from my worker!"); }, async scheduled(event, env, ctx) { // Handle cron triggers }, }; ``` Worker names: 2-50 chars, lowercase alphanumeric + hyphens, must start/end with alphanumeric. ## Limits (Cloudflare free tier) - 100,000 requests/day - 10ms CPU time per invocation - 128 MB memory