Skip to main content
This page takes a Photoshop file to a finished image from a Node.js service: one upload you run once, then a route that renders on demand.

Hand this to a coding agent before it writes SudoMock calls in Node.

Open in Cursor

Prerequisites

  • Node 20 or later. The files below are ESM, so use a .mjs file or set "type": "module" in your package.json. A CommonJS project can reach the same client with const { SudoMock } = require('sudomock').
  • An API key. Create one, then export it. Keys begin with sm_ and travel in the x-api-key header.
  • 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 curl first.

Guide

1

Install

Put the key in the environment rather than in the code. The client reads 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.
upload.mjs
Run it, then keep the two UUIDs it prints:
One upload serves every render after it. A template you uploaded last month renders today without being sent again.
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.
server.mjs
Start it with node server.mjs and send it an artwork:
The answer carries 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.
A render that takes a while does not have to hold the request open. Pass isAsync as true, and client.renders.create resolves with a job instead. Await client.jobs.waitForJob(job.jobId), or let a webhook call you back.
4

Handle the failures

Everything the client raises is a 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.
Error codes lists every 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.