---
title: RuntimeJobV2 (latest version)
description: API reference for qiskit_ibm_runtime.RuntimeJobV2 in the latest version of qiskit-ibm-runtime
source: https://quantum.cloud.ibm.com/docs/en/api/qiskit-ibm-runtime/runtime-job-v2
---

# RuntimeJobV2

*class* `RuntimeJobV2(backend, api_client, job_id, program_id, service, creation_date=None, result_decoder=None, image='', session_id=None, tags=None, version=None, private=False)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.48/qiskit_ibm_runtime/runtime_job_v2.py#L58-L302)

Bases: [`BasePrimitiveJob`](/docs/api/qiskit/qiskit.primitives.BasePrimitiveJob)\[[`PrimitiveResult`](/docs/api/qiskit/qiskit.primitives.PrimitiveResult), `Literal`\[‘INITIALIZING’, ‘QUEUED’, ‘RUNNING’, ‘CANCELLED’, ‘DONE’, ‘ERROR’]], `BaseRuntimeJob`

Representation of a runtime V2 primitive execution.

**Parameters**

- **backend** (*Backend*) – The backend instance used to run this job.
- **api\_client** (*RuntimeClient*) – Object for connecting to the server.
- **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.
- **result\_decoder** (*type\[ResultDecoder] | Sequence\[type\[ResultDecoder]] | None*) – A `ResultDecoder` subclass used to decode job results, or a list of such subclasses. If more than one decoder is specified, they will be called in chain, with the output of the `n-th` decoder as the input of the `n+1-th` decoder. If not specified, the default `ResultDecoder` is used.
- **image** (*str | None*) – Runtime image used for this job: image\_name:tag.
- **service** ([*qiskit\_runtime\_service.QiskitRuntimeService*](/docs/api/qiskit-ibm-runtime/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.
- **private** (*bool | None*) – Marks job as private.

Initializes the primitive job.

**Parameters**

- **job\_id** (*str*) – A unique id in the context of the primitive used to run the job.
- **kwargs** – Any key value metadata to associate with this job.
- **backend** (*Backend*)
- **api\_client** (*RuntimeClient*)
- **program\_id** (*str*)
- **service** ([*qiskit\_runtime\_service.QiskitRuntimeService*](/docs/api/qiskit-ibm-runtime/qiskit-runtime-service "qiskit_ibm_runtime.qiskit_runtime_service.QiskitRuntimeService"))
- **creation\_date** (*str | None*)
- **result\_decoder** (*type\[ResultDecoder] | Sequence\[type\[ResultDecoder]] | None*)
- **image** (*str | None*)
- **session\_id** (*str | None*)
- **tags** (*list | None*)
- **version** (*int | None*)
- **private** (*bool | None*)

## Attributes

### ERROR

Type: `str | RuntimeJobStatus`

Default value: `'ERROR'`

### JOB\_FINAL\_STATES

Type: `tuple[JobStatus, ...]`

Default value: `('DONE', 'CANCELLED', '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**

The runtime image `image_name:tag` or `""` if the default image is used.

### inputs

Job input parameters.

**Returns**

Input parameters used in this job.

### instance

Return the IBM Cloud instance CRN.

### 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 information 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.

## Methods

### backend

`backend(timeout=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.48/qiskit_ibm_runtime/runtime_job_v2.py#L288-L302)

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 | None

### cancel

`cancel()`

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

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()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.48/qiskit_ibm_runtime/runtime_job_v2.py#L203-L205)

Return whether the job has been cancelled.

**Return type**

bool

### done

`done()`

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

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.48/qiskit_ibm_runtime/base_runtime_job.py#L218-L225)

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.48/qiskit_ibm_runtime/runtime_job_v2.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.48/qiskit_ibm_runtime/runtime_job_v2.py#L215-L217)

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.48/qiskit_ibm_runtime/runtime_job_v2.py#L223-L242)

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.48/qiskit_ibm_runtime/base_runtime_job.py#L154-L170)

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.48/qiskit_ibm_runtime/base_runtime_job.py#L201-L216)

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 started running, or `None` if properties are not available.

**Return type**

[BackendProperties](/docs/api/qiskit-ibm-runtime/models-backend-properties "qiskit_ibm_runtime.models.BackendProperties") | None

### result

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

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.48/qiskit_ibm_runtime/runtime_job_v2.py#L115-L160)

Return the results of the job.

**Parameters**

- **timeout** (*float | None*) – Number of seconds to wait for job.

- **decoder** (*type\[ResultDecoder] | Sequence\[type\[ResultDecoder]] | None*) – A `ResultDecoder` subclass used to decode job results, or a list of such subclasses. If more than one decoder is specified, they will be called in chain, with the output of the `n-th` decoder as the input of the `n+1-th` decoder.

- **poll\_interval** (*float | None*) –

  Number of seconds to wait between successive queries of the job’s status. of the job.

  - For non-session jobs, the default is `500ms`, and the floor value is `100ms`.
  - For session jobs, the default and the floor value are `100ms`.

**Returns**

Runtime job result (post-processed if applicable).

**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()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.48/qiskit_ibm_runtime/runtime_job_v2.py#L219-L221)

Return whether the job is actively running.

**Return type**

bool

### status

`status()`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.48/qiskit_ibm_runtime/runtime_job_v2.py#L177-L184)

Return the status of the job.

**Returns**

Status of this job.

**Return type**

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

### update\_tags

`update_tags(new_tags)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.48/qiskit_ibm_runtime/base_runtime_job.py#L172-L199)

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(partial=False)`

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

Return job usage in seconds.

By default, the job usage returned is `0` until the usage calculation is completed. Accumulated intermediate usage can be returned by the method by using the `partial` flag.

> **Note**
>
> When using `partial`, note that is not guaranteed that the final usage is returned as soon as the job is completed. It is recommended to invoke the method with `partial=False` for guarantees that the usage returned is final, or to use the [`metrics()`](#qiskit_ibm_runtime.RuntimeJobV2.metrics "qiskit_ibm_runtime.RuntimeJobV2.metrics") method for details on the completion status.

**Parameters**

**partial** (*bool*) – if `True`, return the accumulated intermediate usage thus far until final usage is reached.

**Return type**

float

### wait\_for\_final\_state

`wait_for_final_state(timeout=None, poll_interval=None)`

[GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/stable/0.48/qiskit_ibm_runtime/runtime_job_v2.py#L244-L286)

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.

- **poll\_interval** (*float | None*) –

  Number of seconds to wait between querying the service for the status of the job.

  - For non-session jobs, the default is `500ms`, and the floor value is `100ms`.
  - For session jobs, the default and the floor value is `100ms`.

**Raises**

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

**Return type**

None
