Overview
The FAQ API provides access to frequently asked questions and their answers. All users can retrieve FAQs, while administrators can create, update, and delete them.
Endpoints
Get FAQs Retrieve all FAQs with optional search
Create FAQ Add a new FAQ entry (Admin only)
Update FAQ Modify an existing FAQ (Admin only)
Delete FAQ Remove an FAQ entry (Admin only)
Get FAQs
curl -X GET "https://api.example.com/api/faq?busqueda=vacation" \
-H "Authorization: Bearer YOUR_TOKEN"
Retrieves all FAQs, with optional search filtering across questions and answers.
Query Parameters
Search term to filter FAQs by question or answer content
Response
200 OK
404 Not Found
500 Error
[
{
"id_faq" : 1 ,
"id_categoria" : 1 ,
"pregunta" : "¿Cómo solicito vacaciones?" ,
"respuesta" : "Debes ingresar al portal y acceder a la sección de Vacaciones. Luego selecciona las fechas deseadas y envía tu solicitud." ,
"fecha_creacion" : "2024-01-10T08:00:00Z"
},
{
"id_faq" : 2 ,
"id_categoria" : 1 ,
"pregunta" : "¿Cuántos días de vacaciones tengo?" ,
"respuesta" : "Puedes consultar tu saldo de vacaciones en el Dashboard de Vacaciones." ,
"fecha_creacion" : "2024-01-12T09:30:00Z"
}
]
Create FAQ
curl -X POST "https://api.example.com/api/faq/admin" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id_categoria": 1,
"pregunta": "¿Cómo cambio mi contraseña?",
"respuesta": "Ve a Configuración > Seguridad > Cambiar Contraseña."
}'
This endpoint requires Admin or RRHH role permissions.
Request Body
Response
201 Created
400 Bad Request
500 Error
{
"message" : "FAQ creada exitosamente." ,
"faq" : {
"id_faq" : 25 ,
"id_categoria" : 1 ,
"pregunta" : "¿Cómo cambio mi contraseña?" ,
"respuesta" : "Ve a Configuración > Seguridad > Cambiar Contraseña." ,
"fecha_creacion" : "2024-03-09T15:45:00Z"
}
}
Update FAQ
curl -X PUT "https://api.example.com/api/faq/admin/25" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id_categoria": 2,
"pregunta": "¿Cómo actualizo mi contraseña?",
"respuesta": "Dirígete a Configuración > Seguridad > Actualizar Contraseña."
}'
This endpoint requires Admin or RRHH role permissions.
Path Parameters
Request Body
Response
200 OK
404 Not Found
500 Error
{
"message" : "FAQ actualizada exitosamente."
}
Delete FAQ
DELETE /api/faq/admin/:id
curl -X DELETE "https://api.example.com/api/faq/admin/25" \
-H "Authorization: Bearer YOUR_TOKEN"
This endpoint requires Admin or RRHH role permissions.
Path Parameters
Response
200 OK
404 Not Found
500 Error
{
"message" : "FAQ eliminada exitosamente."
}
Implementation Reference
Source files:
Routes: src/routes/faqRoutes.js:13-17
Controller: src/controllers/faqController.js:42-243