Skip to content

Workers API

This guide details the Pipelines API within Cloudflare Workers.

Send data to a Pipeline from a Worker

Pipelines exposes an API directly to your Workers scripts via the bindings concept. Bindings allow you to securely send data to a Pipeline without having to manage API keys or clients.

You can bind to a Pipeline by defining a [[pipelines]] binding within your Wrangler configuration. For example:

#:schema node_modules/wrangler/config-schema.json
name = "pipeline-starter"
main = "src/index.ts"
compatibility_date = "2025-04-01"
[[pipelines]]
pipeline = "<MY-PIPELINE-NAME>" # The name of your Pipeline
binding = "MY_PIPELINE" # The binding name, accessed using env.MY_PIPELINE

Pipeline

A binding which allows a Worker to send messages to a Pipeline.

interface Pipeline<PipelineRecord> {
send(records: PipelineRecord[]): Promise<void>;
}
  • send(records): Promise<void>

    • Sends a message to the Pipeline. The body must be an array of objects supported by the structured clone algorithm.
    • When the promise resolves, the message is confirmed to be stored by the Pipeline.