---
title: RuntimeJob (v0.40)
description: API reference for qiskit_ibm_runtime.RuntimeJob in qiskit-ibm-runtime v0.40
source: https://quantum.cloud.ibm.com/docs/en/api/qiskit-ibm-runtime/0.40/runtime-job
---

# RuntimeJob

*class* `RuntimeJob(backend, api_client, job_id, program_id, service, client_params=None, creation_date=None, user_callback=None, result_decoder=None, image='', session_id=None, tags=None, version=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L47-L367)

Bases: [`JobV1`](/docs/api/qiskit/qiskit.providers.JobV1), `BaseRuntimeJob`

Representation of a runtime primitive execution.

A new `RuntimeJob` instance is returned when you call `QiskitRuntimeService.run` to execute a runtime primitive, or [`QiskitRuntimeService.job`](/docs/api/qiskit-ibm-runtime/0.40/qiskit-runtime-service#job "qiskit_ibm_runtime.QiskitRuntimeService.job") to retrieve a previously executed job.

If the primitive execution is successful, you can inspect the job’s status by calling [`status()`](#qiskit_ibm_runtime.RuntimeJob.status "qiskit_ibm_runtime.RuntimeJob.status"). Job status can be one of the [`JobStatus`](/docs/api/qiskit/qiskit.providers.JobStatus) members.

Some of the methods in this class are blocking, which means control may not be returned immediately. [`result()`](#qiskit_ibm_runtime.RuntimeJob.result "qiskit_ibm_runtime.RuntimeJob.result") is an example of a blocking method:

```python
job = service.run(...)

try:
    job_result = job.result()  # It will block until the job finishes.
    print("The job finished with result {}".format(job_result))
except RuntimeJobFailureError as ex:
    print("Job failed!: {}".format(ex))
```

(DEPRECATED) RuntimeJob constructor.

**Parameters**

- **backend** ([*Backend*](/docs/api/qiskit/qiskit.providers.Backend)) – The backend instance used to run this job.
- **api\_client** (*RuntimeClient*) – Object for connecting to the server.
- **client\_params** (*ClientParameters | None*) – (DEPRECATED) Parameters used for server connection.
- **job\_id** (*str*) – Job ID.
- **program\_id** (*str*) – ID of the program this job is for.
- **creation\_date** (*str | None*) – Job creation date, in UTC.
- **user\_callback** (*Callable | None*) – (DEPRECATED) User callback function.
- **result\_decoder** (*Type\[ResultDecoder] | Sequence\[Type\[ResultDecoder]] | None*) – A `ResultDecoder` subclass used to decode job results.
- **image** (*str | None*) – Runtime image used for this job: image\_name:tag.
- **service** ([*qiskit\_runtime\_service.QiskitRuntimeService*](/docs/api/qiskit-ibm-runtime/0.40/qiskit-runtime-service "qiskit_ibm_runtime.qiskit_runtime_service.QiskitRuntimeService")) – Runtime service.
- **session\_id** (*str | None*) – Job ID of the first job in a runtime session.
- **tags** (*List | None*) – Tags assigned to the job.
- **version** (*int | None*) – Primitive version.

## Attributes

### ERROR

Type: `str | RuntimeJobStatus`

Default value: `'job incurred error'`

### JOB\_FINAL\_STATES

Type: `Tuple[Any, ...]`

Default value: `(JobStatus.DONE, JobStatus.CANCELLED, JobStatus.ERROR)`

### creation\_date

Job creation date in local time.

**Returns**

The job creation date as a datetime object, in local time, or `None` if creation date is not available.

### image

Return the runtime image used for the job.

**Returns**

image\_name:tag or “” if the default image is used.

**Return type**

Runtime image

### inputs

Job input parameters.

**Returns**

Input parameters used in this job.

### instance

For ibm\_quantum channel jobs, return the instance where the job was run. For ibm\_cloud and ibm\_quantum\_platform, None is returned.

### primitive\_id

Primitive name. :returns: Primitive this job is for.

### private

Returns a boolean indicating whether or not the job is private.

### session\_id

Session ID.

**Returns**

Session ID. None if the backend is a simulator.

### tags

Job tags.

**Returns**

Tags assigned to the job that can be used for filtering.

### usage\_estimation

Return the usage estimation infromation for this job.

**Returns**

`quantum_seconds` which is the estimated system execution time of the job in seconds. Quantum time represents the time that the system is dedicated to processing your job.

### version

Default value: `1`

## Methods

### backend

`backend(timeout=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L353-L367)

Return the backend where this job was executed. Retrieve data again if backend is None.

**Raises**

**IBMRuntimeError** – If a network error occurred.

**Parameters**

**timeout** (*float | None*)

**Return type**

[*Backend*](/docs/api/qiskit/qiskit.providers.Backend) | None

### cancel

`cancel()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L172-L185)

Cancel the job.

**Raises**

- **RuntimeInvalidStateError** – If the job is in a state that cannot be cancelled.
- **IBMRuntimeError** – If unable to cancel job.

**Return type**

None

### cancelled

`cancelled()`

Return whether the job has been cancelled.

**Return type**

bool

### done

`done()`

Return whether the job has successfully run.

**Return type**

bool

### error\_message

`error_message()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/base_runtime_job.py#L200-L207)

Returns the reason if the job failed.

**Returns**

Error message string or `None`.

**Return type**

str | None

### errored

`errored()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L211-L213)

Return whether the job has failed.

**Return type**

bool

### in\_final\_state

`in_final_state()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L207-L209)

Return whether the job is in a final job state such as `DONE` or `ERROR`.

**Return type**

bool

### job\_id

`job_id()`

Return a unique id identifying the job.

**Return type**

str

### logs

`logs()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L304-L323)

Return job logs.

> **Note**
>
> Job logs are only available after the job finishes.

**Returns**

Job logs, including standard output and error.

**Raises**

**IBMRuntimeError** – If a network error occurred.

**Return type**

str

### metrics

`metrics()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/base_runtime_job.py#L139-L155)

Return job metrics.

**Returns**

- `timestamps`: Timestamps of when the job was created, started running, and finished.

- **`usage`: Details regarding job usage, the measurement of the amount of**

  time the QPU is locked for your workload.

**Return type**

A dictionary with job metrics including but not limited to the following

**Raises**

**IBMRuntimeError** – If a network error occurred.

### properties

`properties(refresh=False)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/base_runtime_job.py#L186-L198)

Return the backend properties for this job.

**Parameters**

**refresh** (*bool*) – If `True`, re-query the server for the backend properties. Otherwise, return a cached version.

**Returns**

The backend properties used for this job, at the time the job was run, or `None` if properties are not available.

**Return type**

*BackendProperties* | None

### queue\_info

`queue_info()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L270-L302)

Return queue information for this job.

The queue information may include queue position, estimated start and end time, and dynamic priorities for the hub, group, and project. See `QueueInfo` for more information.

> **Note**
>
> The queue information is calculated after the job enters the queue. Therefore, some or all of the information may not be immediately available, and this method may return `None`.

**Returns**

A `QueueInfo` instance that contains queue information for this job, or `None` if queue information is unknown or not applicable.

**Return type**

*QueueInfo* | None

### queue\_position

`queue_position(refresh=False)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L243-L268)

Return the position of the job in the server queue.

> **Note**
>
> The position returned is within the scope of the provider and may differ from the global queue position.

**Parameters**

**refresh** (*bool*) – If `True`, re-query the server to get the latest value. Otherwise return the cached value.

**Returns**

Position in the queue or `None` if position is unknown or not applicable.

**Return type**

int | None

### result

`result(timeout=None, decoder=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L137-L170)

Return the results of the job.

**Parameters**

- **timeout** (*float | None*) – Number of seconds to wait for job.
- **decoder** (*Type\[ResultDecoder] | None*) – A `ResultDecoder` subclass used to decode job results.

**Returns**

Runtime job result.

**Raises**

- **RuntimeJobFailureError** – If the job failed.
- **RuntimeJobMaxTimeoutError** – If the job does not complete within given timeout.
- **RuntimeInvalidStateError** – If the job was cancelled, and attempting to retrieve result.

**Return type**

*Any*

### running

`running()`

Return whether the job is actively running.

**Return type**

bool

### status

`status()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L187-L205)

Return the status of the job.

**Returns**

Status of this job.

**Return type**

[*JobStatus*](/docs/api/qiskit/qiskit.providers.JobStatus)

### submit

`submit()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L229-L241)

Unsupported method. .. note:

```python
This method is not supported, please use
:meth:`~qiskit_ibm_runtime.QiskitRuntimeService.run`
to submit a job.
```

**Raises**

**NotImplementedError** – Upon invocation.

**Return type**

None

### update\_tags

`update_tags(new_tags)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/base_runtime_job.py#L157-L184)

Update the tags associated with this job.

**Parameters**

**new\_tags** (*List\[str]*) – New tags to assign to the job.

**Returns**

The new tags associated with this job.

**Raises**

**IBMApiError** – If an unexpected error occurred when communicating with the server or updating the job tags.

**Return type**

*List*\[str]

### usage

`usage()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/base_runtime_job.py#L131-L137)

Return job usage in seconds.

**Return type**

float

### wait\_for\_final\_state

`wait_for_final_state(timeout=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.40/qiskit_ibm_runtime/runtime_job.py#L325-L351)

Poll for the job status from the API until the status is in a final state.

**Parameters**

**timeout** (*float | None*) – Seconds to wait for the job. If `None`, wait indefinitely.

**Raises**

**RuntimeJobTimeoutError** – If the job does not complete within given timeout.

**Return type**

None
