Before you begin
Before you get started, ensure you have an IonQ Quantum Cloud account and have created an API key. For guidance on setting up and managing your API keys, please refer to our dedicated guide. This guide assumes you have completed these steps and stored your API key as a local environment variable namedIONQ_API_KEY
.
Writing a quantum circuit
We’ll need to create a quantum circuit to submit as your first job. Let’s use a simple GHZ state using three qubits, first applying a Hadamard gate to a single qubit, and then using it as the control qubit for a series of controlled-NOT gates on the other two. A three-qubit GHZ circuit can be visualized like this:
Submitting a quantum circuit as a job
For the purposes of this guide we’ll use
curl
on the command line, but in the real world example, you’d likely want to use an SDK.simulator
or qpu.aria-1
). We can also assign a name to the job for easier reference.
For a full list of options that can be passed to this resource, check out the API reference for POST /jobs.
ghz-job.json
.
We’re now ready to submit our job to the IonQ Quantum Cloud API. We’ll use a POST
request to send our JSON job data to the job creation endpoint. This request will include two headers: one for authorization using the API key we created earlier, and another to specify that the request body is in JSON format. In this example, we give the backend
key the value simulator
, which sends the job to our QPU simulator:
id
can then be used to manage the submitted job, including canceling it, checking its status, or retrieving the results.
Retrieving a job status
To retrieve the status of a job, we can use aGET
request to its unique resource URL, identified by the job ID:
Remember to replace
{your-job-id}
with the ID you just got back.GET
request will resemble the following: