Crear un calendario
Crea un calendario. El servidor lo guarda con estado activo y asigna al usuario autenticado como creador (create_user_id). Responde 201 con el registro creado. Si default es verdadero, los demás calendarios pasan a default falso.
Parámetros del cuerpo
Sección titulada «Parámetros del cuerpo»namestringobligatorioNombre del calendario. Máximo 100 caracteres.
holiday_idintegerobligatorioLista de feriados del calendario. Es obligatoria; no se valida que exista.
descriptionstringobligatorioDescripción. Máximo 500 caracteres.
defaultbooleanobligatorioIndica si es el calendario por defecto. Si es verdadero, los demás calendarios pasan a default falso.
working_daysarrayobligatorioDías laborales. Cada elemento lleva day, name, start_hour, end_hour y check.
working_days.*.dayintegerobligatorioDía de la semana, de 0 (domingo) a 6 (sábado).
working_days.*.namestringobligatorioNombre del día.
working_days.*.start_hourstringobligatorioHora de inicio con formato HH:MM:SS. Debe ser menor que la hora de fin.
working_days.*.end_hourstringobligatorioHora de fin con formato HH:MM:SS.
working_days.*.checkbooleanobligatorioIndica si el día es laborable.
Permiso
Sección titulada «Permiso»cashbox.configuration.create, que se valida en CalendarPolicy::create.
curl -X POST \ "https://servererp.allendostmen.app/api/calendar" \ -H "Authorization: Bearer $TOKEN" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{ "name": "CALENDARIO GENERAL", "holiday_id": 1, "description": "Lunes a viernes de 8 a 17 horas", "default": true, "working_days": [ { "day": 1, "name": "Lunes", "start_hour": "08:00:00", "end_hour": "17:00:00", "check": true }, { "day": 6, "name": "Sábado", "start_hour": "08:00:00", "end_hour": "13:00:00", "check": false } ]}'const response = await fetch( "https://servererp.allendostmen.app/api/calendar", { method: "POST", headers: { Authorization: `Bearer ${token}`, Accept: "application/json", "Content-Type": "application/json", }, body: JSON.stringify({ "name": "CALENDARIO GENERAL", "holiday_id": 1, "description": "Lunes a viernes de 8 a 17 horas", "default": true, "working_days": [ { "day": 1, "name": "Lunes", "start_hour": "08:00:00", "end_hour": "17:00:00", "check": true }, { "day": 6, "name": "Sábado", "start_hour": "08:00:00", "end_hour": "13:00:00", "check": false } ] }), },);const data = await response.json();use Illuminate\Support\Facades\Http;
$response = Http::withToken($token) ->acceptJson() ->post('https://servererp.allendostmen.app/api/calendar', [ 'name' => 'CALENDARIO GENERAL', 'holiday_id' => 1, 'description' => 'Lunes a viernes de 8 a 17 horas', 'default' => true, 'working_days' => [ [ 'day' => 1, 'name' => 'Lunes', 'start_hour' => '08:00:00', 'end_hour' => '17:00:00', 'check' => true, ], [ 'day' => 6, 'name' => 'Sábado', 'start_hour' => '08:00:00', 'end_hour' => '13:00:00', 'check' => false, ], ],]);{ "id": 1, "holiday_id": 1, "name": "CALENDARIO GENERAL", "description": "Lunes a viernes de 8 a 17 horas", "working_days": [ { "day": 1, "name": "Lunes", "start_hour": "08:00:00", "end_hour": "17:00:00", "check": true }, { "day": 6, "name": "Sábado", "start_hour": "08:00:00", "end_hour": "13:00:00", "check": false } ], "default": true, "status": "activo", "previous_status": null, "status_update_comment": null, "status_update_date": null, "status_update_user_id": null, "create_user_id": 1, "update_user_id": null, "delete_user_id": null, "restore_user_id": null, "created_at": "2026-11-19T10:40:15.000000Z", "updated_at": "2026-11-19T10:40:15.000000Z", "deleted_at": null}{ "message": "La hora de inicio debe ser menor que la hora de fin para el día Lunes.", "errors": { "working_days.0.start_hour": [ "La hora de inicio debe ser menor que la hora de fin para el día Lunes." ] }}{ "message": "This action is unauthorized."}