Skip to main contentIBM Quantum Documentation

Sessions


Create session

Create a runtime session

Body Parameters (application/json)

Name, TypeDescription
backend
Required
string

Name that identifies the system on which to run the job

Example: "ibmq_wellington"
instance
Required
string

The instance were session will be created

Example: "hub/group/project"
max_session_ttl
number

Max allowed time for session to run in seconds.

Example: 450
mode
string

The session mode

Possible values: batchdedicated
Example: "batch"

HTTP Response Status Codes

Status codeDescription
200Returns the created session id
401Unauthorized
403Forbidden
404Not found
500Internal server error

Code samples

POST
/sessions
curl -X POST \
  https://api.quantum-computing.ibm.com/runtime/sessions \
  -H 'Authorization: Bearer YOUR-TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"backend":"ibmq_wellington","instance":"hub/group/project"}'

Responses

{
  "id": "ci8fo2g4mgo3p0c53uc0",
  "messages": [
    {
      "level": "warn",
      "data": "Dedicated session execution mode is not supported in the open plan. Jobs will run in job mode instead.."
    }
  ]
}

Get session

Get a runtime session details

Path Parameters

Name, TypeDescription
id
Required
string

Identifier of an existing runtime session

HTTP Response Status Codes

Status codeDescription
200Returns runtime session
401Unauthorized
404Not found
500Internal server error

Code samples

GET
/sessions/{id}
curl -X GET \
  https://api.quantum-computing.ibm.com/runtime/sessions/{id} \
  -H 'Authorization: Bearer YOUR-TOKEN' \
  -H 'Accept: application/json'

Responses

{
  "id": "11111111111111111111",
  "backend_name": "ibm-tenerife",
  "started_at": "2023-10-01T00:00:00.000Z",
  "created_at": "2023-10-01T00:00:00.000Z",
  "activated_at": "2023-10-01T00:00:00.000Z",
  "closed_at": "2023-10-01T00:00:00.000Z",
  "last_job_started": "2023-10-01T00:00:00.000Z",
  "last_job_completed": "2023-10-01T00:00:00.000Z",
  "interactive_ttl": 100,
  "max_ttl": 1000,
  "active_ttl": 1000,
  "state": "active",
  "accepting_jobs": true,
  "mode": "batch",
  "elapsed_time": 1000
}

Update session

Update a session

Path Parameters

Name, TypeDescription
id
Required
string

Identifier of an existing runtime session

Body Parameters (application/json)

Name, TypeDescription
accepting_jobs
Required
boolean

Whether the session accepts new jobs or not

HTTP Response Status Codes

Status codeDescription
204Successfully update a runtime session
401Unauthorized
404Not found
500Internal server error

Code samples

PATCH
/sessions/{id}
curl -X PATCH \
  https://api.quantum-computing.ibm.com/runtime/sessions/{id} \
  -H 'Authorization: Bearer YOUR-TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"accepting_jobs":true}'

Responses

Successfully update a runtime session

Close session

Closes the runtime session

Path Parameters

Name, TypeDescription
id
Required
string

Session Id

HTTP Response Status Codes

Status codeDescription
204Successfully closed runtime session

Code samples

DELETE
/sessions/{id}/close
curl -X DELETE \
  https://api.quantum-computing.ibm.com/runtime/sessions/{id}/close \
  -H 'Authorization: Bearer YOUR-TOKEN' \
  -H 'Accept: application/json'

Responses

Successfully closed runtime session

Get session

Get a runtime session details

Path Parameters

Name, TypeDescription
id
Required
string

Identifier of an existing runtime session

HTTP Response Status Codes

Status codeDescription
200Returns session details extended
401Unauthorized
404Not found
500Internal server error

Code samples

GET
/sessions/{id}/extended
curl -X GET \
  https://api.quantum-computing.ibm.com/runtime/sessions/{id}/extended \
  -H 'Authorization: Bearer YOUR-TOKEN' \
  -H 'Accept: application/json'

Responses

{
  "id": "11111111111111111111",
  "user_id": "123456",
  "backend_name": "ibm-tenerife",
  "instance": "aHub/aGroup/aProject",
  "started_at": "2023-10-01T00:00:00.000Z",
  "created_at": "2023-10-01T00:00:00.000Z",
  "activated_at": "2023-10-01T00:00:00.000Z",
  "closed_at": "2023-10-01T00:00:00.000Z",
  "last_job_started": "2023-10-01T00:00:00.000Z",
  "last_job_completed": "2023-10-01T00:00:00.000Z",
  "interactive_ttl": 100,
  "max_ttl": 1000,
  "active_ttl": 1000,
  "status": "active",
  "status_reason": "session_inactivated_by_interactive_ttl",
  "accepting_jobs": true,
  "mode": "batch",
  "elapsed_time": 1000,
  "session_remaining_time_seconds": 12000,
  "timestamps": [
    {
      "status": "pending",
      "date": "2023-10-01T00:00:00.000Z"
    }
  ]
}

Get session jobs

Get all jobs from a session id

Path Parameters

Name, TypeDescription
id
Required
string

Query Parameters

Name, TypeDescription
offset
number

Number of jobs to skip when retrieving the list of jobs

Default value: 0
limit
number

Number of jobs to return at a time

Default value: 10
sort
string

Order to sort the workloads by

Possible values: ascdescASCDESC
Default value: desc

HTTP Response Status Codes

Status codeDescription
200
401Unauthorized
403Forbidden
404Not found

Code samples

GET
/sessions/{id}/jobs
curl -X GET \
  https://api.quantum-computing.ibm.com/runtime/sessions/{id}/jobs \
  -H 'Authorization: Bearer YOUR-TOKEN' \
  -H 'Accept: application/json'

Responses

{
  "jobs": [
    {
      "id": "ch8b1ok4k9li68vm059r",
      "hub": "ibmq",
      "group": "open",
      "project": "main",
      "backend": "ibm_seattle",
      "state": {
        "status": "Cancelled",
        "reason": "Ran too long"
      },
      "status": "Completed",
      "params": {},
      "program": {
        "id": "ch8b1ok4k9li68vm059r"
      },
      "created": "2021-05-05 00:56:04.569709",
      "ended": "2021-05-05 00:56:04.569709",
      "runtime": "example",
      "cost": 1,
      "tags": [
        "test-job"
      ],
      "session_id": "ch8b1ok4k9li68vm059r",
      "usage": {
        "seconds": 1
      },
      "estimated_running_time_seconds": 123,
      "estimated_max_running_time_seconds": 123
    }
  ],
  "count": 5,
  "limit": 5,
  "offset": 1
}
Was this page helpful?
Report a bug or request content on GitHub.