Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JuanSCaicedo/Api-Ecommerce/llms.txt

Use this file to discover all available pages before exploring further.

Categories power the storefront navigation menu and product filtering system. They support a three-level hierarchy: department (first) → category (second) → subcategory (third). Brands are a flat resource that appear as both navigation facets and product metadata. Both resources drive the dropdowns used when creating or editing products.
Mutating operations — store, update, and destroy — on both categories and brands are throttled at 10 requests per minute per token.

Authentication

All /api/admin/ endpoints require an admin JWT with type_user=1:
Authorization: Bearer <admin_token>
See Products — Authentication for how to obtain a token via POST /api/auth/login.

Category Hierarchy Rules

The three-level hierarchy is encoded in two nullable foreign-key columns on every category row:
Levelcategorie_second_idcategorie_third_idExample
FirstNULLNULLElectronics
Secondset (not NULL)NULLSmartphones
Thirdset (not NULL)set (not NULL)Android Phones
A category cannot be deleted while any product references it as categorie_first_id, categorie_second_id, or categorie_third_id. The API returns {"message": 403, "message_text": "La categoría no puede ser eliminada porque tiene productos asociados"}.

List Categories

GET /api/admin/categories
Returns a paginated list of all categories (all levels), ordered by id descending, 10 per page. Request headers
HeaderValue
AuthorizationBearer <admin_token>
Query parameters
Filter categories by name (SQL LIKE %value%).
Response
total
integer
Total matching categories across all pages.
categories
object
Paginated category collection. Items live under the data key (Laravel ResourceCollection envelope).
categories.data
array
Array of category objects for the current page. Each object includes id, name, icon, imagen (resolved OCI URL or null), categorie_second_id, categorie_second (nested name object or null), categorie_third_id, categorie_third (nested name object or null), position, type_categorie, state, and created_at.
{
  "total": 18,
  "categories": {
    "data": [
      {
        "id": 9,
        "name": "Android Phones",
        "icon": "smartphone",
        "imagen": "https://objectstorage.../categories/android.jpg",
        "categorie_second_id": 4,
        "categorie_second": { "name": "Smartphones" },
        "categorie_third_id": 9,
        "categorie_third": { "name": "Android Phones" },
        "position": 3,
        "type_categorie": null,
        "state": 1,
        "created_at": "2024-01-10 08:00:00"
      }
    ]
  }
}

Get Category Config (Dropdowns)

Returns all first-level and second-level categories for use in form dropdowns (e.g., when creating a new category). Note: this endpoint does not filter by state — all categories at each level are returned regardless of state.
GET /api/admin/categories/config
Request headers
HeaderValue
AuthorizationBearer <admin_token>
Response
categories_first
array
All top-level categories (categorie_second_id = NULL, categorie_third_id = NULL).
categories_seconds
array
All second-level categories (categorie_second_id != NULL, categorie_third_id = NULL).
{
  "categories_first": [
    { "id": 1, "name": "Electronics", "state": 1 }
  ],
  "categories_seconds": [
    { "id": 4, "name": "Smartphones", "state": 1, "categorie_second_id": 1 }
  ]
}
Unlike GET /api/admin/products/config, the categories config endpoint only returns two levels (first and second), not thirds. Third-level categories are accessible via the main list endpoint.

Get Category

GET /api/admin/categories/{id}
Path parameters
id
integer
required
Category ID.
Response
categorie
object
Full category resource via CategorieResource. Includes id, name, icon, imagen (OCI URL), categorie_second_id, categorie_second (nested {name} or null), categorie_third_id, categorie_third (nested {name} or null), position, type_categorie, state, and created_at.
{
  "categorie": {
    "id": 4,
    "name": "Smartphones",
    "icon": "phone",
    "imagen": "https://objectstorage.../categories/smartphones.jpg",
    "categorie_second_id": 1,
    "categorie_second": { "name": "Electronics" },
    "categorie_third_id": null,
    "categorie_third": null,
    "position": 2,
    "type_categorie": null,
    "state": 1,
    "created_at": "2024-01-10 08:00:00"
  }
}

Create Category

POST /api/admin/categories
Category names must be unique. Submitting a duplicate name returns {"message": 403} without creating anything.
Request headers
HeaderValue
AuthorizationBearer <admin_token>
Content-Typemultipart/form-data
Body parameters
name
string
required
Category display name. Must be unique across all categories.
image
file
Category image file (JPEG/PNG). Uploaded to OCI Object Storage under juandevops/ecommerce/public/categories/. The OCI path is stored in the imagen column.
state
integer
1 = active (visible on storefront), 0 = inactive.
position
integer
Display order in navigation menus. Lower values appear first.
icon
string
Icon identifier string (e.g., a Heroicons name or custom token used by the frontend).
type_categorie
integer
Optional category type flag consumed by the frontend.
categorie_second_id
integer
Parent category ID for second-level categories. Omit to create a first-level category.
categorie_third_id
integer
Grandparent category ID for third-level categories. Set alongside categorie_second_id.
Level quick-reference
To createcategorie_second_idcategorie_third_id
First-levelomit / nullomit / null
Second-levelparent IDomit / null
Third-levelparent IDgrandparent ID
Response
message
integer
200 on success, 403 on duplicate name.
id
integer
Newly created category ID.
{ "message": 200, "id": 11 }
Example — create a first-level category
curl -X POST https://your-domain.com/api/admin/categories \
  -H "Authorization: Bearer <admin_token>" \
  -F "name=Footwear" \
  -F "state=1" \
  -F "position=5" \
  -F "icon=shoe" \
  -F "image=@/path/to/footwear.jpg"
Example — create a second-level category
curl -X POST https://your-domain.com/api/admin/categories \
  -H "Authorization: Bearer <admin_token>" \
  -F "name=Running Shoes" \
  -F "state=1" \
  -F "position=1" \
  -F "categorie_second_id=11"

Update Category

Uses POST (not PUT/PATCH) to support multipart image uploads.
POST /api/admin/categories/{id}
Path parameters
id
integer
required
Category ID to update.
Body parameters Same as Create Category, plus special image handling:
image
string or file
  • Omit — leave the current image unchanged.
  • Empty string ("") — delete the existing image from OCI and set imagen to null.
  • New file — delete the old image from OCI and upload the replacement.
If another category already uses the same name, the request returns {"message": 403} and no update is applied.
Response
{ "message": 200 }

Delete Category

DELETE /api/admin/categories/{id}
Deletes the category image from OCI (if present) and removes the database record. Path parameters
id
integer
required
Category ID to delete.
Response
{ "message": 200 }
Error if the category has associated products:
{
  "message": 403,
  "message_text": "La categoría no puede ser eliminada porque tiene productos asociados"
}


List Brands

GET /api/admin/brands
Returns a paginated list of brands, 25 per page, ordered by id descending. Request headers
HeaderValue
AuthorizationBearer <admin_token>
Query parameters
search
string
Filter brands by name (SQL LIKE %value%).
Response
total
integer
Total matching brands across all pages.
brands
array
Array of brand objects. Each object contains id, name, state, and created_at formatted as "YYYY-MM-DD hh:mm A". Note: the brands list is returned as a plain array (not wrapped in a data key).
{
  "total": 12,
  "brands": [
    {
      "id": 3,
      "name": "Samsung",
      "state": 1,
      "created_at": "2024-01-15 10:30 AM"
    }
  ]
}

Create Brand

POST /api/admin/brands
Brand names must be unique. A duplicate name returns {"message": 403}.
Request headers
HeaderValue
AuthorizationBearer <admin_token>
Content-Typeapplication/json
Body parameters
name
string
required
Brand display name. Must be unique.
state
integer
1 = active, 0 = inactive.
Response
message
integer
200 on success, 403 on duplicate name.
brand
object
The created brand object including id, name, state, and created_at.
{
  "message": 200,
  "brand": {
    "id": 13,
    "name": "Nike",
    "state": 1,
    "created_at": "2024-06-01 09:15 AM"
  }
}
Example — create a brand
curl -X POST https://your-domain.com/api/admin/brands \
  -H "Authorization: Bearer <admin_token>" \
  -H "Content-Type: application/json" \
  -d '{"name": "Nike", "state": 1}'

Update Brand

PUT /api/admin/brands/{id}
Path parameters
id
integer
required
Brand ID to update.
Body parameters
name
string
New brand name. Must be unique among other brands.
state
integer
1 = active, 0 = inactive.
Response
message
integer
200 on success, 403 on duplicate name.
brand
object
Updated brand object with id, name, state, and created_at.
{
  "message": 200,
  "brand": {
    "id": 13,
    "name": "Nike Inc.",
    "state": 1,
    "created_at": "2024-06-01 09:15 AM"
  }
}

Delete Brand

DELETE /api/admin/brands/{id}
A brand that has associated products cannot be deleted. Returns {"message": 403, "message_text": "No se puede eliminar la marca porque tiene productos asociados"}.
Path parameters
id
integer
required
Brand ID to delete.
Response
{ "message": 200 }

Build docs developers (and LLMs) love