Media

Upload and manage media library files

GET /admin/api/media

List all media files for the current shop, newest first.

Response 200

[
  {
    "id": 1,
    "slug": "hero_banner",
    "storage_key": "shop1/media/a1b2c3.webp",
    "url": "https://cdn.zeroshop.io/shop1/media/a1b2c3.webp",
    "original_filename": "hero-banner.png",
    "file_size": 48210,
    "content_type": "image/webp",
    "created_at": "2025-11-20T14:30:00Z"
  },
  {
    "id": 2,
    "slug": "logo",
    "storage_key": "shop1/media/d4e5f6.webp",
    "url": "https://cdn.zeroshop.io/shop1/media/d4e5f6.webp",
    "original_filename": "logo.jpg",
    "file_size": 12480,
    "content_type": "image/webp",
    "created_at": "2025-11-19T09:15:00Z"
  }
]

Example

curl "https://yourshop.zeroshop.io/admin/api/media" \
  -H "Authorization: Bearer zspat_..."
POST /admin/api/media

Upload a new media file. Accepts multipart/form-data with a single field named "file". Images are resized to max 1200x1200 px and converted to WebP. Tier caps are enforced — exceeding either cap returns 402 with `error: tier_limit_exceeded`, `limit: max_media_bytes` or `max_single_file_bytes`. See the Tenant Tier reference.

Parameters

Name Type Required Description
file file required The image file to upload. Supported formats: JPEG, PNG, GIF, WebP.

Response 201

{
  "id": 3,
  "slug": "product_shot",
  "storage_key": "shop1/media/g7h8i9.webp",
  "url": "https://cdn.zeroshop.io/shop1/media/g7h8i9.webp",
  "original_filename": "product-shot.png",
  "file_size": 35600,
  "content_type": "image/webp",
  "created_at": "2025-11-21T10:00:00Z"
}

Example

curl -X POST "https://yourshop.zeroshop.io/admin/api/media" \
  -H "Authorization: Bearer zspat_..." \
  -F "file=@product-shot.png"
PUT /admin/api/media/{id}

Update a media file's slug. The slug is URL-friendly and used in templates. Input is slugified server-side.

Parameters

Name Type Required Description
id integer required Media file ID

Request Body

{
  "slug": "new_hero_banner"
}

Response 200

{
  "slug": "new_hero_banner"
}

Example

curl -X PUT "https://yourshop.zeroshop.io/admin/api/media/1" \
  -H "Authorization: Bearer zspat_..." \
  -H "Content-Type: application/json" \
  -d '{"slug": "new_hero_banner"}'
DELETE /admin/api/media/{id}

Delete a media file. Removes both the database record and the file from object storage.

Parameters

Name Type Required Description
id integer required Media file ID

Response 204

Example

curl -X DELETE "https://yourshop.zeroshop.io/admin/api/media/1" \
  -H "Authorization: Bearer zspat_..."

We value your privacy

We use cookies for essential site functionality and, with your consent, analytics to understand how our platform is used. No personal data is shared with third parties. See our Privacy Policy for details.