Media

Media endpoints allow reordering and deletion of images/documents attached to lots and auctions. Ownership is strictly enforced.

SPA / browser sessions: Users authenticated via browser session (cookie) are also permitted for media endpoints without a Sanctum token — no ability check is applied. This supports the admin UI and seller upload screens.

Ownership rules

The MediaController enforces the following rules before allowing reorder or delete:

Media attached toWho can manage
LotSeller who owns the lot, or the auction owner, or any admin
Auction (team-owned)Any member of the owning team, or any admin
Auction (user-owned)The owning user, or any admin

Attempting to manage media you do not own returns 403 with code media_not_owned.

POST /api/media/reorder write ability (or session)

Reorders media items. Pass the desired order as an array of media IDs. All IDs must belong to the same lot/auction, and you must own that lot/auction.

Request body

FieldTypeRequiredDescription
media_idsarray of integersYesMedia IDs in the desired display order

Example

curl -X POST "https://bidyear.com/api/media/reorder" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{"media_ids": [34, 31, 38, 29]}'

Response 200

{ "success": true, "message": "Media reordered" }
DELETE /api/media/{media} write ability (or session)

Deletes a media item. The media file is removed from storage. Ownership is verified before deletion.

Path parameters

ParamTypeDescription
mediaintegerMedia ID (Spatie Media Library record)

Example

curl -X DELETE "https://bidyear.com/api/media/34" \
  -H "Authorization: Bearer {token}"

Response 200

{ "success": true, "message": "Media deleted" }

Error responses

HTTPcodeCause
403media_not_ownedCaller does not own the lot/auction this media is attached to
404Media ID not found