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.
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" } ]}
#:schema node_modules/wrangler/config-schema.jsonname = "pipeline-starter"main = "src/index.ts"compatibility_date = "2025-04-01"
[[pipelines]]pipeline = "<MY-PIPELINE-NAME>" # The name of your Pipelinebinding = "PIPELINE" # The binding name, accessed using env.MY_PIPELINE
You can bind multiple pipelines to a Worker.
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>;
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.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark