Skip to main content
SudoMock renders a mockup from a Photoshop template you upload once. This page wires that into a Django project: the key lives in settings.py, a management command uploads the template, and a view returns the finished image.

Guide an agent through a SudoMock render in Django.

Open in Cursor

Prerequisites

  • A Django project with an app you can add a view and a command to. The app is called mockups below.
  • Python 3.9 or later, which the client library requires.
  • An API key. Keys start with sm_ and travel in the x-api-key header. See API keys.
  • A public URL to the PSD you want to render, and a public URL to the artwork that goes into it.
If you have not called the API before, Quickstart shows the same two requests as plain HTTP.

Guide

1

Install the client

2

Put the key in settings

Three values belong in the environment: the key, and the two uuids the next step prints. Reading them with os.environ means a missing value stops the project at startup rather than on the first render.
Build the client once and import it where you need it. It reads SUDOMOCK_API_KEY by itself when no key is passed, but taking it from settings keeps every secret on one page.
3

Upload the template once

A PSD is uploaded once and rendered many times, so this belongs in a management command rather than in request handling.
Run it:
Those two uuids are the SUDOMOCK_MOCKUP_UUID and SUDOMOCK_SMART_OBJECT values from the previous step.
4

Render from a view

The view takes an artwork URL, fills the smart object with it, and answers with the rendered image.
csrf_exempt is there because this route is called by your own backend. A route a browser form posts to keeps the token instead.
5

Call it and read the answer

A success answers with the URL of the finished image, taken from render.url. One render answers with one composited image, so render.print_files carries a single entry and render.url is the shortcut to it.A failure answers with the code the API returned:
That code means the requested width is above what the account may render. Every code, and the statuses worth retrying, are in Errors.
A render holds the request open while it runs. Pass is_async=True to get a job id back at once and let a webhook tell you when the image is ready.

Next steps

SDKs

Every resource the Python client exposes, and the Node one.

Errors

Each error_code, and which statuses are worth retrying.

Webhooks

Let a finished render call your Django route back.