---
title: RuntimeJobV2 (v0.26)
description: API reference for qiskit_ibm_runtime.RuntimeJobV2 in qiskit-ibm-runtime v0.26
source: https://quantum.cloud.ibm.com/docs/en/api/qiskit-ibm-runtime/0.26/runtime-job-v2
---

# RuntimeJobV2

*class* `RuntimeJobV2(backend, api_client, client_params, job_id, program_id, service, 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.26/qiskit_ibm_runtime/runtime_job_v2.py#L53-L325)

Representation of a runtime V2 primitive exeuction.

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`) – Parameters used for server connection.
- **job\_id** (`str`) – Job ID.
- **program\_id** (`str`) – ID of the program this job is for.
- **creation\_date** (`Optional`\[`str`]) – Job creation date, in UTC.
- **user\_callback** (`Optional`\[`Callable`]) – User callback function.
- **result\_decoder** (`Union`\[`Type`\[`ResultDecoder`], `Sequence`\[`Type`\[`ResultDecoder`]], `None`]) – A `ResultDecoder` subclass used to decode job results.
- **image** (`Optional`\[`str`]) – Runtime image used for this job: image\_name:tag.
- **service** ([`QiskitRuntimeService`](/docs/api/qiskit-ibm-runtime/0.26/qiskit-runtime-service "qiskit_ibm_runtime.qiskit_runtime_service.QiskitRuntimeService")) – Runtime service.
- **session\_id** (`Optional`\[`str`]) – Job ID of the first job in a runtime session.
- **tags** (`Optional`\[`List`]) – Tags assigned to the job.
- **version** (`Optional`\[`int`]) – Primitive version.

## Attributes

### ERROR

Type: `str | RuntimeJobStatus`

Default value: `'ERROR'`

### JOB\_FINAL\_STATES

Type: `Tuple[Literal['INITIALIZING', 'QUEUED', 'RUNNING', 'CANCELLED', 'DONE', 'ERROR'], ...]`

Default value: `('DONE', 'CANCELLED', 'ERROR')`

### creation\_date

Job creation date in local time.

**Return type**

`Optional`\[`datetime`]

**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.

**Return type**

`Dict`

**Returns**

Input parameters used in this job.

### instance

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

**Return type**

`Optional`\[`str`]

### primitive\_id

Primitive name. :rtype: `str` :returns: Primitive this job is for.

### program\_id

Program ID.

**Return type**

`str`

**Returns**

ID of the program this job is for.

### session\_id

Session ID.

**Return type**

`str`

**Returns**

Session ID. None if the backend is a simulator.

### tags

Job tags.

**Return type**

`List`

**Returns**

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

### usage\_estimation

Return the usage estimation infromation for this job.

**Return type**

`Dict`\[`str`, `Any`]

**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.

## Methods

### backend

`backend(timeout=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/runtime_job_v2.py#L259-L273)

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

**Raises**

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

**Return type**

`Optional`\[[`Backend`](/docs/api/qiskit/qiskit.providers.Backend)]

### cancel

`cancel()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/runtime_job_v2.py#L148-L162)

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`

### cancel\_result\_streaming

`cancel_result_streaming()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/base_runtime_job.py#L132-L136)

Cancel result streaming.

**Return type**

`None`

### cancelled

`cancelled()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/runtime_job_v2.py#L190-L192)

Return whether the job has been cancelled.

**Return type**

`bool`

### done

`done()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/runtime_job_v2.py#L194-L196)

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.26/qiskit_ibm_runtime/base_runtime_job.py#L195-L202)

Returns the reason if the job failed.

**Return type**

`Optional`\[`str`]

**Returns**

Error message string or `None`.

### errored

`errored()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/runtime_job_v2.py#L198-L200)

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.26/qiskit_ibm_runtime/runtime_job_v2.py#L202-L204)

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

**Return type**

`bool`

### interim\_results

`interim_results(decoder=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/utils/deprecation.py#L306-L325)

Return the interim results of the job.

**Parameters**

**decoder** (`Optional`\[`Type`\[`ResultDecoder`]]) – A `ResultDecoder` subclass used to decode interim results.

**Return type**

`Any`

**Returns**

Runtime job interim results.

**Raises**

**RuntimeJobFailureError** – If the job failed.

### 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.26/qiskit_ibm_runtime/runtime_job_v2.py#L210-L229)

Return job logs.

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

**Return type**

`str`

**Returns**

Job logs, including standard output and error.

**Raises**

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

### metrics

`metrics()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/base_runtime_job.py#L138-L150)

Return job metrics.

**Return type**

`Dict`\[`str`, `Any`]

**Returns**

Job metrics, which includes timestamp information.

**Raises**

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

### properties

`properties(refresh=False)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/base_runtime_job.py#L181-L193)

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.

**Return type**

`Optional`\[`BackendProperties`]

**Returns**

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

### result

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

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/runtime_job_v2.py#L113-L146)

Return the results of the job.

**Parameters**

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

**Return type**

`Any`

**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.

### running

`running()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/runtime_job_v2.py#L206-L208)

Return whether the job is actively running.

**Return type**

`bool`

### status

`status()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/runtime_job_v2.py#L164-L171)

Return the status of the job.

**Return type**

`Literal`\[‘INITIALIZING’, ‘QUEUED’, ‘RUNNING’, ‘CANCELLED’, ‘DONE’, ‘ERROR’]

**Returns**

Status of this job.

### stream\_results

`stream_results(callback, decoder=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/utils/deprecation.py#L275-L304)

Start streaming job results.

**Parameters**

- **callback** (`Callable`) –

  Callback function to be invoked for any interim results and final result. The callback function will receive 2 positional parameters:

  > 1. Job ID
  > 2. Job result.

- **decoder** (`Optional`\[`Type`\[`ResultDecoder`]]) – A `ResultDecoder` subclass used to decode job results.

**Raises**

**RuntimeInvalidStateError** – If a callback function is already streaming results or if the job already finished.

**Return type**

`None`

### update\_tags

`update_tags(new_tags)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/base_runtime_job.py#L152-L179)

Update the tags associated with this job.

**Parameters**

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

**Return type**

`List`\[`str`]

**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.

### wait\_for\_final\_state

`wait_for_final_state(timeout=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.26/qiskit_ibm_runtime/runtime_job_v2.py#L231-L257)

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

**Parameters**

**timeout** (`Optional`\[`float`]) – Seconds to wait for the job. If `None`, wait indefinitely.

**Raises**

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

**Return type**

`None`
