CControxity Docs
GuidesReferenceHTTP APIOpen Controxity
Platforms

Edge and Workers

Cloudflare Workers, workerd, Deno, Bun or any language: three HTTP calls, no SDK needed.

When to use this#

The Node SDK uses Node's own modules (files, the process), so it doesn't run on Cloudflare Workers or other edge runtimes. Any runtime with fetch can call Controxity's API directly. It's what the SDKs do underneath.

Every call carries the place's server key: Authorization: Bearer dep_….

1. Send errors#

await fetch(`${env.CONTROXITY_URL}/api/v1/signals`, {
  method: "POST",
  headers: { authorization: `Bearer ${env.CONTROXITY_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({
    version: env.BUILD_COMMIT,                       // "3f9c2a1", or "1.4.2"
    signals: [{
      type: "error",
      exception: error.name,                         // never error.message
      frames: ["src/index.ts:42:7:handleRequest"],   // file:line:column:function, innermost last
      where: "api.orders",
      code: "http-503",
      count: 1,
    }],
  }),
});

Add errors up for a minute and send them together: up to 200 signals and 256 KB per call.

An error can also carry, if you have them:

{
  "input": {"body": {"items": "undefined", "coupon": "string"}},
  "trail": [{"step": "route:POST /api/orders", "ago": 1450}, {"step": "http:POST stripe.com 402 1204ms", "ago": 40}],
  "expect": "total-not-negative"
}

input is the shape of what failed: key names and type words only. trail is the steps before it, oldest first, each a code and how many ms before. expect names an expectation that didn't hold (with "exception": "ExpectationFailed"). Anything that isn't one of these shapes is dropped. The full list: HTTP API.

2. Say it's alive#

await fetch(`${env.CONTROXITY_URL}/api/v1/heartbeat`, {
  method: "POST",
  headers: { authorization: `Bearer ${env.CONTROXITY_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({ version: env.BUILD_COMMIT, every: 60 }),
});

Once a minute, from a cron trigger or a Durable Object alarm. No heartbeat for 3 minutes, and the place shows Down.

3. Report health#

{ "signals": [{ "type": "health", "code": "arena_eu", "ok": false, "severity": "high", "reason": "timeout" }] }

Each code shows on Today's Health panel; ok: true clears it. See Health checks.

Bundled code#

A Worker runs a bundle, so its frames point at the bundle (index.js:1:2604). Send the bundle's source map when you deploy, and Controxity translates each frame back to your files: see Send source maps.

Everything the API takes: HTTP API v1.

Controxity 1.132.0These pages are in the repository: docs/site