Hand this to a coding agent before it writes SudoMock calls in Node.
Prerequisites
- Node 20 or later. The files below are ESM, so use a
.mjsfile or set"type": "module"in yourpackage.json. A CommonJS project can reach the same client withconst { SudoMock } = require('sudomock'). - An API key. Create one, then export it. Keys begin
with
sm_and travel in thex-api-keyheader. - A PSD reachable over HTTPS. Preparing a PSD covers what to check before the first upload.
- If the API is new to you, the Quickstart runs the same two
requests with
curlfirst.
Guide
1
Install
SUDOMOCK_API_KEY when you construct it with no argument.2
Upload the template once
Uploading returns the layers you can address later, each with its own
UUID. This belongs in your setup, not in the path that serves requests.Run it, then keep the two UUIDs it prints:
upload.mjs
3
Render from a route
The route below takes an artwork URL and answers with the rendered image.
It uses the built-in HTTP server, so nothing beyond the client is needed.Start it with The answer carries
server.mjs
node server.mjs and send it an artwork:url, the finished image. The same value sits in
render.printFiles, paired with the smart object it was placed into.
How the artwork meets that area is set by asset.fit, described in
Fit and blend modes.4
Handle the failures
Everything the client raises is a Error codes lists every
SudoMockError carrying status and
code, and the subclasses let you branch without reading message text:
AuthenticationError for a key the account no longer honours,
CreditError when the render cannot be paid for, ValidationError for a
body the API rejected, and RateLimitError when calls arrive faster than
the account allows.Only the last one is worth repeating, and it says how long to wait:An account still in trial renders up to 1024 px wide. An
imageSize
above that answers OUTPUT_RESOLUTION_LIMIT rather than quietly
shrinking the image, so the width you asked for is the width you get.code, its status, and whether
retrying it can help.Next steps
SDK reference
Every resource on the client, in Node and in Python.
Webhooks
Get called back the moment a background render finishes.