---
title: Sinks
meta:
   description: "Sinks are the destinations for your data. They are the places where you can store your data after it has been transformed."
---

# Sinks

Tinybird Sinks allow you to export data from your Tinybird Workspace to external systems on a scheduled or on-demand basis. Sinks are built on top of [Pipes](/forward/core-concepts/pipes) and provide a fully managed way to push data to various destinations.

## Available Sinks

Tinybird supports the following Sink destinations:

- [Kafka Sink](/forward/copy-export-data/kafka-sink)
- [S3 Sink](/forward/copy-export-data/s3-sink)
- [GCS Sink](/forward/copy-export-data/gcs-sink)

{% callout type="info" %}
Sinks are available on the Developer and Enterprise plans. See [Plans](/forward/pricing).
{% /callout %}

## Create a Sink

Sinks are defined with a connection and a pipe that exports query results to that connection. Use `TYPE SINK` in `.pipe` files, `defineSinkPipe` in the TypeScript SDK, or `define_sink_pipe` in the Python SDK.

The following example creates an S3 Sink that exports processed events to an S3 bucket on a schedule.

{% tabs initial="Tinybird CLI" %}
{% tab label="Tinybird CLI" %}

```tb {% title="connections/landing_s3.connection" %}
TYPE s3
S3_REGION "us-east-1"
S3_ARN {{ tb_secret("AWS_ROLE_ARN") }}
```

```tb {% title="datasources/events.datasource" %}
SCHEMA >
    `timestamp` DateTime,
    `session_id` String,
    `status` String

ENGINE "MergeTree"
ENGINE_SORTING_KEY "timestamp"
```

```tb {% title="pipes/events_export_sink.pipe" %}
NODE export
SQL >
    SELECT timestamp, session_id
    FROM events
    WHERE status = 'processed'

TYPE SINK
EXPORT_CONNECTION_NAME "landing_s3"
EXPORT_BUCKET_URI "s3://my-bucket/exports/"
EXPORT_FILE_TEMPLATE "events_{date}"
EXPORT_FORMAT "csv"
EXPORT_SCHEDULE "0 * * * *"
```

{% /tab %}

{% tab label="TypeScript SDK" %}

```ts {% title="tinybird.ts" %}
import {
  defineDatasource,
  defineS3Connection,
  defineSinkPipe,
  engine,
  node,
  secret,
  t,
} from "@tinybirdco/sdk";

export const landingS3 = defineS3Connection("landing_s3", {
  region: "us-east-1",
  arn: secret("AWS_ROLE_ARN"),
});

export const events = defineDatasource("events", {
  schema: {
    timestamp: t.dateTime(),
    session_id: t.string(),
    status: t.string(),
  },
  engine: engine.mergeTree({
    sortingKey: ["timestamp"],
  }),
});

export const eventsExportSink = defineSinkPipe("events_export_sink", {
  sink: {
    connection: landingS3,
    bucketUri: "s3://my-bucket/exports/",
    fileTemplate: "events_{date}",
    format: "csv",
    schedule: "0 * * * *",
  },
  nodes: [
    node({
      name: "export",
      sql: `
        SELECT timestamp, session_id
        FROM events
        WHERE status = 'processed'
      `,
    }),
  ],
});
```

{% /tab %}

{% tab label="Python SDK" %}

```python {% title="tinybird.py" %}
from tinybird_sdk import (
    define_datasource,
    define_s3_connection,
    define_sink_pipe,
    engine,
    node,
    secret,
    t,
)

landing_s3 = define_s3_connection("landing_s3", {
    "region": "us-east-1",
    "arn": secret("AWS_ROLE_ARN"),
})

events = define_datasource("events", {
    "schema": {
        "timestamp": t.date_time(),
        "session_id": t.string(),
        "status": t.string(),
    },
    "engine": engine.merge_tree({
        "sorting_key": ["timestamp"],
    }),
})

events_export_sink = define_sink_pipe("events_export_sink", {
    "sink": {
        "connection": landing_s3,
        "bucket_uri": "s3://my-bucket/exports/",
        "file_template": "events_{date}",
        "format": "csv",
        "schedule": "0 * * * *",
    },
    "nodes": [
        node({
            "name": "export",
            "sql": """
                SELECT timestamp, session_id
                FROM events
                WHERE status = 'processed'
            """,
        }),
    ],
})
```

{% /tab %}
{% /tabs %}

See all syntax options in the [Sink pipes reference](/forward/dev-reference/datafiles/pipe-files#sink-pipes), [TypeScript SDK reference](/forward/dev-reference/typescript-sdk-resources#sink-pipes), and [Python SDK reference](/forward/dev-reference/python-sdk-resources#sink-pipes).

## Key features

- Fully Managed: Sinks require no additional tooling or infrastructure management.  
- Scheduled or On-Demand: Run exports on a defined schedule using cron expressions or trigger them manually when needed.
- Query Parameters: Support for parameterized queries allows flexible data filtering and transformation.
- Observability: Monitor Sink operations and data transfer through Service Data Sources.

## Common use cases

Sinks enable various data integration scenarios:

- Regular data exports to clients or partner systems.
- Feeding data lakes and data warehouses.
- Real-time data synchronization with external systems.
- Event-driven architectures and data pipelines.
