Skip to main content

Overview

The Image Upload API provides endpoints to upload images for tenant logos, hero banners, products, services, and gallery images. All uploads are processed and converted to WebP format for optimal performance.

Image Processing

  • Format: All images are converted to WebP
  • Storage: /storage/tenants/{tenantId}/
  • URL Pattern: https://example.com/storage/tenants/{tenantId}/{filename}
  • Validation: Files must be valid images
All image upload endpoints require authentication (auth middleware).

Upload a logo image for a tenant. The logo is typically displayed in the header/navbar.

Path Parameters

tenantId
integer
required
The ID of the tenant

Request Body

image
file
required
The logo image file (must be a valid image format)

Response

success
boolean
Whether the upload was successful
filename
string
The generated filename (e.g., logo.webp)
url
string
Full URL to access the uploaded image
{
  "success": true,
  "filename": "logo.webp",
  "url": "https://synticorex.com/storage/tenants/1/logo.webp"
}

Example

const formData = new FormData();
formData.append('image', logoFile);

fetch('/tenant/1/upload/logo', {
  method: 'POST',
  headers: {
    'X-CSRF-TOKEN': csrfToken,
  },
  body: formData
});

Upload Hero Image

Upload a hero banner image for the main landing page section.

Path Parameters

tenantId
integer
required
The ID of the tenant

Request Body

image
file
required
The hero banner image file

Response

success
boolean
Whether the upload was successful
filename
string
The generated filename (e.g., hero.webp)
url
string
Full URL to access the uploaded image
{
  "success": true,
  "filename": "hero.webp",
  "url": "https://synticorex.com/storage/tenants/1/hero.webp"
}

Upload Product Image

Upload an image for a specific product. If the product already has an image, it will be deleted and replaced.

Path Parameters

tenantId
integer
required
The ID of the tenant
productId
integer
required
The ID of the product

Request Body

image
file
required
The product image file

Filename Pattern

Generated filename: product_{index}.webp Where index is calculated as:
  • Product’s position field (if set)
  • Or: (product.id % 99) + 1
Examples:
  • product_01.webp
  • product_12.webp

Response

success
boolean
Whether the upload was successful
filename
string
The generated filename
url
string
Full URL to access the uploaded image
{
  "success": true,
  "filename": "product_01.webp",
  "url": "https://synticorex.com/storage/tenants/1/product_01.webp"
}

Upload Service Image

Upload an image for a specific service. If the service already has an image, it will be deleted and replaced.

Path Parameters

tenantId
integer
required
The ID of the tenant
serviceId
integer
required
The ID of the service

Request Body

image
file
required
The service image file

Filename Pattern

Generated filename: service_{index}.webp Where index is calculated as:
  • Service’s position field (if set)
  • Or: (service.id % 99) + 1

Response

success
boolean
Whether the upload was successful
filename
string
The generated filename
url
string
Full URL to access the uploaded image
{
  "success": true,
  "filename": "service_03.webp",
  "url": "https://synticorex.com/storage/tenants/1/service_03.webp"
}

Upload About Image

Upload an image for the “About Us” section of the landing page.

Path Parameters

tenantId
integer
required
The ID of the tenant

Request Body

image
file
required
The about section image file

Image Specifications

  • Filename: about.webp
  • Max Width: 1200px (automatically resized)

Response

success
boolean
Whether the upload was successful
filename
string
Always about.webp
url
string
Full URL to access the uploaded image
{
  "success": true,
  "filename": "about.webp",
  "url": "https://synticorex.com/storage/tenants/1/about.webp"
}

This feature is only available for Plan 3 / VISIÓN tenants. Returns 403 error for other plans.
Upload additional gallery images for a product. Each product can have up to 2 gallery images (plus the main product image = 3 total).

Path Parameters

tenantId
integer
required
The ID of the tenant (must be Plan 3 / VISIÓN)
productId
integer
required
The ID of the product

Request Body

image
file
required
The gallery image file

Filename Pattern

product_{productIndex}_gallery_{position}.webp Examples:
  • product_01_gallery_1.webp
  • product_01_gallery_2.webp

Limits

  • Max gallery images per product: 2
  • Total images per product: 3 (1 main + 2 gallery)

Response

success
boolean
Whether the upload was successful
id
integer
Database ID of the created ProductImage record
filename
string
The generated filename
url
string
Full URL to access the uploaded image
position
integer
Position index (0 or 1)
Total number of gallery images after upload
{
  "success": true,
  "id": 42,
  "filename": "product_01_gallery_1.webp",
  "url": "https://synticorex.com/storage/tenants/1/product_01_gallery_1.webp",
  "position": 0,
  "gallery_count": 1
}

Delete a specific gallery image from a product. Remaining images are automatically reordered.

Path Parameters

tenantId
integer
required
The ID of the tenant
productId
integer
required
The ID of the product
imageId
integer
required
The ID of the ProductImage record to delete

Response

success
boolean
Whether the deletion was successful
message
string
Success message
Number of gallery images remaining after deletion
{
  "success": true,
  "message": "Imagen eliminada correctamente",
  "gallery_count": 1
}

Auto-Reordering

After deletion, remaining gallery images are automatically reordered:
Before: gallery_1.webp (position: 0), gallery_2.webp (position: 1)
Delete: gallery_1.webp
After:  gallery_2.webp (position: 0)

Image Processing Details

ImageUploadService

All images are processed through the ImageUploadService which:
  1. Validates the file is a valid image
  2. Resizes images to optimal dimensions
  3. Converts to WebP format for performance
  4. Stores in the tenant’s directory
  5. Returns the generated filename

Storage Structure

storage/
└── app/
    └── public/
        └── tenants/
            ├── 1/
            │   ├── logo.webp
            │   ├── hero.webp
            │   ├── about.webp
            │   ├── product_01.webp
            │   ├── product_01_gallery_1.webp
            │   └── service_01.webp
            ├── 2/
            │   └── ...

Public Access

Images are accessible via the public storage symlink:
php artisan storage:link
URL: https://example.com/storage/tenants/{tenantId}/{filename}

Build docs developers (and LLMs) love