Skip to main content
PUT
/
api
/
personas
/
:id
/
foto
Update Profile Photo
curl --request PUT \
  --url https://api.example.com/api/personas/:id/foto \
  --header 'Content-Type: application/json' \
  --data '
{
  "foto_url": "<string>"
}
'
{
  "id": 123,
  "nombres": "<string>",
  "apellidos": "<string>",
  "telefono": "<string>",
  "dni": "<string>",
  "foto_url": "<string>",
  "created_at": "<string>"
}

Overview

Updates the profile photo URL for a person. Both admins and assistants can update profile photos.
Authentication RequiredThis endpoint requires a valid JWT token. Both admin and asistente roles can access this endpoint.

Path Parameters

id
number
required
The unique identifier of the person

Request Body

foto_url
string
required
The URL of the new profile photo

Response

Returns the updated person object with the new photo URL.
id
number
Person ID
nombres
string
First name(s)
apellidos
string
Last name(s)
telefono
string
Phone number
dni
string
National ID number
foto_url
string
Updated profile photo URL
created_at
string
Creation timestamp

Example Request

cURL
curl -X PUT http://localhost:3000/api/personas/5/foto \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "foto_url": "https://example.com/photos/updated-photo.jpg"
  }'
JavaScript
const response = await fetch('http://localhost:3000/api/personas/5/foto', {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    foto_url: 'https://example.com/photos/updated-photo.jpg'
  })
});
const updated = await response.json();

Example Response

200 OK
{
  "id": 5,
  "nombres": "María",
  "apellidos": "González",
  "telefono": "+1234567890",
  "dni": "12345678",
  "foto_url": "https://example.com/photos/updated-photo.jpg",
  "created_at": "2024-03-01T08:00:00.000Z"
}

Error Responses

{
  "message": "Persona no encontrada"
}
No person exists with the specified ID.
{
  "message": "Error al actualizar foto"
}
An error occurred while updating the photo.

Implementation Note

This endpoint uses a controller function actualizarFotoPersona which may include additional validation or image processing logic.
Source: /home/daytona/workspace/source/src/routes/personas.routes.js:140

Build docs developers (and LLMs) love