---
title: Workers API · Cloudflare Pipelines Docs
description: 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.
lastUpdated: 2025-04-09T16:06:19.000Z
source_url:
  html: https://ranbel-terraform-default-profile.preview.developers.cloudflare.com/pipelines/build-with-pipelines/sources/workers-apis/index.md
  md: https://ranbel-terraform-default-profile.preview.developers.cloudflare.com/pipelines/build-with-pipelines/sources/workers-apis/
---

Pipelines exposes an API directly to your [Workers](https://developers.cloudflare.com/workers) scripts via the [bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/#what-is-a-binding) 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:

* wrangler.jsonc

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

* wrangler.toml

  ```toml
  #: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 = "PIPELINE" # The binding name, accessed using env.MY_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:

```ts
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.

```ts
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.

Note

When running your Worker locally, pipelines are partially simulated. Worker code which sends data to a pipeline will execute successfully. However, the full pipeline, including batching & writing to R2, will not be executed locally.
