# Python Microsoft Fabric API - Jobs

run\_job, get\_job and cancel\_job, the job types for notebooks, pipelines and report refreshes, and the statuses.

Running a notebook, running a pipeline and refreshing a report's data are all jobs in Fabric, started, checked and cancelled with the same three methods. Every one takes the workspace ID and the ID of the item the job belongs to.

## Job types {#job-types}

| Item | Job type | What it does |
| --- | --- | --- |
| Notebook | `RunNotebook` | Runs the notebook once |
| Pipeline | `Pipeline` | Runs the pipeline once |
| A report's dataset | `DefaultSemanticModelRefresh` | Refreshes the report's data from the tables it reads |

## Statuses {#statuses}

`get_job` reports one of these in `status`:

| Status | Meaning |
| --- | --- |
| `NotStarted` | Accepted, not yet running |
| `InProgress` | Running |
| `Completed` | Ended without error |
| `Failed` | Ended with an error, details in `failureReason` |
| `Cancelled` | Stopped with `cancel_job` or from Fabric |
| `Deduped` | Not started, because the same job was already running |

The first two mean the job is still going, everything else means it has ended.

## run\_job {#run_job}

```python
conn.run_job(workspace_id, item_id, job_type, payload=None)
```

Starts a job and returns as soon as Fabric has accepted it, without waiting for it to run.

| Parameter | Type | Meaning |
| --- | --- | --- |
| `workspace_id` | str | The workspace the item is in |
| `item_id` | str | The notebook, pipeline or dataset |
| `job_type` | str | One of the job types above |
| `payload` | dict | Parameters for the job, or none |

Returns the job's ID as a string, for `get_job` and `cancel_job`.

Parameters go under `executionData`. A notebook takes them for its parameter cell, each with a value and a type, a pipeline takes them as plain values:

```python
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class RunNotebook(Service):

    def handle(self):

        workspace_id = '11111111-2222-3333-4444-555555555555'
        notebook_id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'

        conn = self.microsoft.fabric['My Fabric']

        payload = {
            'executionData': {
                'parameters': {
                    'location': {'value': 'Riverside', 'type': 'string'},
                    'days_ahead': {'value': '1', 'type': 'int'},
                }
            }
        }

        job_id = conn.run_job(workspace_id, notebook_id, 'RunNotebook', payload)

        self.response.payload = {'job_id': job_id}
```

```python
payload = {
    'executionData': {
        'parameters': {
            'source_table': 'admissions',
            'target_table': 'occupancy',
        }
    }
}

job_id = conn.run_job(workspace_id, pipeline_id, 'Pipeline', payload)
```

A report refresh takes no parameters:

```python
job_id = conn.run_job(workspace_id, dataset_id, 'DefaultSemanticModelRefresh')
```

## get\_job {#get_job}

```python
conn.get_job(workspace_id, item_id, job_id)
```

Returns the job's current state.

| Parameter | Type | Meaning |
| --- | --- | --- |
| `workspace_id` | str | The workspace the item is in |
| `item_id` | str | The item the job belongs to |
| `job_id` | str | The ID `run_job` returned |

Returns a dict with `id`, `itemId`, `jobType`, `invokeType`, `status`, `startTimeUtc`, `endTimeUtc` and, for a failed job, `failureReason`.

```python
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class GetJob(Service):

    def handle(self):

        workspace_id = '11111111-2222-3333-4444-555555555555'
        item_id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
        job_id = 'dddddddd-eeee-ffff-0000-111111111111'

        conn = self.microsoft.fabric['My Fabric']

        job = conn.get_job(workspace_id, item_id, job_id)

        self.response.payload = {'status': job['status'], 'started': job['startTimeUtc'], 'ended': job['endTimeUtc']}
```

```json
{"status": "Completed", "started": "2026-03-12T02:30:04Z", "ended": "2026-03-12T02:34:11Z"}
```

## cancel\_job {#cancel_job}

```python
conn.cancel_job(workspace_id, item_id, job_id)
```

Asks Fabric to stop a running job. Returns nothing, and the job's status becomes `Cancelled` once it has stopped, which `get_job` shows.

| Parameter | Type | Meaning |
| --- | --- | --- |
| `workspace_id` | str | The workspace the item is in |
| `item_id` | str | The item the job belongs to |
| `job_id` | str | The ID `run_job` returned |

```python
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class CancelJob(Service):

    def handle(self):

        workspace_id = '11111111-2222-3333-4444-555555555555'
        item_id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
        job_id = 'dddddddd-eeee-ffff-0000-111111111111'

        conn = self.microsoft.fabric['My Fabric']

        conn.cancel_job(workspace_id, item_id, job_id)
```

## See also {#see-also}

- [Picking up results when a notebook finishes](https://zato.io/docs/dev/examples/cloud/fabric/notebook-results.html) - run\_job and get\_job across two scheduled services
- [Running a pipeline and refreshing a report](https://zato.io/docs/dev/examples/cloud/fabric/pipelines-and-reports.html) - All three methods in one service, with a timeout
- [Workspaces](https://zato.io/docs/dev/examples/cloud/fabric/api/workspaces.html) - Finding the item IDs the jobs need

## Learn more {#learn-more}

- [Development documentation](https://zato.io/docs/dev/) - Everything about writing services, in one place
- [Requests and responses](https://zato.io/docs/dev/request-response/) - What a service receives, what it returns and how to shape both
- [Integration examples](https://zato.io/docs/dev/examples/) - Ready-made code for the systems you are likely to connect to
- [IDE and debugging](https://zato.io/docs/dev/ide/) - Write services in the Dashboard or in your own editor
- [Data models](https://zato.io/docs/dev/model/) - Declare inputs and outputs and have them validated for you
- [In-depth API tutorial](https://zato.io/tutorials/main/01.html) - The full platform tutorial, from installation to production patterns
