Hello Penpot community,
We are automating design updates using the Penpot API and are trying to programmatically update the image fill of a rectangle shape (e.g., a “hero image” layer) in a design file. Our workflow is:
Upload a new image using the /api/rpc/command/create-file-media-object-from-url endpoint.
Add the resulting image object to the file’s media section using an add-media change.
Update the target shape’s fills property using a mod-obj change, setting fillImage.id to the new image’s id (not mediaId), and providing all required fields (id, width, height, mtype, name, keepAspectRatio).
Despite following the schema and confirming the image is present in the file’s media section, we consistently receive this error when updating the fill:
:type :server-error
:code :assertion
:hint "invalid shape found after applying changes on file ..."
:explain "Errors:
[{:path [1 :rect :malli.core/in :fills 0 0 :fill-image :id 0],
:in [:fills 0 :fill-image :id],
:schema :app.common.schema/uuid,
:value \"<image-id>\"}]"
The id we use matches the one in the media section.
We use the latest revn after each change.
The error persists even after restarting the server and trying different images.
Has anyone successfully updated a shape’s image fill via the API? Are there any undocumented requirements or known issues with this workflow?
Any advice or working examples would be greatly appreciated!
Thank you.