Use Leona's REST API
Read published Atlas records without signing in. To start a run or read your workspace's results, create a personal access token in Account → Access tokens.
These examples use Bash, curl, jq and Python 3. They call the control plane directly; no Python package or GitHub repository access is needed. Running the submission example starts a real Leona job and uses your account's run allowance.
Set the API origin and token
The hosted origin below is the Python client's configured default. Set LEONA_API_URL to your control-plane origin when using another deployment; omit a trailing slash.
export LEONA_API_URL='https://majorana-api-nikekeixtq-uw.a.run.app'
Create the token while the intended workspace is active. Enable Also let it start verified runs for this guide. Copy the token when it appears; it is shown once. Read it into your shell without placing it in a command's history:
read -r -s -p 'Leona API token: ' LEONA_API_TOKEN
printf '\n'
export LEONA_API_TOKEN
A token expires after the selected 1–90 days and stays bound to the workspace where it was created. Switching workspaces on the website does not move it. Revoking it in Account takes effect on its next request. If you lose it, revoke it and create another.
| Scope | Useful operations |
|---|---|
read | Read workspace resources; request workflow plans and resource estimates. Always included. |
run | Start and cancel runs, execute Qapps, check circuits, and use the permitted notebook write routes. |
hardware | Submit circuits to real hardware, subject to the deployment's provider and allowance gates. Independent of run; this guide does not use it. |
A token cannot read IBM credentials or billing, manage other tokens, or delete an account. Manage credentials through the signed-in website.
Check the token's workspace before doing work:
curl --max-time 30 --fail-with-body -sS \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
"$LEONA_API_URL/v1/me" | jq '{workspace_id, workspace_name, role}'
API reference
GET /v1/openapi.json returns an OpenAPI 3.1 description of the public API: the anonymous reads and every route a personal access token can reach. It needs no token. Each operation that needs a token names the scope it requires in x-leona-token-scope. To browse the routes without the JSON, use the endpoint reference on the developers page: every route, grouped by resource, with the access each one needs.
curl --max-time 30 --fail-with-body -sS "$LEONA_API_URL/v1/openapi.json" -o leona-openapi.json
jq '.paths | keys | length' leona-openapi.json
1. Read an Atlas record
The listing is a JSON array. view=list returns a compact projection; the individual-record request returns the full record.
curl --max-time 30 --fail-with-body -sS -D atlas.headers \
"$LEONA_API_URL/v1/catalog/entries?view=list&limit=10&offset=0" \
-o atlas.json
jq '.[] | {slug, execution_state}' atlas.json
if SLUG=$(jq -er '.[0].slug // empty' atlas.json); then
curl --max-time 30 --fail-with-body -sS \
"$LEONA_API_URL/v1/catalog/entries/$SLUG" | jq .
fi
record contains published source claims, with provenance where available. Reading a catalog entry does not execute it or establish a new verification result.
For more entries, increase offset by the number of entries received. The listing's limit is clamped to 1–500; offset is clamped to zero or greater. X-Catalog-Total in atlas.headers reports the total. If that total changes while reading several pages, restart the read; do not treat a mixed or incomplete set as the complete Atlas.
2. Start a small circuit run
To check a claim you found in Atlas, describe that claim and its assumptions in task_prompt. Start with a small reproduction.
This example asks Leona to build and check a Bell circuit. It requests an execute run explicitly, so the message is sent through the execution pipeline rather than left to automatic mode selection.
cat > run-request.json <<'JSON'
{
"task_prompt": "Build a two-qubit Bell state with H(0) and CX(0,1). Simulate 1024 shots, check the expected Bell-state behavior, and explain what was checked.",
"mode": "execute",
"framework": "qiskit",
"seed": 7,
"shots": 1024
}
JSON
RUN_KEY=$(python3 -c 'import uuid; print(uuid.uuid4())')
curl --max-time 30 --fail-with-body -sS \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
-H 'Content-Type: application/json' \
-H "Idempotency-Key: $RUN_KEY" \
--data-binary @run-request.json \
"$LEONA_API_URL/v1/runs" -o run-created.json
RUN_ID=$(jq -er '.id' run-created.json)
jq '{id, workspace_id, status, queue_position}' run-created.json
A successful submission returns 201 with a run resource, usually queued. It confirms that the work was accepted, not that a circuit passed. queue_position counts claimable jobs ahead of it; it is not a time estimate. The eventual result can fail or be inconclusive.
Keep RUN_KEY and run-request.json until you receive the response. If a timeout leaves submission uncertain, retry the same POST with the same key and unchanged body. It returns the existing run rather than creating another. A changed body under the same key is refused with 409 idempotency_key_reused. A concurrent request may return 409 idempotency_key_in_flight; briefly back off, then retry the same request. Generate a new key only when intentionally starting new work.
3. Wait and inspect the evidence
Poll with a bounded wait. This example makes up to 60 checks with a two-second pause between them. Each request has a 30-second timeout. Reaching the polling limit leaves the run running; you can inspect it again or cancel it.
for attempt in {1..60}; do
curl --max-time 30 --fail-with-body -sS \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
"$LEONA_API_URL/v1/runs/$RUN_ID" -o run.json || break
RUN_STATUS=$(jq -er '.status' run.json) || break
case "$RUN_STATUS" in
succeeded|failed|cancelled) break ;;
esac
sleep 2
done
jq '{status, verifier_decision, verification_summary, residual_risks, artifact_version_id}' run.json
status describes the job lifecycle. succeeded can still have a verification decision other than pass. Read verification_summary.decision, evidence_strength, checks, reason_code and unverified_claims to understand what was established. A structural pass does not establish physical correctness. A missing summary is a gap in the evidence, not a pass. Preserve the returned qualifications when presenting a result.
Read the stored event log for generated code, sandbox output and individual verification results:
curl --max-time 30 --fail-with-body -sS \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
"$LEONA_API_URL/v1/runs/$RUN_ID/events?after=0" -o events.json
jq '.[] | select(.type == "code.finalized" or .type == "sandbox.result" or .type == "verification.result" or .type == "run.finished")' events.json
Each event has run_id, seq, ts and type, followed by the fields for that event type. Save the highest processed seq; subsequent reads with after=<seq> return later events. An absent event type is not evidence that its step passed.
To cancel your own queued or running run:
curl --max-time 30 --fail-with-body -sS -X POST \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
"$LEONA_API_URL/v1/runs/$RUN_ID/cancel" | jq '{id, status}'
Cancellation is cooperative between executor stages. Cancelling a terminal run returns 409.
Stream events instead of polling
The authenticated SSE endpoint replays stored events and follows new ones. id is the sequence number, event is the event type, and data is the event's JSON.
curl --max-time 120 --fail-with-body -sS -N \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
-H 'Accept: text/event-stream' \
"$LEONA_API_URL/v1/runs/$RUN_ID/events/stream?after=0"
Your client should remember the last processed id. On disconnect, reconnect with that numeric value in Last-Event-ID; it takes precedence over after. For example:
LAST_SEQ=12 # replace with the last event your client processed
curl --max-time 120 --fail-with-body -sS -N \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
-H "Last-Event-ID: $LAST_SEQ" \
"$LEONA_API_URL/v1/runs/$RUN_ID/events/stream"
The example closes its connection after 120 seconds; a curl timeout does not cancel the run. Ignore SSE comment lines beginning with :. The stream closes after run.finished, at its connection-duration limit, or when it discovers a terminal run with no finishing event. Closing alone does not prove success: read the run resource and its verification summary. Use a client that can send bearer headers; the browser's built-in EventSource constructor has no custom-header argument.
Page through runs
Run lists are JSON arrays, scoped to the token's workspace. They accept limit (default 50, clamped to 1–100), an optional status, and a UUID cursor.
curl --max-time 30 --fail-with-body -sS \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
"$LEONA_API_URL/v1/runs?limit=20" -o runs.json
jq '.[] | {id, status}' runs.json
if CURSOR=$(jq -er '.[-1].id // empty' runs.json); then
curl --max-time 30 --fail-with-body -sS \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
"$LEONA_API_URL/v1/runs?limit=20&cursor=$CURSOR" | jq .
fi
Use the last returned ID as the next cursor, preserving the same status filter if one was supplied. Stop on an empty or short page; do not extract a cursor from an empty array. Runs are ordered by descending ID, and the cursor requests lower IDs. There is no next_cursor response wrapper.
Handle refusals and retries
Errors use application/problem+json, with type, title, status, code and request_id. Some include a machine-readable reason and additional fields. Branch on status and reason, and show title to the person using your client. When you report a problem to Leona, include the request_id.
A 422 also has an errors array, with at most 50 entries. Each entry has loc (where the problem is), msg (the rule it broke) and type (a machine-readable name for the rule). loc uses the field names you sent, unknown ones included. In msg, any string value you submitted that is 16 characters or longer, such as a key pasted into the wrong field, is replaced with <submitted value>. Object keys are not replaced, so a key you sent can appear as written in loc or msg.
{
"type": "about:blank",
"title": "validation failed",
"status": 422,
"code": "validation_error",
"request_id": "4f1c2a9e0b7d4c3e8a6b5d2f1e0c9b8a",
"errors": [
{
"loc": ["body", "shots"],
"msg": "Input should be less than or equal to 20000",
"type": "less_than_equal"
}
]
}
| Response | Next action |
|---|---|
| 401 | Check the API origin and token; replace an expired or revoked token through Account. |
| 403 | Check the token's scope and the account's permission for this resource. Repeating the same request will not add authority. |
| 404 | Check the ID, deployment and token workspace. An inaccessible resource can look absent. |
| 409 | Read reason; use the same key/body for an in-flight submission, or a new key for intentionally new work. Other conflicts need their stated recovery. |
| 422 | Correct the request; errors says which field to fix. Run prompts must be 1–20,000 characters; seed is 0–2³¹−1, shots is 1–20,000, and timeout_s, when supplied, is 1–600. Unknown request fields are rejected. |
| 429 | If the response has Retry-After, wait that many seconds and retry. Many 429s do not have it; read reason and title instead. A used-up allowance, such as run_allowance_exhausted or qpu_spend_exhausted, will not come back in a few seconds. GET /v1/usage shows what is left. |
| 503 or a transport failure | Back off with a bounded retry budget; respect Retry-After when supplied. For an uncertain run POST, retain the same idempotency key and body. |
To inspect a refusal without discarding its body, save the headers and response:
curl --max-time 30 -sS -D response.headers -o response.json -w '%{http_code}\n' \
-H "Authorization: Bearer ${LEONA_API_TOKEN:?set LEONA_API_TOKEN}" \
"$LEONA_API_URL/v1/runs/$RUN_ID"
jq . response.json
Headers
| Header | Sent by | Meaning |
|---|---|---|
X-Request-Id | both | Sent on every response except a publicly cacheable one (see below), and repeated in error bodies as request_id. You can send your own (8 to 128 characters: letters, digits, ., _ or -) to match Leona's records to your logs. Any other value is replaced with a generated id. |
X-RateLimit-Limit | API | Requests allowed in the current window of the token's limit, or of your IP address's limit on an anonymous read. |
X-RateLimit-Remaining | API | Requests left in that window. |
X-RateLimit-Reset | API | Seconds until that window resets. |
Retry-After | API | On a 429 or 503 that waiting will clear, the number of seconds to wait before retrying. Not every 429 or 503 has it. |
Idempotency-Key | you | On POST /v1/runs, POST /v1/notebooks and POST /v1/notebooks/{notebook_id}/attempts, makes a retry safe: the same key with the same body returns the first result instead of starting new work. Use a new UUID for each new piece of work. |
The X-RateLimit-* headers describe one window only: the token's own limit on requests made with a personal access token, or your IP address's limit on the anonymous reads listed below. The other limits below, such as circuit checks and the run allowance, are not in them. A 429 from one of those still carries the token or address window's headers, so X-RateLimit-Remaining can be above zero on a 429. On a 429 that has Retry-After, follow it. A response marked Cache-Control: public, such as a catalog read or /v1/openapi.json, carries neither these nor X-Request-Id, because a shared cache may pass it on to other callers.
Limits
| What | Limit | Counted |
|---|---|---|
| Requests with a personal access token | 600 per minute | per token |
Anonymous reads (/v1/catalog, /v1/qapps/public, /v1/certificates, /v1/openapi.json) | 900 per minute | per IP address, for every request to those paths, with or without a token |
Circuit checks (POST /v1/checks/circuit) | 30 per minute | per account, on top of the token limit |
| Requests refused with 401 (a missing, expired or wrong token) | 300 per 5 minutes | per IP address; after that, requests from the address are refused until the window ends |
| Runs | your plan's allowance: 5 on Free, 75 on Plus, 250 on Professional | per account, over a rolling 7 days |
The per-minute limits use a fixed one-minute window, and each API server keeps its own count, so read the X-RateLimit-* headers rather than counting requests yourself. The run allowance is measured in model usage, with each run budgeted at a typical run's share, so a run that needs extra repair work can use more than one. Each run's share comes back seven days after it was spent. GET /v1/usage shows what is left.
Versioning
Everything under /v1 is stable. Additive changes, such as new fields and new endpoints, can happen at any time, so your client should ignore fields it does not recognise. A breaking change would only ship under a new version prefix. It would be announced in advance, and /v1 would keep running alongside it for a transition period.
Python and coding-agent tools
The Python client, MCP server and coding-agent plugin use this API. Installing them currently requires access to the private GitHub repository. The Leona API token supplies API authority; it does not grant GitHub access. The REST examples above remain usable without installing those packages.
Endpoint reference
Every route in the public API, grouped by resource. Open a group to see its routes and the access each one needs.
This list covers only the routes you can call without a token or with a personal access token.
Open the full OpenAPI spec (JSON, no token needed)
Access
- No token
- Anyone can call it, with or without a token.
read- Included in every token. Reads workspace data, plans and estimates.
run- Starts and cancels runs, runs Qapps, checks circuits, generates courses and writes notebooks.
hardware- Sends circuits to real hardware. Granted separately from run.
/v1/algorithm-graphs3 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Graphs | read |
| GET | / | Graph Detail | read |
| GET | / | Latest Evaluation | read |
/v1/artifacts6 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Artifacts | read |
| GET | / | Get Artifact | read |
| GET | / | Get Artifact Document | read |
| GET | / | Projection Notebook State | read |
| GET | / | List Artifact Versions | read |
| GET | / | Get Current Version | read |
/v1/catalog6 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Catalog Entries | No token |
| GET | / | Get Catalog Entry | No token |
| GET | / | Get Catalog Entry Estimate | No token |
| GET | / | Get Catalog Entry Profile | No token |
| GET | / | List Catalog Estimates | No token |
| GET | / | List Catalog Profiles | No token |
/v1/certificates1 route
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | Public Certificate Assertion | No token |
/v1/checks1 route
| Method | Path | What it does | Access |
|---|---|---|---|
| POST | / | Check Circuit | run |
/v1/comments3 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Comments | read |
| GET | / | List My Mentions | read |
| GET | / | List Mentionable People | read |
/v1/courses10 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Courses | read |
| GET | / | Get Course | read |
| GET | / | List Course Certificates | read |
| GET | / | List Course Cohorts | read |
| GET | / | Export Course | read |
| POST | / | Generate Course | run |
| GET | / | Get Course Gradebook | read |
| GET | / | Export Course Gradebook | read |
| GET | / | Get Course Grading Coverage | read |
| GET | / | List Course Turns | read |
/v1/estimates2 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| POST | / | Inspect Interchange | read |
| POST | / | Estimate Logical | read |
/v1/functions2 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Function Executions | read |
| GET | / | Get Function Execution | read |
/v1/me1 route
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | Get the signed-in user | read |
/v1/notebook-templates1 route
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List notebook templates | read |
/v1/notebooks15 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Notebooks | read |
| POST | / | Create NotebookAccepts an Idempotency-Key header | run |
| POST | / | Import Notebook | run |
| GET | / | Get Notebook | read |
| POST | / | Grade Notebook AttemptAccepts an Idempotency-Key header | run |
| GET | / | Get Notebook Grades | read |
| POST | / | Rerun Notebook | run |
| GET | / | List Notebook Share Links | read |
| GET | / | List Notebook Turns | read |
| POST | / | Create Notebook Turn | run |
| GET | / | List Notebook Versions | read |
| POST | / | Author Notebook Version | run |
| GET | / | Get Notebook Version | read |
| GET | / | Circuit Lineage | read |
| GET | / | Export Notebook Version | read |
/v1/notifications1 route
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Notifications | read |
/v1/plans1 route
| Method | Path | What it does | Access |
|---|---|---|---|
| POST | / | Plan a problem's method pathway and cost | read |
/v1/presence1 route
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Presence | read |
/v1/qapps11 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Qapps | read |
| GET | / | List Qapp Examples | read |
| GET | / | Qapp Execution | read |
| GET | / | List Public Qapps | No token |
| GET | / | Public Qapp | No token |
| GET | / | Qapp Detail | read |
| GET | / | Qapp Activity | read |
| GET | / | Qapp Usage | read |
| GET | / | List Qapp Versions | read |
| POST | / | Execute Qapp | run |
| GET | / | Qapp Progress | read |
/v1/qpu7 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List QPU backends | read |
| GET | / | Get a QPU backend's queue status | read |
| POST | / | Estimate a QPU run's cost | read |
| GET | / | List QPU run records | read |
| GET | / | Get a QPU run record | read |
| GET | / | Check whether you can submit to a QPU | read |
| POST | / | Submit a circuit to a QPU | hardware |
/v1/runs9 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | List Runs | read |
| POST | / | Create RunAccepts an Idempotency-Key header | run |
| GET | / | Run Capabilities | read |
| GET | / | Get Run | read |
| POST | / | Cancel Run | run |
| GET | / | Get Conversation | read |
| GET | / | List Run Events | read |
| GET | / | Stream Run Events | read |
| GET | / | Get Conversation Sharing | read |
/v1/usage1 route
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | Get usage and run allowance | read |
/v1/workspace4 routes
| Method | Path | What it does | Access |
|---|---|---|---|
| GET | / | Get Workspace | read |
| GET | / | List Workspace Folders | read |
| GET | / | List Workspace Projects | read |
| GET | / | List Project Shares | read |