Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Emmanuel-Mtz-777/TechStore-Explorer/llms.txt

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

The Roles API provides full CRUD operations for managing user roles within TechStore Explorer. Because roles control access across the application, this resource is restricted exclusively to users with the admin role. All five endpoints require both a valid Laravel Sanctum Bearer token (auth:sanctum) and admin privileges (admin.api) — unauthenticated requests and regular authenticated users are both denied access.
All /api/roles/* endpoints are protected by both the auth:sanctum and admin.api middleware. The admin.api middleware returns 401 Unauthorized if no authenticated user is found on the request, and 403 Forbidden if the authenticated user’s role.name is not "admin". A valid customer token will always receive a 403.
401 Unauthorized — returned by admin.api when no user is present on the request:
{
  "message": "Unauthorized"
}
403 Forbidden — returned by admin.api when the authenticated user does not hold the admin role:
{
  "message": "Forbidden"
}

GET /api/roles

Returns a list of every role currently defined in the system. Authentication: Bearer token + admin role Request body: None Success response — 200 OK
{
  "roles": [
    {
      "id": 1,
      "name": "admin",
      "created_at": "2024-01-01T12:00:00.000000Z",
      "updated_at": "2024-01-01T12:00:00.000000Z"
    },
    {
      "id": 2,
      "name": "customer",
      "created_at": "2024-01-01T12:00:00.000000Z",
      "updated_at": "2024-01-01T12:00:00.000000Z"
    }
  ]
}
roles
array
required
Array of all role objects in the system.
curl example
curl -s -X GET http://127.0.0.1:8000/api/roles \
  -H 'Authorization: Bearer {token}' \
  -H 'Accept: application/json'

POST /api/roles

Creates a new role with the provided name. Authentication: Bearer token + admin role Request body
name
string
required
The name of the new role. Must be a string with a maximum length of 255 characters.
Success response — 201 Created
{
  "message": "Rol creado correctamente",
  "role": {
    "id": 3,
    "name": "moderator",
    "created_at": "2024-01-01T12:00:00.000000Z",
    "updated_at": "2024-01-01T12:00:00.000000Z"
  }
}
message
string
Human-readable confirmation string: "Rol creado correctamente".
role
object
The newly created role record, including its generated id and timestamps.
curl example
curl -s -X POST http://127.0.0.1:8000/api/roles \
  -H 'Authorization: Bearer {token}' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{"name": "moderator"}'

GET /api/roles/

Returns a single role by its ID. Uses Laravel’s implicit route model binding — a non-existent ID returns a 404 response automatically. Authentication: Bearer token + admin role Path parameter
id
integer
required
The ID of the role to retrieve.
Success response — 200 OK
{
  "role": {
    "id": 1,
    "name": "admin",
    "created_at": "2024-01-01T12:00:00.000000Z",
    "updated_at": "2024-01-01T12:00:00.000000Z"
  }
}
role
object
The role object matching the supplied id. Contains id, name, created_at, and updated_at.
curl example
curl -s -X GET http://127.0.0.1:8000/api/roles/1 \
  -H 'Authorization: Bearer {token}' \
  -H 'Accept: application/json'

PUT /api/roles/

Updates the name of an existing role. Uses Laravel’s implicit route model binding — a non-existent ID returns a 404 response automatically. Authentication: Bearer token + admin role Path parameter
id
integer
required
The ID of the role to update.
Request body
name
string
required
The new name for the role. Must be a string with a maximum length of 255 characters.
Success response — 200 OK
{
  "message": "Rol actualizado correctamente",
  "role": {
    "id": 1,
    "name": "superadmin",
    "created_at": "2024-01-01T12:00:00.000000Z",
    "updated_at": "2024-01-02T09:30:00.000000Z"
  }
}
message
string
Human-readable confirmation string: "Rol actualizado correctamente".
role
object
The updated role record reflecting the new name and a refreshed updated_at timestamp.
curl example
curl -s -X PUT http://127.0.0.1:8000/api/roles/1 \
  -H 'Authorization: Bearer {token}' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{"name": "superadmin"}'

DELETE /api/roles/

Permanently deletes a role by its ID. Uses Laravel’s implicit route model binding — a non-existent ID returns a 404 response automatically. Authentication: Bearer token + admin role Path parameter
id
integer
required
The ID of the role to delete.
Success response — 200 OK
{
  "message": "Rol eliminado correctamente"
}
message
string
Human-readable confirmation string: "Rol eliminado correctamente".
Deleting a role that is currently assigned to users may leave those users without a valid role. Verify role usage before performing a deletion in production.
curl example
curl -s -X DELETE http://127.0.0.1:8000/api/roles/3 \
  -H 'Authorization: Bearer {token}' \
  -H 'Accept: application/json'

Build docs developers (and LLMs) love