Skip to content
Cloudflare Docs

Workers API

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. Sending data via a Worker is enabled by default.

Send data from a Worker

Setup a binding

Bind to a pipeline by defining a pipelines binding within your Wrangler configuration. For example:

{
"name": "pipeline-starter",
"main": "src/index.ts",
"compatibility_date": "2025-04-01",
"pipelines": [
{
"pipeline": "<MY-PIPELINE-NAME>",
"binding": "PIPELINE"
}
]
}

You can bind multiple pipelines to a Worker.

Send data

The Pipelines binding exposes a send() method. For example, to log inbound HTTP requests to your Worker:

export default {
async fetch(request, env, ctx): Promise<Response> {
let log = {
url: request.url,
method: request.method,
headers: Object.fromEntries(request.headers),
};
await env.PIPELINE.send([log]);
return new Response('Hello World!');
},
} satisfies ExportedHandler<Env>;

Workers API

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 records to the pipeline. The body must be an array of objects which are JSON serializable.
    • When the promise resolves, the records are confirmed to be ingested.