Skip to main content

Set up a workspace SDK

Start with a read-only identity check, then add the permissions needed by your automation. Both SDKs call the workspace API used by the product.

Prepare your environment​

Download and verify the signed discovery bundle, then extract it. Use Python 3.12 or newer or Node.js 22 or newer. These examples need no additional packages. Keep the reviewed SDK version pinned with your automation.

Ask a workspace administrator for a dedicated viewer API credential for the initial check. Set QSCAN_ENDPOINT to https://qscan.dev and inject QSCAN_TOKEN using your environment or secret manager. Do not put tokens in command arguments, source files, screenshots or chat. These environment names belong to the examples; the SDK constructors receive endpoint and token explicitly.

Python: confirm your workspace​

Save this as verify_workspace.py in the extracted bundle root:

import os
from sdk.python.quantum_ready import QuantumReady

client = QuantumReady(
os.environ["QSCAN_ENDPOINT"],
os.environ["QSCAN_TOKEN"],
)
print(client.me()["organization"]["name"])

Run python verify_workspace.py. Confirm the printed organization name before performing writes. This check neither executes scans nor reads provider credentials.

JavaScript: confirm your workspace​

Save this as verify-workspace.mjs in the extracted bundle root:

import { QuantumReady } from './sdk/javascript/index.mjs';

const client = new QuantumReady({
endpoint: process.env.QSCAN_ENDPOINT,
token: process.env.QSCAN_TOKEN,
});
console.log((await client.me()).organization.name);

Run node verify-workspace.mjs. A successful response confirms workspace access at that time, not provider connectivity or agent health.

Choose the next workflow​

  • Repository scanning: configure scoped access, submit a scan, follow progress and export SARIF.
  • Database discovery: select a locally approved connection UUID, queue a managed job and inspect coverage.
  • Risk profiles: inspect immutable standards mappings, preview tenant-defined scoring and retain recalculation history.
  • Cloud automation: review resources and trust, test access, run discovery and read results.
  • Capture analysis: prepare an upload, review consent and confirm processing and cleanup.
  • Agent setup: traverse the full fleet and inspect host acknowledgements.
  • Signed webhooks: configure a receiver and verify signatures before processing events.
  • CI scanning: scan locally without a workspace token; use a separate ingestor credential for optional evidence upload.

A viewer reads permitted metadata. An analyst can submit authorized discovery; an administrator manages workspace connections and agents. An ingestor uploads standalone observations. Agent enrollment credentials belong to their assigned host, and platform operator credentials are for provisioning. Never replace a denied credential with a broader one automatically. Check the OpenAPI reference for each operation's requirements.

Pagination and uncertain responses​

Use all-page iterators where available, or follow the documented cursor until null. A page is not the entire inventory. Lists reflect live data; concurrent changes may require restarting traversal.

Retain request IDs and identical input when replaying an operation after a lost response. Keep expected revisions for optimistic edits. The SDKs do not invent new request IDs or retry mutations automatically. A 409 requires inspection of the current resource or original operation. Do not create a replacement job just because its response was lost.

Troubleshoot the first check​

  • Missing environment variable: configure the environment of the process running the script or assistant host, then restart that process.
  • 401: check expiry, revocation and credential type. Do not print the token.
  • 403: inspect the required role and intended scope. Preserve the original denial.
  • Wrong organization name: stop before writing and obtain the intended workspace credential.
  • Import not found: keep SDK folders together and save the example in the extracted bundle root. JavaScript uses an .mjs file and the relative path above.
  • 429 or timeout: inspect retry guidance and preserve operation identity. A successful identity check does not prove a later write completed.

Agent SSH inventory​

These methods ship with platform 0.51.353 and source scanner 0.26.70. Use the bundled agent for normal deployments; this API is for integrations that already manage scanner execution and job leases.

JavaScript claimJob(claimId, instanceId, options) and Python claim_job(claim_id, instance_id, *, job_id=None, pool_id=None, ssh_inventory=None) accept an optional exact job or remote pool selection. Do not select both. JavaScript option names are jobId, poolId, and sshInventory.

Inventory preferences contain profile: "host-keys-v1" (five connections) or profile: "host-keys-v2" (ten connections, source scanner 0.26.90), a source name, and a pins object mapping approved SSH endpoints to SHA256 fingerprints (at most 256 entries). Retain the same preferences, claim ID and process ID when recovering a lost response. Remote scans additionally require pool/run approval and the agent's local ceiling. V2 requires sshHostCertificateInventory: true in pool policy; the existing sshHostKeyInventory flag authorizes v1 only. Run selection and claim preferences must name the same profile. A preference does not authorize scanning arbitrary devices or expand a baseline run.

After claiming, execute the qualified scanner only against the returned job's scope and profile. Upload its complete raw proof with JavaScript reportSshInventory(job.id, job.leaseToken, report) or Python report_ssh_inventory(job_id, lease_token, report). Do not flatten the proof into ordinary observations or manufacture host identity, hosted execution or remote provenance. Keep the lease current during scanning and upload.

The receipt contains accepted and assetIds; a repeated identical upload under the current lease does not duplicate evidence. Complete the job separately using that accepted count and partial when report.analysisComplete is false. An expired or revoked lease is a stop condition, not permission to claim another job and reuse old evidence. The SDKs perform one request per call and do not silently retry these operations. See the remote scan guide for connection budgets, baseline-only pin trust and partial coverage interpretation.

SIEM automation and account boundaries​

The JavaScript SDK exposes siemAccess, siemConnections, createSiemConnection, siemConnectionAction, siemDeliveries, siemDelivery and retrySiemDelivery. Python provides the corresponding snake-case methods. These use the workspace credential supplied to the constructor. A browser's selected workspace does not retarget that credential. Check siemAccess() / siem_access() before writes; a viewer API key does not inherit a person's delegated browser permission.

Connection actions are test, state, subscriptions, credentials, rotate, revoke and delete. Supply the action's documented body from the API reference; revision and credential-version checks are not filled in automatically. For example:

await client.siemConnectionAction(connectionId, 'test');
// Inspect delivery history and the receiver before enabling export.
await client.siemConnectionAction(connectionId, 'state', { enabled: true });
client.siem_connection_action(connection_id, "test")
# Inspect delivery history and the receiver before enabling export.
client.siem_connection_action(connection_id, "state", {"enabled": True})

Retry methods accept an explicit approval body. Only after checking an unknown Splunk outcome should a caller pass {"confirmDuplicateRisk": true}. The SDK does not add this confirmation or bypass server-side retry limits. A successful retry response means queued, not delivered. See SIEM setup and diagnostics.

Workspace selection, membership invitation acceptance and identity handoff inspection use verified browser sessions under /api/auth; they are deliberately not bearer-SDK operations. Use the product UI or the documented browser-session API, with its origin and current-workspace constraints. Never copy browser session cookies into automation. Existing SDK versions do not acquire these methods without an updated SDK distribution; pin and verify the version you install.