Use standard fetch against the experimental Cloud API; VisionScan does not publish a native npm scanner package.
SDK 0.1.0-RC5 · Experimental
Status: Experimental
These examples call the same authenticated upload, job, and status HTTP API. They are REST clients, not native VisionScan scanner SDKs. VisionScan does not publish Cloud client packages to PyPI, npm, NuGet, Maven Central, or RubyGems in RC2.
The service contract is:
POST /v1/uploads with an idempotency key, base64 image, and allowlisted content type.
POST /v1/jobs with an idempotency key, one or more returned upload IDs, and a scan profile.
GET /v1/jobs/{jobId} until completed or failed .
Tenant and site scope come from the verified bearer token. Never send or accept a tenant override in the JSON body.
HTTP contract reference
Every language on this page calls the same three contracts:
Cross-tenant/unknown upload denial, idempotency conflict, invalid profile, or quota failure
GET /v1/jobs/{jobId}
Bearer token in the owning tenant/site scope
Pending, completed, or failed status with receipt/error metadata
Cross-tenant data is never exposed; ENGINE_ADAPTER_UNAVAILABLE is failed, not an empty successful scan
Client code must reject non-2xx responses and unknown response shapes. A retry of an identical request retains its idempotency key; changed content receives a new key. The machine-readable request/status schemas and contracts/sdk-public-contracts.json are the frozen contract sources.
Common environment
Set VISIONSCAN_CLOUD_URL and VISIONSCAN_ACCESS_TOKEN in the process secret store. Loopback development may use the explicitly documented --dev token format. Production requires an RS256 token with bounded timestamps and the cloud-scan entitlement.
Use image/png , image/jpeg , or image/webp . Enforce local image-size limits before base64 encoding. Every retry of an identical request should retain its original idempotency key; changed content needs a new key.
JavaScript and TypeScript
Node.js 20 includes fetch . Keep the token on a trusted server, not in public browser code.
Add an AbortController timeout and bounded retry policy in production.
Error handling
Condition
Client action
401 or 403
Refresh credentials and confirm the cloud-scan entitlement. Do not retry indefinitely.
409 idempotency conflict
Reuse the key only with the original payload or generate a new key for changed content.
429 or quota error
Apply bounded backoff and respect the tenant quota.
ENGINE_ADAPTER_UNAVAILABLE
Treat the job as failed. The experimental host has no production engine adapter.
Unknown or invalid response shape
Fail closed and preserve non-sensitive correlation metadata for support.
The local development service can prove authentication, tenant isolation, persistence, idempotency, quotas, and job lifecycle. Its empty development receipt is not evidence of a barcode decode. Production certification requires an approved Linux engine adapter and deployment artifact.
These are the callable methods and HTTP operations used by this guide. Inputs, results, lifecycle rules, and denial behavior are part of the versioned customer contract.
Cloud upload contract
Upload bytes are authenticated, bounded, MIME-checked, idempotent, and tenant-scoped.
POST /v1/uploads
http
Persist one validated image and return a tenant-scoped upload identifier.
Inputs for POST /v1/uploads
Input
Type
Required
Meaning
Authorization
Bearer token
Yes
Production RS256 token with bounded time claims and cloud-scan entitlement.
idempotencyKey
UUID/string
Yes
Tenant-scoped key reused only for an identical retry.
contentBase64
base64 string
Yes
Locally bounded PNG, JPEG, or WebP bytes.
contentType
string
Yes
image/png, image/jpeg, or image/webp matching the file magic bytes.
Result
2xx JSON containing uploadId and non-sensitive upload metadata.
Lifecycle
Upload before creating a job; retain the idempotency key for retries of the same bytes.
Trust boundary
Tenant and site come only from the verified token; request bodies cannot override tenant scope.
Failure behavior
401/403 for invalid or unentitled identity.
409 for a reused key with different content.
4xx for invalid MIME, magic bytes, base64, or size; 429 for quota limits.
Cloud job creation contract
A job references same-tenant uploads and selects a bounded scan profile.
POST /v1/jobs
http
Create an asynchronous scan job from one or more previously accepted uploads.
Inputs for POST /v1/jobs
Input
Type
Required
Meaning
idempotencyKey
UUID/string
Yes
Tenant-scoped key for identical job retries.
uploadIds
string[]
Yes
Existing upload IDs owned by the authenticated tenant and site.
profile
string
Yes
An allowlisted profile such as still-image-dense.
callback
HTTPS URL
No
Optional policy-validated callback; production delivery requires the documented callback controls.
Result
2xx JSON containing jobId, queued status, and correlation metadata.
Lifecycle
Create after uploads succeed, then poll status until completed or failed.
Trust boundary
Callbacks reject non-HTTPS and non-global destinations, pin validated addresses, follow no redirects, and HMAC-sign payloads.