Skip to main content
POST
/
solicitud
/
{id}
/
cancelar
curl -X POST https://api.example.com/solicitud/42/cancelar \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "motivo": "Cambio de planes institucionales - evento pospuesto indefinidamente"
  }'
{
  "success": true,
  "message": "Solicitud cancelada exitosamente",
  "data": {
    "Id": 42,
    "CodigoSolicitud": "SOL-2026-03-00000042",
    "IdUsuarioSolicitante": 1,
    "NombreSolicitante": "Juan Pérez",
    "EmailSolicitante": "[email protected]",
    "IdDepartamentoSolicitante": 2,
    "NombreDepartamento": "Logística",
    "IdUsuarioAprobador": 3,
    "NombreAprobador": "María González",
    "EmailAprobador": "[email protected]",
    "IdTipoPrioridadSolicitud": 2,
    "NombrePrioridad": "Normal",
    "IdTipoServicioSolicitud": 1,
    "NombreTipoServicio": "Transporte de personal",
    "Asunto": "Transporte de personal a sede central",
    "Descripcion": "Se requiere transporte para personal de la unidad",
    "CantidadPasajeros": 5,
    "FechaServicioRequerido": "2026-04-15",
    "HoraServicioRequerido": "08:00:00",
    "IdEstadoActual": 4,
    "CodigoEstadoActual": "CANCELADA",
    "NombreEstadoActual": "Cancelada",
    "ColorEstadoActual": "#808080",
    "EsEstadoFinal": true,
    "FechaHoraCreacion": "2026-03-10T14:30:00",
    "FechaHoraActualizacion": "2026-03-12T10:15:00",
    "lugares": [
      {
        "Id": 1,
        "IdLugar": 5,
        "NombreLugar": "Sede Central",
        "EsOrigen": true,
        "Orden": 0
      }
    ],
    "misiones": []
  }
}

Overview

Cancels a transport solicitud, changing its status to CANCELADA (final status). This action soft-deletes any missions that are not currently in progress or completed.
Cancellation is a final action. Once cancelled, the solicitud cannot be reactivated or approved.

Authentication

Requires valid authentication token.

Path Parameters

id_solicitud
integer
required
The unique ID of the solicitud to cancel

Request Body

motivo
string
required
Required reason for cancellation. Must not be empty. This will be sent to both the requester and approver in notification emails.

Business Rules

  • Cannot cancel solicitudes already in a final status (RECHAZADA, COMPLETADA, CANCELADA)
  • Cannot cancel if there are missions with status EN_CURSO (in progress)
  • The reason (motivo) is mandatory and must not be empty
  • Missions that are not EN_CURSO or COMPLETADA are soft-deleted
  • Missions that are EN_CURSO or COMPLETADA remain active
  • The status change is recorded in the status history
  • Notification emails are sent to:
    • Requester: Cancellation notification with reason
    • Approver: Cancellation notification with reason

Response

success
boolean
Indicates if the operation was successful
message
string
Success message
data
object
The updated solicitud object with:
  • Status updated to CANCELADA
  • All solicitud details
  • Associated locations
  • Remaining active missions (only EN_CURSO or COMPLETADA, if any)

Status Codes

200
OK
Solicitud cancelled successfully
400
Bad Request
Validation error (missing or empty reason)
404
Not Found
Solicitud with the specified ID does not exist
409
Conflict
Cannot cancel (final status, missions in progress, or other conflict)
500
Internal Server Error
Server error
curl -X POST https://api.example.com/solicitud/42/cancelar \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "motivo": "Cambio de planes institucionales - evento pospuesto indefinidamente"
  }'
{
  "success": true,
  "message": "Solicitud cancelada exitosamente",
  "data": {
    "Id": 42,
    "CodigoSolicitud": "SOL-2026-03-00000042",
    "IdUsuarioSolicitante": 1,
    "NombreSolicitante": "Juan Pérez",
    "EmailSolicitante": "[email protected]",
    "IdDepartamentoSolicitante": 2,
    "NombreDepartamento": "Logística",
    "IdUsuarioAprobador": 3,
    "NombreAprobador": "María González",
    "EmailAprobador": "[email protected]",
    "IdTipoPrioridadSolicitud": 2,
    "NombrePrioridad": "Normal",
    "IdTipoServicioSolicitud": 1,
    "NombreTipoServicio": "Transporte de personal",
    "Asunto": "Transporte de personal a sede central",
    "Descripcion": "Se requiere transporte para personal de la unidad",
    "CantidadPasajeros": 5,
    "FechaServicioRequerido": "2026-04-15",
    "HoraServicioRequerido": "08:00:00",
    "IdEstadoActual": 4,
    "CodigoEstadoActual": "CANCELADA",
    "NombreEstadoActual": "Cancelada",
    "ColorEstadoActual": "#808080",
    "EsEstadoFinal": true,
    "FechaHoraCreacion": "2026-03-10T14:30:00",
    "FechaHoraActualizacion": "2026-03-12T10:15:00",
    "lugares": [
      {
        "Id": 1,
        "IdLugar": 5,
        "NombreLugar": "Sede Central",
        "EsOrigen": true,
        "Orden": 0
      }
    ],
    "misiones": []
  }
}

Mission Handling

When a solicitud is cancelled:
  1. Missions with EN_CURSO status: Remain active (cannot be deleted)
  2. Missions with COMPLETADA status: Remain active (historical record)
  3. All other missions (PENDIENTE, ASIGNADA, etc.): Soft-deleted
If there are any missions with EN_CURSO status, the cancellation will fail with a 409 error.

Email Notifications

When a solicitud is cancelled, automatic email notifications are sent to:
  1. Requester - with:
    • Solicitud code and subject
    • Cancellation date and time
    • Cancellation reason
  2. Approver - with:
    • Solicitud code and subject
    • Cancellation date and time
    • Cancellation reason
    • List of affected missions (if any)
Provide a clear and detailed cancellation reason, as this information is shared with both the requester and approver.

Build docs developers (and LLMs) love