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.

ScopeUseful operations
readRead workspace resources; request workflow plans and resource estimates. Always included.
runStart and cancel runs, execute Qapps, check circuits, and use the permitted notebook write routes.
hardwareSubmit 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"
    }
  ]
}
ResponseNext action
401Check the API origin and token; replace an expired or revoked token through Account.
403Check the token's scope and the account's permission for this resource. Repeating the same request will not add authority.
404Check the ID, deployment and token workspace. An inaccessible resource can look absent.
409Read 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.
422Correct 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.
429If 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 failureBack 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

HeaderSent byMeaning
X-Request-IdbothSent 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-LimitAPIRequests allowed in the current window of the token's limit, or of your IP address's limit on an anonymous read.
X-RateLimit-RemainingAPIRequests left in that window.
X-RateLimit-ResetAPISeconds until that window resets.
Retry-AfterAPIOn a 429 or 503 that waiting will clear, the number of seconds to wait before retrying. Not every 429 or 503 has it.
Idempotency-KeyyouOn 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

WhatLimitCounted
Requests with a personal access token600 per minuteper token
Anonymous reads (/v1/catalog, /v1/qapps/public, /v1/certificates, /v1/openapi.json)900 per minuteper IP address, for every request to those paths, with or without a token
Circuit checks (POST /v1/checks/circuit)30 per minuteper account, on top of the token limit
Requests refused with 401 (a missing, expired or wrong token)300 per 5 minutesper IP address; after that, requests from the address are refused until the window ends
Runsyour plan's allowance: 5 on Free, 75 on Plus, 250 on Professionalper 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
MethodPathWhat it doesAccess
GET/v1/algorithm-graphsList Graphsread
GET/v1/algorithm-graphs/{graph_id}Graph Detailread
GET/v1/algorithm-graphs/{graph_id}/evaluationLatest Evaluationread
/v1/artifacts6 routes
MethodPathWhat it doesAccess
GET/v1/artifactsList Artifactsread
GET/v1/artifacts/{artifact_id}Get Artifactread
GET/v1/artifacts/{artifact_id}/documentGet Artifact Documentread
GET/v1/artifacts/{artifact_id}/notebookProjection Notebook Stateread
GET/v1/artifacts/{artifact_id}/versionsList Artifact Versionsread
GET/v1/artifacts/{artifact_id}/versions/currentGet Current Versionread
/v1/catalog6 routes
MethodPathWhat it doesAccess
GET/v1/catalog/entriesList Catalog EntriesNo token
GET/v1/catalog/entries/{slug}Get Catalog EntryNo token
GET/v1/catalog/entries/{slug}/estimateGet Catalog Entry EstimateNo token
GET/v1/catalog/entries/{slug}/profileGet Catalog Entry ProfileNo token
GET/v1/catalog/estimatesList Catalog EstimatesNo token
GET/v1/catalog/profilesList Catalog ProfilesNo token
/v1/certificates1 route
MethodPathWhat it doesAccess
GET/v1/certificates/{certificate_id}Public Certificate AssertionNo token
/v1/checks1 route
MethodPathWhat it doesAccess
POST/v1/checks/circuitCheck Circuitrun
/v1/comments3 routes
MethodPathWhat it doesAccess
GET/v1/commentsList Commentsread
GET/v1/comments/mentionsList My Mentionsread
GET/v1/comments/peopleList Mentionable Peopleread
/v1/courses10 routes
MethodPathWhat it doesAccess
GET/v1/coursesList Coursesread
GET/v1/courses/{course_id}Get Courseread
GET/v1/courses/{course_id}/certificatesList Course Certificatesread
GET/v1/courses/{course_id}/cohortsList Course Cohortsread
GET/v1/courses/{course_id}/export.zipExport Courseread
POST/v1/courses/{course_id}/generateGenerate Courserun
GET/v1/courses/{course_id}/gradebookGet Course Gradebookread
GET/v1/courses/{course_id}/gradebook.csvExport Course Gradebookread
GET/v1/courses/{course_id}/gradingGet Course Grading Coverageread
GET/v1/courses/{course_id}/turnsList Course Turnsread
/v1/estimates2 routes
MethodPathWhat it doesAccess
POST/v1/estimates/interchangeInspect Interchangeread
POST/v1/estimates/logicalEstimate Logicalread
/v1/functions2 routes
MethodPathWhat it doesAccess
GET/v1/functions/executionsList Function Executionsread
GET/v1/functions/executions/{execution_id}Get Function Executionread
/v1/me1 route
MethodPathWhat it doesAccess
GET/v1/meGet the signed-in userread
/v1/notebook-templates1 route
MethodPathWhat it doesAccess
GET/v1/notebook-templatesList notebook templatesread
/v1/notebooks15 routes
MethodPathWhat it doesAccess
GET/v1/notebooksList Notebooksread
POST/v1/notebooksCreate NotebookAccepts an Idempotency-Key headerrun
POST/v1/notebooks/importImport Notebookrun
GET/v1/notebooks/{notebook_id}Get Notebookread
POST/v1/notebooks/{notebook_id}/attemptsGrade Notebook AttemptAccepts an Idempotency-Key headerrun
GET/v1/notebooks/{notebook_id}/gradesGet Notebook Gradesread
POST/v1/notebooks/{notebook_id}/runRerun Notebookrun
GET/v1/notebooks/{notebook_id}/share-linksList Notebook Share Linksread
GET/v1/notebooks/{notebook_id}/turnsList Notebook Turnsread
POST/v1/notebooks/{notebook_id}/turnsCreate Notebook Turnrun
GET/v1/notebooks/{notebook_id}/versionsList Notebook Versionsread
POST/v1/notebooks/{notebook_id}/versionsAuthor Notebook Versionrun
GET/v1/notebooks/{notebook_id}/versions/{seq}Get Notebook Versionread
GET/v1/notebooks/{notebook_id}/versions/{seq}/circuitCircuit Lineageread
GET/v1/notebooks/{notebook_id}/versions/{seq}/export.ipynbExport Notebook Versionread
/v1/notifications1 route
MethodPathWhat it doesAccess
GET/v1/notificationsList Notificationsread
/v1/plans1 route
MethodPathWhat it doesAccess
POST/v1/plansPlan a problem's method pathway and costread
/v1/presence1 route
MethodPathWhat it doesAccess
GET/v1/presenceList Presenceread
/v1/qapps11 routes
MethodPathWhat it doesAccess
GET/v1/qappsList Qappsread
GET/v1/qapps/examplesList Qapp Examplesread
GET/v1/qapps/executions/{execution_id}Qapp Executionread
GET/v1/qapps/publicList Public QappsNo token
GET/v1/qapps/public/{slug}Public QappNo token
GET/v1/qapps/{qapp_id}Qapp Detailread
GET/v1/qapps/{qapp_id}/activityQapp Activityread
GET/v1/qapps/{qapp_id}/usageQapp Usageread
GET/v1/qapps/{qapp_id}/versionsList Qapp Versionsread
POST/v1/qapps/{slug}/executionsExecute Qapprun
GET/v1/qapps/{slug}/progressQapp Progressread
/v1/qpu7 routes
MethodPathWhat it doesAccess
GET/v1/qpu/backendsList QPU backendsread
GET/v1/qpu/backends/{device_id}/queueGet a QPU backend's queue statusread
POST/v1/qpu/estimatesEstimate a QPU run's costread
GET/v1/qpu/runsList QPU run recordsread
GET/v1/qpu/runs/{record_id}Get a QPU run recordread
GET/v1/qpu/submission-gateCheck whether you can submit to a QPUread
POST/v1/qpu/submissionsSubmit a circuit to a QPUhardware
/v1/runs9 routes
MethodPathWhat it doesAccess
GET/v1/runsList Runsread
POST/v1/runsCreate RunAccepts an Idempotency-Key headerrun
GET/v1/runs/capabilitiesRun Capabilitiesread
GET/v1/runs/{run_id}Get Runread
POST/v1/runs/{run_id}/cancelCancel Runrun
GET/v1/runs/{run_id}/conversationGet Conversationread
GET/v1/runs/{run_id}/eventsList Run Eventsread
GET/v1/runs/{run_id}/events/streamStream Run Eventsread
GET/v1/runs/{run_id}/sharingGet Conversation Sharingread
/v1/usage1 route
MethodPathWhat it doesAccess
GET/v1/usageGet usage and run allowanceread
/v1/workspace4 routes
MethodPathWhat it doesAccess
GET/v1/workspaceGet Workspaceread
GET/v1/workspace/foldersList Workspace Foldersread
GET/v1/workspace/projectsList Workspace Projectsread
GET/v1/workspace/projects/{project_id}/sharesList Project Sharesread