TypeScript quickstart
Run a server-side Skin Analysis with the published TypeScript SDK.
This guide uploads one image, submits a Skin Analysis job, and reads its result with
@morphiaone/sdk. It runs on Node.js 20 or newer. Working in Python? The
Python SDK guide opens with the same
quickstart.
Release status. API 1.0.0-rc.1 is a release candidate: request and response shapes may still change before the stable release. SDK 0.12.0 is published as a Developer Preview (@morphiaone/sdk on npm and morphiaone on PyPI).
You need an API key first; Get access takes you through it.
Use a pk_test_ key while you build where test mode is
available to your account; otherwise use the live key the Platform gives you.
Install the SDK
To run the TypeScript file directly on Node.js 20, add tsx to your project and run
the file with it:
Keep both values in your server environment. Never put an API key in browser code, mobile app bundles, source control, or a chatbot client.
Upload, submit, and wait
Save this as quickstart.mts in your server-side Node.js project. Replace face.jpg
with an image you are allowed to process.
jobs.wait polls using the server’s Retry-After and resolves with a succeeded Job.
If processing fails, it throws ProcessingError. A timeout stops local waiting; it does
not cancel work already accepted by the server. Store the Job id if your application
needs to resume later. See Jobs and outputs.
If the key check fails
whoami needs no scope and charges nothing, so it fails for only these reasons:
Once whoami prints test or live and the key’s scopes, a later 403
INSUFFICIENT_SCOPE means the key lacks that product’s scope. See
Status codes for every other status.
Make retries safe
The idempotencyKey above comes from the order that owns the work. Keep that key for
every retry of the same logical request. Use a new key for a different request. If you
omit it, the SDK creates a key for that call and reuses it across its own transport
retries, but that key cannot survive an application restart.
See Idempotency for replay behavior and Retries and backoff for retryable failures.
Handle errors by type and code
Branch on code, not the human-readable message. An HTTP success for the submit means
the Job was accepted; a processing failure is reported by the Job and is distinct from
an HTTP error. See Error handling.
Continue with another product or language
- Full TypeScript SDK guide covers Makeup, Hair, Assets, Usage, result images, deadlines, and error classes.
- Python SDK guide shows the synchronous and asynchronous clients.
- REST API onboarding explains each HTTP step.
- Product availability lists current product status.