Skip to content

Upload Media

Stores one image or video against a section and returns the path to record in its options. This endpoint is REST only — a binary upload cannot be carried over GraphQL.

Uploading does not change what the section shows. The file becomes part of the section when its path appears in the options sent to Stage edits or Update section.

Endpoint

MethodPathPurpose
POST/api/admin/appearance/sections/{id}/mediaUpload media for a section

Send as multipart/form-data.

Path parameters

ParameterDescription
idSection the media belongs to.

Request body

FieldTypeRequiredDescription
filebinaryYesThe image or video to store.

Response fields

FieldTypeDescription
sectionIdintegerSection the file was stored against.
pathstringStored path to record in the section's options.
typestringimage or video, decided from the file itself.
messagestringConfirmation text.

Use cases

  • Add a slide to an image carousel — upload, then stage options carrying the returned path alongside the slide's link and title.

Best practices

  • Record the returned path verbatim. It is the value the storefront resolves; rewriting or re-hosting it breaks the image.
  • Files nothing points at are cleaned up. An upload whose path never reaches the section's published or staged options is removed when the section is next saved, so upload as part of an edit rather than in advance.
  • type is derived from the file, not from the section. A video uploaded to an image carousel still returns video; it is up to the client to put the path in a field that accepts it.

Errors

StatusWhen
404No section with this ID.
422No file part in the request.

Permissions

Requires appearance.sections.edit.

Released under the MIT License.