Skip to main content

Get All Brands

GET /api/brands
Retrieves all product brands.

Response

success
boolean
required
Indicates if the request was successful
data
array
required
Array of brand objects
id
number
Brand ID
nombre
string
Brand name
logoUrl
string
URL to the brand logo image (if uploaded)
{
  "success": true,
  "data": [
    {
      "id": 1,
      "nombre": "NVIDIA",
      "logoUrl": "/uploads/brands/nvidia-logo.png"
    },
    {
      "id": 2,
      "nombre": "AMD",
      "logoUrl": "/uploads/brands/amd-logo.png"
    },
    {
      "id": 3,
      "nombre": "Intel",
      "logoUrl": "/uploads/brands/intel-logo.png"
    }
  ]
}

Get Brand by ID

GET /api/brands/:id
Retrieves a specific brand by its ID.

Path Parameters

id
number
required
The unique identifier of the brand

Response

success
boolean
required
Indicates if the request was successful
data
object
Brand object
id
number
Brand ID
nombre
string
Brand name
logoUrl
string
URL to the brand logo image
{
  "success": true,
  "data": {
    "id": 1,
    "nombre": "NVIDIA",
    "logoUrl": "/uploads/brands/nvidia-logo.png"
  }
}

Error Responses

{
  "success": false,
  "error": "Marca no encontrada"
}

Create Brand

POST /api/brands
Content-Type: multipart/form-data
Creates a new brand with optional logo upload.

Authentication

Note: This endpoint requires appropriate permissions to create brands.

Request Body

This endpoint accepts multipart/form-data for file uploads.
nombre
string
required
Name of the brand
Brand logo image file (optional)Accepted formats: Common image formats (JPG, PNG, etc.)
curl -X POST https://api.example.com/api/brands \
  -F "nombre=Corsair" \
  -F "logo=@/path/to/logo.png"

Response

success
boolean
required
Indicates if the request was successful
data
object
Created brand object
id
number
Brand ID
nombre
string
Brand name
logoUrl
string
URL to the uploaded brand logo
{
  "success": true,
  "data": {
    "id": 4,
    "nombre": "Corsair",
    "logoUrl": "/uploads/brands/corsair-logo.png"
  }
}

Error Responses

{
  "success": false,
  "error": "Nombre requerido"
}

Delete Brand

DELETE /api/brands/:id
Deletes a brand. Brands with associated products cannot be deleted.

Authentication

Note: This endpoint requires appropriate permissions to delete brands.

Path Parameters

id
number
required
The unique identifier of the brand to delete

Response

success
boolean
required
Indicates if the request was successful
message
string
Success message
error
string
Error message if deletion failed (e.g., brand has associated products)
{
  "success": true,
  "message": "Marca eliminada"
}

Error Responses

{
  "success": false,
  "error": "No se pudo eliminar (¿Tiene productos?)"
}

Build docs developers (and LLMs) love