Skip to main content
PUT
/
activities
/
{id}
Update Activity
curl --request PUT \
  --url https://api.example.com/activities/{id} \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "place": "<string>",
  "horaInicio": "<string>",
  "horaFin": "<string>",
  "diaSemana": "<string>",
  "idMonitor": 123,
  "projectIds": [
    123
  ],
  "icon": "<string>"
}
'
{
  "id": 123,
  "name": "<string>",
  "place": "<string>",
  "horaInicio": "<string>",
  "horaFin": "<string>",
  "diaSemana": "<string>",
  "icon": "<string>",
  "idMonitor": 123,
  "monitor": "<string>",
  "proyectos": [
    {
      "id": 123,
      "nombre": "<string>"
    }
  ]
}
Updates an existing activity by ID. All fields are optional and only provided fields will be updated.

Authentication

Authorization
string
required
Bearer token for authentication
Required Roles: monitor, admin

Path Parameters

id
number
required
The unique identifier of the activity to update

Request Body

All fields are optional. Only include fields you want to update.
name
string
Name of the activity
place
string
Location where the activity takes place
horaInicio
string
Start time in HH:MM or HH:MM:SS format. Must be before horaFin.
horaFin
string
End time in HH:MM or HH:MM:SS format. Must be after horaInicio.
diaSemana
string
Day of the week when the activity occurs
idMonitor
number
ID of the monitor assigned to this activity
projectIds
number[]
Array of project IDs to associate with this activity. This replaces all existing associations.
icon
string
Icon identifier for the activity

Response

id
number
Unique identifier for the activity
name
string
Name of the activity
place
string
Location where the activity takes place
horaInicio
string
Start time in HH:MM format
horaFin
string
End time in HH:MM format
diaSemana
string
Day of the week
icon
string
Icon identifier for the activity
idMonitor
number
ID of the assigned monitor
monitor
string
Name of the assigned monitor
proyectos
array
Array of associated projects
id
number
Project ID
nombre
string
Project name

Example Request

curl -X PUT https://api.sociapp.com/activities/10 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "place": "Nuevo campo deportivo",
    "horaInicio": "17:00",
    "horaFin": "19:00",
    "projectIds": [1, 2, 3]
  }'

Example Response

{
  "id": 10,
  "name": "Fútbol",
  "place": "Nuevo campo deportivo",
  "horaInicio": "17:00",
  "horaFin": "19:00",
  "diaSemana": "Lunes",
  "icon": "soccer",
  "idMonitor": 5,
  "monitor": "Juan Pérez",
  "proyectos": [
    {
      "id": 1,
      "nombre": "Deportes de equipo"
    },
    {
      "id": 2,
      "nombre": "Arte y creatividad"
    },
    {
      "id": 3,
      "nombre": "Actividades al aire libre"
    }
  ]
}

Project Association Behavior

When updating projectIds:
  • The activity is removed from projects not in the new list
  • The activity is added to projects in the new list that didn’t have it
  • The activity remains in projects that are in both the old and new lists
This means projectIds replaces the entire set of associated projects.

Validation Rules

  • If both horaInicio and horaFin are present (either existing or updated), horaInicio must be before horaFin
  • Time format must be HH:MM or HH:MM:SS with valid hours (00-23) and minutes (00-59)

Error Responses

400 Bad Request - Invalid Time Range

{
  "statusCode": 400,
  "message": "La hora de inicio debe ser anterior a la hora de fin"
}

400 Bad Request - Invalid Time Format

{
  "statusCode": 400,
  "message": "Formato de hora inválido"
}

401 Unauthorized

{
  "statusCode": 401,
  "message": "Unauthorized"
}

403 Forbidden

{
  "statusCode": 403,
  "message": "Forbidden resource"
}

404 Not Found

{
  "statusCode": 404,
  "message": "Actividad no encontrada"
}

500 Internal Server Error

{
  "statusCode": 500,
  "message": "Failed to update activity"
}

Build docs developers (and LLMs) love