SellMyCode Developers
Author API

Item media

Change an item's images through the API: the thumbnail, the preview image (the large picture on the item page, also used when the item is shared) and the screenshot gallery. It takes two steps:

  1. Upload each new image with POST /media/uploads. It is checked and stored privately for 24 hours, and you get an upload id back.
  2. Send one PUT /media that says what the item should show: new uploads, current screenshots you keep, in the order you want.

The PUT is one change, like a PATCH: it waits for review unless your account publishes updates directly, and an item has at most one update waiting (send replace_pending: true to replace it).

ℹ️

Note: Screenshots have no captions on SellMyCode, so there is no caption field.

#Read the current media

GET/api/items/{id}/media

Needs items:read. Also shows what the waiting update would change, and the image rules of the item's category.

curl https://sellmycode.net/api/items/123/media \
  -H "Authorization: Bearer YOUR_API_KEY"

#Upload an image

POST/api/items/{id}/media/uploads

Needs items:upload. Send the image as multipart/form-data, one image per request.

Parameter Type Description
file required file JPG or PNG, at most 10 MB. The type is read from the file itself
slot required string thumbnail, preview_image or screenshot

The same checks as the upload fields in Workspace:

Slot Rule
thumbnail At least the category's thumbnail size (see rules). Padded to a square and resized
preview_image At least 1120Γ—630 and landscape 16:9. Within Β±2 % it is kept as it is, up to Β±10 % it is cropped to 16:9, beyond that it is refused (wrong_ratio)
screenshot At least 600 px on the longer side

Images are converted to WebP when the site does that for web uploads. Uploads you do not use expire after 24 hours; you can have 30 unused images at a time (429 too_many_uploads).

curl -X POST https://sellmycode.net/api/items/123/media/uploads \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F slot=screenshot \
  -F file=@dashboard.png

#Set the media

PUT/api/items/{id}/media

Needs items:write. Send only what changes.

Parameter Type Description
thumbnail string Upload id of a thumbnail upload
preview_image string Upload id of a preview_image upload (items with an image preview only)
screenshots array The whole gallery, in order. Each entry is {"keep": position} (a current screenshot, positions from GET /media) or {"upload": "id"} (a screenshot upload). At least 1, at most the category's max_screenshots
replace_pending boolean Replace the update that is waiting for review

Removing a screenshot = leaving it out of the list. Reordering = listing the entries in the new order. A gallery identical to the current one changes nothing (mode: unchanged).

curl -X PUT https://sellmycode.net/api/items/123/media \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"screenshots":[{"upload":"k3Jx9Qw2LmPa"},{"keep":0},{"keep":1}]}'

mode is published (live now, HTTP 200) or review (waiting for approval, HTTP 202). Follow the review with Review state or the item.update_* webhooks. When the change goes live, the images it no longer uses are deleted; images you kept stay as they are. If the update is rejected, its new uploads are deleted and the item keeps its current images.

#Errors

Code HTTP Meaning
invalid_type 422 Not a JPG or PNG
too_large 413 Over 10 MB
too_small / wrong_ratio 422 Below the minimum size, or not 16:9 (preview)
slot_unavailable 422 The item's category has no gallery, or the item uses a video/audio preview
too_many_uploads 429 30 unused images are waiting
upload_not_found 422 Unknown or expired upload id, or an upload made for another item
wrong_slot 422 e.g. a screenshot upload sent as thumbnail
invalid_screenshot / duplicate_screenshot 422 An entry without exactly one of keep/upload, a position that does not exist, or the same image twice
too_many_screenshots 422 More than the category allows
pending_update 409 An update is already waiting; send replace_pending: true to replace it
Was this page helpful?