---
title: Lakeflow Integrations
description: Build, register, and use Lakeflow Integrations, custom function and sensor tasks that extend Lakeflow Jobs in Databricks.
canonical_url: https://docs.databricks.com/gcp/en/jobs/tasks/lakeflow-integrations
---

# Lakeflow Integrations

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/gcp/en/release-notes/release-types.md).

Integrations are custom tasks that you can add to Lakeflow Jobs. An author writes an integration in Python and registers it in the workspace, making it available from the **Add task** dialog. Any other user can then use it in a job without writing code.

An integration is either a function or a sensor:

* **Functions** perform a one-time operation, such as sending a notification.
* **Sensors** wait on a condition by checking it in a loop. Between checks, a sensor releases its compute instead of holding it idle, so it can wait efficiently.

To get started, [add an integration](https://docs.databricks.com/gcp/en/jobs/tasks/lakeflow-integrations.md#add-integration) or [use a registered integration](https://docs.databricks.com/gcp/en/jobs/tasks/lakeflow-integrations.md#use-integration).

> [!NOTE]
>
> To provide feedback or ask questions during the preview, email [lakeflow-integrations-private-preview@databricks.com](mailto\:lakeflow-integrations-private-preview@databricks.com).

## <a id="add-integration" />Add an integration

You author integrations using [Declarative Automation Bundles](https://docs.databricks.com/gcp/en/dev-tools/bundles/index.md). Create a bundle from the **Lakeflow Integrations** template, which scaffolds two sample integrations that you can modify to build your own. You can create the bundle from the workspace or from the Databricks CLI.

### Workspace

To create and register an integration from the workspace UI:

1. Create a bundle from the **Lakeflow Integrations** template, following [Tutorial: Create and deploy a bundle in the workspace](https://docs.databricks.com/gcp/en/dev-tools/bundles/workspace-tutorial.md).

2. When the bundle is created, click the bundle (rocket) icon in the left sidebar, then click **Deploy**. Deployment uploads the integration YAML and wheel files, and creates example jobs.

3. Find the uploaded wheels and YAML files at `/Workspace/Users/<user>/.bundle/<bundle>/dev/artifacts/.internal`.

4. Register the uploaded integrations so they appear in the UI, using a `.lakeflow_integrations.yml` file:

   * To make an integration available to any user, add it to `/Workspace/.lakeflow_integrations.yml` and grant workspace users permission to read the file.
   * To make an integration visible only to yourself, add it to `/Workspace/Users/<user>/.lakeflow_integrations.yml`.

   For example:

   ```yaml
   integrations:
     - '/Workspace/Users/<user>/.bundle/<bundle>/dev/artifacts/.internal/*.yml'
   ```

5. To share integrations across workspace users, add top-level permissions in `databricks.yml`:

   ```yaml
   permissions:
     - group_name: 'users'
       level: CAN_VIEW
   ```

### Databricks CLI

To create and register an integration from the Databricks CLI:

1. Install Databricks CLI version 1.7.0 or later. See [Install or update the Databricks CLI](https://docs.databricks.com/gcp/en/dev-tools/cli/install.md).

   ```bash
   databricks version
   # Databricks CLI v1.7.0
   ```

2. Authenticate to your workspace if you haven't already:

   ```bash
   databricks configure
   ```

3. Install [uv](https://docs.astral.sh/uv). See [Installing uv](https://docs.astral.sh/uv/getting-started/installation/). Bundles use uv for packaging.

4. Create a bundle from the **Lakeflow Integrations** template:

   ```bash
   databricks bundle init lakeflow-integrations
   ```

5. Change into the project directory and deploy the bundle:

   ```bash
   cd my_lakeflow_integrations
   databricks bundle deploy
   ```

   Deployment builds the integration YAML and Python wheel, then uploads them to the workspace.

6. Confirm that the integration YAML and wheel files were uploaded:

   ```bash
   databricks workspace list /Workspace/Users/<user>/.bundle/my_lakeflow_integrations/dev/artifacts/.internal
   ```

7. Register the uploaded integrations so they appear in the UI, using a `.lakeflow_integrations.yml` file:

   * To make an integration available to any user, add it to `/Workspace/.lakeflow_integrations.yml` and grant workspace users permission to read the file.
   * To make an integration visible only to yourself, add it to `/Workspace/Users/<user>/.lakeflow_integrations.yml`.

   For example:

   ```yaml
   integrations:
     - '/Workspace/Users/<user>/.bundle/my_lakeflow_integrations/dev/artifacts/.internal/*.yml'
   ```

   Upload the file with the Databricks CLI:

   ```bash
   databricks workspace import /Workspace/.lakeflow_integrations.yml --file .lakeflow_integrations.yml --format AUTO
   ```

8. To share integrations across workspace users, add top-level permissions in `databricks.yml`:

   ```yaml
   permissions:
     - group_name: 'users'
       level: CAN_VIEW
   ```

9. The template also creates example jobs that you can inspect or run:

   ```bash
   databricks bundle summary
   databricks bundle run
   ```

## <a id="use-integration" />Use a registered integration

After an integration is registered, any user in the workspace can add it to a job:

1. Refresh the page, or navigate away and back to the Lakeflow Jobs page, to reload the list of available integrations.

2. When adding a task to a job, click **Add task** if the job already has tasks, or **Add another task type** if it has none.

3. Find registered integrations in the **Integrations** section of the **Add task** dialog and select one.

4. Configure the task. The form fields are generated from the integration's configuration.

> [!NOTE]
>
> Custom icons for integrations are not yet supported.

## <a id="api-reference" />API reference

This section describes the Python API for authoring integrations, the bundle task type that runs them, and the YAML schema that registers them.

### <a id="python-api" />Python API

Import these objects from `databricks.lakeflow.integrations` to define functions and sensors.

#### <a id="integration-decorator" />`@integration`

The `@integration` decorator adds metadata to a function or to a `Sensor` class. It generates the Lakeflow Integration YAML file that registers the integration in the workspace or user integration list.

```python
from databricks.lakeflow.integrations import integration
```

Function parameters and class constructor parameters become task parameters. Their string values are interpreted as JSON, so `int`, `str`, `bool`, `dict`, and `list` are all supported.

#### <a id="sensor" />`Sensor`

A protocol for objects that poll an external condition and either complete or defer. A `Sensor` is re-created between poll calls, so any state that must survive a deferral has to be persisted externally, for example in task values, workspace files, or Lakebase.

```python
from databricks.lakeflow.integrations import Context, Sensor, SensorResult
```

As with functions, you can add task parameters through the `__init__` method.

**Methods**

* `poll(self, ctx: Context) -> SensorResult`: Called once per attempt. Return `SensorResult.completed()` when the condition is met, or `SensorResult.deferred(duration)` to release compute and try again later.

#### <a id="context" />`Context`

Passed to `Sensor.poll`, and provides information on the task run.

```python
from databricks.lakeflow.integrations import Context
```

**Attributes**

| Attribute     | Type  | Description                                                                            |
| ------------- | ----- | -------------------------------------------------------------------------------------- |
| `main`        | `str` | The integration's main entry point; the function or `Sensor` class that the task runs. |
| `task_key`    | `str` | The key of the task running the integration.                                           |
| `job_run_id`  | `int` | The ID of the current job run.                                                         |
| `task_run_id` | `int` | The ID of the current task run.                                                        |
| `job_id`      | `int` | The ID of the job the task belongs to.                                                 |

#### <a id="sensor-result" />`SensorResult`

Returned by `Sensor.poll` to indicate whether the task has completed or should be deferred.

```python
from databricks.lakeflow.integrations import SensorResult
```

| Field       | Type                          | Description                                                     |
| ----------- | ----------------------------- | --------------------------------------------------------------- |
| `status`    | `"completed"` or `"deferred"` | The outcome of the poll.                                        |
| `defer_for` | `datetime.timedelta`          | How long to defer before the next poll. Only set when deferred. |

**Methods**

* `SensorResult.completed()`: The condition was met and the task finishes successfully.
* `SensorResult.deferred(duration)`: The condition was not met. The task is rescheduled after `duration`, and compute is released in the meantime.

### <a id="bundle-task" />Bundle task type

Lakeflow Integrations run as a task type called `python_operator_task`:

* `main`: The main function, or a class that extends `Sensor`.
* `parameters`: An array of function or class constructor parameters.

For example:

```yaml
resources:
  jobs:
    my_function:
      name: 'my_function'
      tasks:
        - task_key: slack
          environment_key: my_environment
          python_operator_task:
            main: my_lakeflow_integrations.my_function
            parameters:
              - name: 'conn_id'
                value: 'CHANGEME'
      environments:
        - environment_key: my_environment
          spec:
            environment_version: '5'
            dependencies:
              - ../dist/*.whl
```

### <a id="integration-yaml" />Lakeflow Integration YAML

The bundle template generates the Lakeflow Integration YAML automatically for any function or class annotated with `@integration`. The UI discovers available integrations by inspecting `/Workspace/.lakeflow_integrations.yml` and `/Workspace/Users/<user>/.lakeflow_integrations.yml`.

For example:

```yaml
schema: lakeflow-integration-v0.1.0
name: Slack message
description: Post a message to a Slack channel
icon:
  name: send # A known Databricks icon. See the list of available options below.
  library: databricks # The only available option currently.
main: slack_operator.integrations.slack.send_message
environment:
  environment_version: '5'
  dependencies: # Must include the Python wheel that contains the sensor or function.
    - /Workspace/Shared/integrations/slack_operator-0.1.0.whl
config:
  type: object
  properties:
    channel: # The name of your parameter.
      type: string
      title: Channel # The title to render in the UI instead of the raw parameter name.
      description: Channel to post to.
      default: '#alerts' # Default value for new task instances.
      examples: ['#my-channel'] # The first example is used as the placeholder if the field is empty.
      x-ui:
        widget: input # The widget to render: input, textarea, or number.
    message:
      type: string
      title: Message
      description: Message body.
      examples: ['Pipeline :white_check_mark: completed']
      x-ui:
        widget: textarea
  required: # Parameters listed here are marked as required in the UI.
    - channel
    - message
```

For the full list of icon values, expand the details below.

**Available icon values**

* `app`
* `arrow-in`
* `at`
* `backup`
* `bar-chart`
* `beaker`
* `binary`
* `book`
* `bookmark`
* `brackets-curly`
* `brackets-square`
* `branch`
* `briefcase`
* `brush`
* `bug`
* `calendar`
* `camera`
* `catalog`
* `chain`
* `chart-line`
* `check-circle`
* `checklist`
* `chip`
* `clipboard`
* `clock`
* `cloud`
* `cloud-database`
* `code`
* `columns`
* `compass`
* `connect`
* `copy`
* `dag`
* `dashboard`
* `database`
* `decimal`
* `dollar`
* `download`
* `erd`
* `face-smile`
* `file`
* `filter`
* `flag`
* `flow`
* `folder`
* `fork`
* `function`
* `gear`
* `gift`
* `globe`
* `grid`
* `hash`
* `history`
* `home`
* `image`
* `ingestion`
* `key`
* `layer`
* `leaf`
* `letters`
* `lightbulb`
* `lightning`
* `link`
* `list`
* `lock`
* `mail`
* `map`
* `measure`
* `megaphone`
* `models`
* `moon`
* `notebook`
* `notification`
* `numbers`
* `office`
* `pencil`
* `pie-chart`
* `pipeline`
* `play`
* `plug`
* `puzzle`
* `query`
* `refresh`
* `robot`
* `rocket`
* `rows`
* `school`
* `search`
* `send`
* `share`
* `shield`
* `sliders`
* `sparkle`
* `speech-bubble`
* `speedometer`
* `star`
* `storefront`
* `stream`
* `sun`
* `sync`
* `table`
* `tag`
* `target`
* `terminal`
* `trash`
* `tree`
* `trending`
* `upload`
* `user`
* `user-group`
* `visible`
* `workflows`
* `wrench`
* `zoom-in`

## <a id="billing" />Billing and compute

Integrations run on serverless compute, and billing is similar to running notebooks. Usage appears in system tables under the run name `lakeflow_integrations`:

```sql
SELECT *
FROM system.billing.usage
WHERE usage_metadata.job_name = 'lakeflow_integrations'
```

Compute is reused and released to reduce cost when a task meets any of the following conditions:

* The deferral duration is longer than one minute.
* Multiple parallel sensors run on behalf of the same run-as user or service principal, so the underlying compute can be shared across them.
* The task uses serverless client version 5 or later.

When multiple job runs reuse the same compute, usage is attributed to the first job run that acquired the compute. For example, running 10 parallel sensors, each with 20 iterations and a five-minute deferral, produces about 22 records totaling roughly 0.48 DBU. The exact figure varies with the workload.

```sql
SELECT
  usage_metadata.job_name,
  SUM(usage_quantity) AS usage_quantity,
  COUNT(*) AS records
FROM system.billing.usage
WHERE usage_metadata.job_name = 'lakeflow_integrations'
GROUP BY ALL
```

## <a id="faq" />Frequently asked questions

The following questions address common issues.

### <a id="uc-connection-http" />How do I create a Unity Catalog connection for an external HTTP service?

Follow [Connect to external HTTP services](https://docs.databricks.com/gcp/en/query-federation/http.md).

### <a id="compute-heavy-workload" />Can I run a compute-heavy workload?

Resource-intensive workloads can affect other workloads that reuse the same compute, so Databricks doesn't recommend using this feature with compute-heavy workloads.

## <a id="related-articles" />Additional resources

* [Lakeflow Jobs](https://docs.databricks.com/gcp/en/jobs/index.md)
* [What are Declarative Automation Bundles?](https://docs.databricks.com/gcp/en/dev-tools/bundles/index.md)
* [Connect to external HTTP services](https://docs.databricks.com/gcp/en/query-federation/http.md)
