Skip to main contentIBM Quantum Documentation Preview
This is a preview build of IBM Quantum® documentation. Refer to quantum.cloud.ibm.com/docs for the official documentation.

Use IBM Cloud Resource Controller API for instance management

You can use the IBM Cloud® Resource Controller REST API to programmatically get, create, and update instances.

All Resource Controller endpoints require that you authenticate by passing a header called Authorization with the bearer token. Refer to the REST API setup guide.


Get an instance

Use the GET /v2/resource_instances/{crn} endpoint to get information about a particular instance. The CRN must be URL-encoded in the path.

In addition to the standard Resource Controller fields, the response includes quantum-specific fields in both parameters and extensions. extensions stores the instance's normalized metadata, whereas parameters only stores the most recent request to modify the instance. Therefore, you should read from extensions rather than parameters.

The extensions object includes these fields:

  • instance_limit_seconds — Integer, or null. The usage time limit for the instance. See Set instance allocation limits.
  • usage_allocation_seconds — Integer, or null. The time allocated to this instance, used by the fair-share scheduler to determine queue priority. See Set instance allocation limits.
  • backends — Array of strings. The allowlist of backend names available to this instance. ["ANY"] means all backends on the plan are available (the default). [] means no backends are available.
The backends field may be outdated

The backends field in the extensions object may be outdated. This can happen when IBM Quantum Support changes your account in a way that impacts instances. For example, when a backend is removed from an account, it will update the backends for the instance, but that change is currently not yet reflected in the Resource Controller API.

Instead, the current workaround is to use the Qiskit Runtime REST API with the GET /v1/backends endpoint. (Make sure that you set the Service-CRN header to your instance's CRN.)

The CRN must be URL-encoded in the path. Replace each : with %3A and each / with %2F. For example, crn:v1:bluemix:... becomes crn%3Av1%3Abluemix%3A....

curl \
  --request GET \
  --url 'https://resource-controller.cloud.ibm.com/v2/resource_instances/<YOUR_INSTANCE_CRN_URL_ENCODED>' \
  --header 'Authorization: Bearer <YOUR_BEARER_TOKEN>'

Get a list of all instances

Use the GET /v2/resource_instances endpoint to get a list of all your instances. Set the resource_id query parameter to b6049020-80f4-11eb-a0f7-e35ec9b4054f to filter to IBM Quantum® instances.

If your account has multiple plans and you want to filter by plan, set the resource_plan_id query parameter to one of the following values:

Plan
resource_plan_id
Premium7f666d17-7893-47d8-bf9d-2b2389fc4dfc
Flex53bde9d3-cdbb-46f5-a98f-60ebcadf7260
Pay-As-You-Go5304b575-3cff-4455-90dc-ae4367762093
Open850b21a7-71de-4e53-9441-1abdd202f35d

Each result includes the same extensions field as described in Get an instance.

curl \
  --request GET \
  --url 'https://resource-controller.cloud.ibm.com/v2/resource_instances?resource_id=b6049020-80f4-11eb-a0f7-e35ec9b4054f' \
  --header 'Authorization: Bearer <YOUR_BEARER_TOKEN>'

Update an instance

Use the PATCH /v2/resource_instances/{crn} endpoint to update the limit, allocation, and permitted backends for an instance. The CRN must be URL-encoded in the path.

Pass a parameters JSON object in the request body with the fields you want to change, along with the header "Content-Type: application/json". Omitted fields are left unchanged.

  • instance_limit_seconds — Integer, or null. The usage time limit for the instance. See Set instance allocation limits.
  • usage_allocation_seconds — Integer, or null. The time allocated to this instance, used by the fair-share scheduler to determine queue priority. See Set instance allocation limits. Not applicable to Pay-As-You-Go instances.
  • backends — Array of strings. The allowlist of backend names available to this instance. ["ANY"] means all backends on the plan are available. [] means no backends are available.
Always include a unique timestamp

The API silently ignores the request if parameters is identical to the previous request. In the parameters object, always include a timestamp field set to the current time so each request is treated as unique.

The endpoint's response is similar to getting an instance, including how it handles the extensions object.

The CRN must be URL-encoded in the path. Replace each : with %3A and each / with %2F. For example, crn:v1:bluemix:... becomes crn%3Av1%3Abluemix%3A....

curl \
--request PATCH \
--url 'https://resource-controller.cloud.ibm.com/v2/resource_instances/<YOUR_INSTANCE_CRN_URL_ENCODED>' \
--header 'Authorization: Bearer <YOUR_BEARER_TOKEN>' \
--header 'Content-Type: application/json' \
--data "{
    \"parameters\": {
        \"timestamp\": \"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\",
        \"usage_allocation_seconds\": 220
    }
}"

Create a new instance

Use the POST /v2/resource_instances endpoint to create (provision) a new instance. Pass a JSON body with the header "Content-Type: application/json".

Required fields:

  • name — A human-readable name for the instance.
  • target — The region, such as us-east or eu-de.
  • resource_plan_id — The plan for this instance. See the plan ID table.
  • resource_group — The resource group to use.

You can also include a parameters object to set quantum-specific values:

  • instance_limit_seconds — Integer, or null. The usage time limit for the instance. See Set instance allocation limits.
  • usage_allocation_seconds — Integer, or null. The time allocated to this instance, used by the fair-share scheduler to determine queue priority. See Set instance allocation limits. Not applicable to Pay-As-You-Go instances.
  • backends — Array of strings. The allowlist of backend names available to this instance. ["ANY"] means all backends on the plan are available. [] means no backends are available.
curl \
  --request POST \
  --url 'https://resource-controller.cloud.ibm.com/v2/resource_instances' \
  --header 'Authorization: Bearer <YOUR_BEARER_TOKEN>' \
  --header 'Content-Type: application/json' \
  --data '{
      "name": "my-new-instance",
      "target": "us-east",
      "resource_plan_id": "7f666d17-7893-47d8-bf9d-2b2389fc4dfc",
      "resource_group": "<YOUR_RESOURCE_GROUP_ID>",
      "parameters": {
          "instance_limit_seconds": 300,
          "usage_allocation_seconds": 220
      }
  }'