Skip to main content

Use this pre-built prompt to get started faster.

Open in Cursor

Prerequisites

  • An API key. Create one and keep the sm_ value.
  • A PSD with at least one visible smart object, at a public URL. Preparing a PSD covers what it needs.

Guide

1

Add a client

There is no gem to install. Open Rails credentials with bin/rails credentials:edit, put the key there, then let one service object carry the header, the timeout and the failure.
config/credentials.yml.enc
app/services/sudomock.rb
A failed call still answers with a JSON body, and error_code is what you branch on. Errors lists the codes and says which ones are worth retrying.
2

Upload once, then render from a controller

Upload the PSD once to learn the mockup UUID and the name of every slot inside it. This belongs in a rake task, not in a request, and Upload a PSD covers every field it takes.
lib/tasks/sudomock.rake
Those UUIDs stay valid for every later render, so they belong in credentials, in the environment, or on the product row they describe. The render call takes them with the artwork and answers with the finished file. Wire the action into config/routes.rb and post the artwork URL to it.
app/controllers/mockups_controller.rb
One render answers with one image, so print_files carries a single entry whatever number of layers the request filled. A long render does not have to hold the connection open: set is_async to true, read job_id from the 202, and follow it from an Active Job worker.

Next steps

Render a PSD mockup

Every field the render call takes, and everything it answers with.

Create a mockup from a PSD

The upload call, field by field.

Retrieve a single job

Follow an asynchronous render through to its finished file.

Fit and blend modes

What fit, fill and crop each do to the artwork.

Photo mockups

Render from a product photo when there is no PSD.

Webhooks

Get a signed callback when an asynchronous render finishes.