Skip to main content
POST
/
api
/
solicitudes
/
actualizacion-perfil
Request Profile Update
curl --request POST \
  --url https://api.example.com/api/solicitudes/actualizacion-perfil \
  --header 'Content-Type: application/json' \
  --data '
{
  "telefono": "<string>",
  "direccion": "<string>",
  "img_perfil": "<string>"
}
'
{
  "message": "Debe proporcionar al menos un campo (teléfono, dirección o imagen) para actualizar."
}

Endpoint

POST /api/solicitudes/actualizacion-perfil
This endpoint allows employees to request updates to their profile information. Changes require administrator approval before being applied to the employee record.

Updatable Fields

Phone Number

Update contact phone number

Address

Update residential address

Profile Image

Update profile picture URL

Request Body

telefono
string
New phone numberExample: "+1234567890"
direccion
string
New residential addressExample: "123 Main St, City, Country"
img_perfil
string
New profile image URLExample: "https://example.com/images/profile.jpg"
At least one field is required. You can update one, two, or all three fields in a single request.

Response

mensaje
string
Success message confirming the request was created
id_solicitud
number
Unique identifier for the profile update request

Code Examples

const token = 'your_jwt_token';

const profileUpdate = {
  telefono: '+1234567890',
  direccion: '456 New Street, City, State',
  img_perfil: 'https://example.com/images/new-profile.jpg'
};

const response = await fetch('/api/solicitudes/actualizacion-perfil', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(profileUpdate)
});

const data = await response.json();
console.log(data);

Response Example

201 Created
{
  "mensaje": "Solicitud de actualización de perfil enviada correctamente para aprobación.",
  "id_solicitud": 234
}

Error Responses

{
  "message": "Debe proporcionar al menos un campo (teléfono, dirección o imagen) para actualizar."
}

Validation Rules

Required Fields

At least one field (telefono, direccion, or img_perfil) must be provided in the request body

Pending Requests

Employees cannot create a new profile update request if they already have one pending approval

Business Logic

1

Validate Input

System checks that at least one field is provided
2

Check Existing Requests

Verifies the employee doesn’t have a pending profile update request
3

Create Request

Creates a new request (type 5) with proposed changes stored in a separate table
4

Admin Approval

Request enters pending state awaiting administrator approval
5

Apply Changes

Upon approval, the proposed changes are applied to the employee’s profile

Data Storage

The proposed changes are stored in a separate table (actualizacion_perfil) linked to the main request:
// Proposed data structure
{
  id_solicitud: 234,
  datos_propuestos: {
    telefono: '+1234567890',
    direccion: '456 New Street, City, State',
    img_perfil: 'https://example.com/images/new-profile.jpg'
  }
}

Approve Profile Update

PUT /api/solicitudes/:id/aprobarAdmin approves the request and applies changes to employee profile

Reject Profile Update

PUT /api/solicitudes/:id/rechazarAdmin rejects the request without applying changes

Partial Updates

You can update individual fields without affecting others:
// Update only phone number
{
  "telefono": "+1234567890"
}

// Update only address
{
  "direccion": "789 Another St, City"
}

// Update phone and address, keep current image
{
  "telefono": "+1234567890",
  "direccion": "789 Another St, City"
}

Build docs developers (and LLMs) love