Skip to main content
POST
/
activities
Create Activity
curl --request POST \
  --url https://api.example.com/activities \
  --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>"
    }
  ]
}
Creates a new activity and optionally associates it with projects.

Authentication

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

Request Body

name
string
required
Name of the activity
place
string
required
Location where the activity takes place
horaInicio
string
required
Start time in HH:MM or HH:MM:SS format. Must be before horaFin.
horaFin
string
required
End time in HH:MM or HH:MM:SS format. Must be after horaInicio.
diaSemana
string
required
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
icon
string
Icon identifier for the activity

Response

id
number
Unique identifier for the created 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 POST https://api.sociapp.com/activities \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Fútbol",
    "place": "Campo deportivo",
    "horaInicio": "16:00",
    "horaFin": "18:00",
    "diaSemana": "Lunes",
    "icon": "soccer",
    "idMonitor": 5,
    "projectIds": [1, 3]
  }'

Example Response

{
  "id": 10,
  "name": "Fútbol",
  "place": "Campo deportivo",
  "horaInicio": "16:00",
  "horaFin": "18:00",
  "diaSemana": "Lunes",
  "icon": "soccer",
  "idMonitor": 5,
  "monitor": "Juan Pérez",
  "proyectos": [
    {
      "id": 1,
      "nombre": "Deportes de equipo"
    },
    {
      "id": 3,
      "nombre": "Actividades al aire libre"
    }
  ]
}

Validation Rules

  • All required fields (name, place, horaInicio, horaFin, diaSemana) must be provided
  • 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 - Missing Required Fields

{
  "statusCode": 400,
  "message": "Todos los campos obligatorios deben estar completos"
}

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"
}

500 Internal Server Error

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

Build docs developers (and LLMs) love