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

instance
Required
string

The instance were session will be created

max_session_ttl
number

Max allowed time for session to run in seconds.

mode
string

The session mode

Possible Values: batchdedicated

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","max_session_ttl":450,"mode":"batch"}'

Responses

{
  "id": "ci8fo2g4mgo3p0c53uc0"
}

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",
  "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
}

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
Was this page helpful?