---
title: External job runs
description: External job runs in the dltHub Runtime Python SDK (dlthub_sdk)
keywords: [dlthub, runtime, python sdk, dlthub_sdk, api]
---
# External job runs

<!-- generated from dlthub-client 0.33.2, do not edit -->

New to the SDK? [Getting started](getting-started.md) shows how to connect and use it.

## `ExternalJobRuns` {#externaljobruns}

The runs external runners report in one workspace.

### `ExternalJobRuns.start()` {#externaljobruns-start}

```python
start(
    *,
    job_ref: str,
    external_id: str,
    started_at: datetime,
    trigger: str,
    dlt_version: str,
    refresh: bool = False,
    previous_job_run_id: str | None = None,
    details: ExternalRunDetails | None = None,
    runner_bootstrap_version: int | None = None,
) -> ExternalJobRun
```

Report that an external runner is about to run an externally controlled job.

Repeating a start with the same `external_id` answers the run it
recorded, so a retried start is safe.

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `job_ref` | <code>str</code> | The job to run, by its ref. |
| `external_id` | <code>str</code> | The run's id on the external runner, unique per workspace. |
| `started_at` | <code>datetime</code> | When the external runner started the run. |
| `trigger` | <code>str</code> | What fired the run, e.g. `manual:<job_ref>`. |
| `dlt_version` | <code>str</code> | The dlt version installed where the job runs. |
| `refresh` | <code>bool</code> | Whether to start the run as a refresh. |
| `previous_job_run_id` | <code>str &#124; None</code> | For a follow-up, the run it follows. |
| `details` | <code><a href="job-runs#externalrundetails">ExternalRunDetails</a> &#124; None</code> | What the external runner reports about the run. |
| `runner_bootstrap_version` | <code>int &#124; None</code> | The newest bootstrap version the runner reads, from `dlt_runtime.external.runner_bootstrap_version()`. |

**Returns:** <code><a href="#externaljobrun">ExternalJobRun</a></code> — The run and its bootstrap; awaitable in async mode. A repeated start for a run that has ended carries no bootstrap.

**Raises**

| Exception | When |
| --- | --- |
| [`BadRequest`](errors.md#badrequest) | The job is archived or not externally controlled, the details pass 16 KB, or the runner is too old for dltHub (`code` is `runner_too_old`). |
| [`Conflict`](errors.md#conflict) | The job would not take the run, e.g. it is paused or at its concurrency limit; `code` says why, and no run is recorded. |
| [`NotAuthorized`](errors.md#notauthorized) | Only the owner of the workspace's organization reports external runs. |
| [`NotFound`](errors.md#notfound) | No job with that ref. |
| [`ServerError`](errors.md#servererror) | The run could not be started on its data plane. |
| [`ScopeMissing`](errors.md#scopemissing) | Reached without a workspace in scope. |

### `ExternalJobRuns.get()` {#externaljobruns-get}

```python
get(*, id: str) -> ExternalJobRun
```

Return one external run by id; it never carries a bootstrap.

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `id` | <code>str</code> | The run's uuid. |

**Returns:** <code><a href="#externaljobrun">ExternalJobRun</a></code> — The run; awaitable in async mode.

**Raises**

| Exception | When |
| --- | --- |
| [`BadRequest`](errors.md#badrequest) | The id is not a uuid. |
| [`NotFound`](errors.md#notfound) | No external run with that id in this workspace. |
| [`ScopeMissing`](errors.md#scopemissing) | Reached without a workspace in scope. |

### `ExternalJobRuns.finish()` {#externaljobruns-finish}

```python
finish(
    *,
    id: str,
    status: ExternalRunEnd,
    finished_at: datetime,
    details: ExternalRunDetails | None = None,
) -> ExternalJobRun
```

Report how an external run ended.

A run that already ended is answered as recorded.

**Arguments**

| Name | Type | Description |
| --- | --- | --- |
| `id` | <code>str</code> | The run's uuid, as its start answered it. |
| `status` | <code><a href="#externalrunend">ExternalRunEnd</a></code> | How the run ended. |
| `finished_at` | <code>datetime</code> | When the external runner ended the run. |
| `details` | <code><a href="job-runs#externalrundetails">ExternalRunDetails</a> &#124; None</code> | Merged into the start's details; `error` says why a failed run failed. |

**Returns:** <code><a href="#externaljobrun">ExternalJobRun</a></code> — The ended run; awaitable in async mode.

**Raises**

| Exception | When |
| --- | --- |
| [`BadRequest`](errors.md#badrequest) | The run is not external, or the details together pass 16 KB. |
| [`NotAuthorized`](errors.md#notauthorized) | Only the owner of the workspace's organization reports external runs. |
| [`NotFound`](errors.md#notfound) | No such run in this workspace. |
| [`ServerError`](errors.md#servererror) | The run's end could not be applied. |
| [`ScopeMissing`](errors.md#scopemissing) | Reached without a workspace in scope. |

## `ExternalJobRun` {#externaljobrun}

Subclass of [`JobRun[M]`](job-runs.md#jobrun).

A run of an externally controlled job, as its external runner reported it.

Only its external runner ends it, with [`ExternalJobRuns.finish()`](#externaljobruns-finish): dltHub
refuses `cancel()` for it.

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `bootstrap` | <code>Mapping[str, Any] &#124; None</code> | The document the external runner hands our runner as `bootstrap.json`, written as is; answered only by [`ExternalJobRuns.start()`](#externaljobruns-start), and `None` once the run has ended. It carries the run's credentials: keep it secret. |

## `ExternalRunEnd` {#externalrunend}

```python
ExternalRunEnd = Literal[JobRunStatus.COMPLETED, JobRunStatus.FAILED, JobRunStatus.CANCELLED]
```
