{
  "slug": "wrangler-k2-producer-bindings-write-to-existing-streams-fe443330e667",
  "title": "wrangler K2 producer bindings write to existing streams",
  "tools": [
    "wrangler"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-09-30T14:36:05.000Z",
  "announced_at": "2026-09-30T14:36:05.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When producing events from a Worker to an existing K2 stream, add its ID and a binding name under `k2` in Wrangler config, then call `env.<BINDING>.send(records)` and check `result.success`.",
    "examples": [
      "{\n  \"k2\": [\n    {\n      \"binding\": \"<BINDING>\",\n      \"stream\": \"<32-character-lowercase-hex-stream-id>\"\n    }\n  ]\n}",
      "const result = await env.<BINDING>.send([\n  {\n    content: new TextEncoder().encode(\"<EVENT_PAYLOAD>\"),\n    headers: { event: \"<EVENT_NAME>\" }\n  }\n]);\nif (!result.success) {\n  console.error(`Produce failed: ${result.error.message}`);\n}",
      "npx wrangler types"
    ],
    "gotchas": [
      "Version: 4.145.0",
      "Availability: Beta",
      "k2[].binding (required): Worker variable name for the binding, such as `env.ORDERS`.",
      "k2[].stream (required): 32 lowercase hexadecimal stream ID; stream must be in the same account as the Worker.",
      "send(records)[].content (required): Record payload as `ArrayBuffer` or `Uint8Array`; all records in a batch must use the same type.",
      "send(records)[].headers: Metadata map with string keys and string values.",
      "Prerequisite: K2 is available on the Workers Paid plan; it is in public beta.",
      "Prerequisite: The K2 Workers binding input must be enabled on the stream; it is enabled by default when omitted at stream creation.",
      "Prerequisite: Run `npx wrangler types` after adding the binding to generate the Env type.",
      "K2 requires an enabled account.",
      "Deployment credentials need Worker deployment and K2 configuration-read access.",
      "Existing OAuth users should run `wrangler login` again to grant the new permissions.",
      "Development always uses a real K2 stream and may incur usage charges; no local simulator is provided.",
      "Batches use either all `ArrayBuffer` or all `Uint8Array` content.",
      "Check the returned `success` value, handle rejected RPC promises, and retry only when the returned error explicitly allows it.",
      "`remote: false` is rejected.",
      "Consumption is not part of this Worker binding."
    ]
  },
  "why_it_matters": "Configure a Worker to produce events to an existing K2 stream during development or deployment.",
  "sources": [
    "https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.145.0",
    "https://developers.cloudflare.com/k2/features/produce/",
    "https://developers.cloudflare.com/k2/",
    "https://developers.cloudflare.com/k2/configuration/"
  ],
  "rank": 0.92026,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v1+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "gap-20261007",
    "verdict_id": "gap-20261007:gap-20261007-d1d092289be53894-2:gate",
    "evidence_hash": "c35c2be49303b49b11772089482a3e67943136eb8187ee21fd9ed85016fcd6ac"
  },
  "review": {
    "draft_hash": "c69917965afaf2add92c38ec8ae3365b0639f6e583048eab9382729e79ba6ecc",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "gap-20261007:gate",
    "reason": "2 of 3 judge runs approved with p_yes >= 0.9 (mean 0.92 >= 0.9; 2 needed) and Jev gave 0.69 (>= 0.6 needed)."
  }
}
