Skip to main content

Update Session (v1)

Method + Path

PATCH /v1/workspace/:workspaceId/sessions/:sessionId

Actual backend path: /v1/workspace/:workspaceId/sessions/:sessionId

Update an existing session. All fields are optional - only provided fields will be updated. If serviceIds are updated, the duration will be automatically recalculated from the new services (unless durationMinutes is manually provided).

Authentication

Required - JWT token in Authorization header

Required Permissions:

  • sessions.update

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token: Bearer <token>
Content-TypestringYesapplication/json

Path Parameters

ParameterTypeRequiredDescription
workspaceIdstringYesWorkspace identifier
sessionIdstringYesSession identifier

Request Body

{
"name": "Updated Session Name",
"clientId": "507f1f77bcf86cd799439012",
"serviceIds": ["507f1f77bcf86cd799439013"],
"staffId": "507f1f77bcf86cd799439015",
"date": "2024-01-21T00:00:00.000Z",
"startTime": "10:00",
"durationMinutes": 90,
"status": "in-progress",
"reminder": {
"isReminded": true,
"remindedAt": "2024-01-20T10:00:00.000Z",
"channels": ["sms"]
}
}

Body Parameters

ParameterTypeRequiredDescription
namestringNoSession name (minimum 1 character if provided)
clientIdstringNoClient ID for the session
serviceIdsarray[string]NoArray of service IDs (minimum 1 service required if provided). All services must have scope: "sessions"
staffIdstring|nullNoResponsible staff member ID (use null to remove assignment)
datestringNoSession date in ISO 8601 datetime format
startTimestringNoSession start time in HH:mm format (24-hour)
durationMinutesnumberNoSession duration in minutes. If serviceIds are updated and durationMinutes is not provided, duration will be recalculated from services
statusstringNoSession status. Valid values: scheduled, in-progress, completed, cancelled
reminder.isRemindedbooleanNoWhether the session reminder has been sent
reminder.remindedAtstring|nullNoReminder timestamp (ISO 8601)
reminder.channelsarray[string]NoReminder channels: sms, whatsapp, manual, bulk-sms

Note: At least one field must be provided for update.

Duration Recalculation:

  • When serviceIds are updated without providing durationMinutes, the duration is automatically recalculated from the new services
  • If durationMinutes is explicitly provided, it takes precedence over the calculated value

Response (200)

{
"session": {
"id": "507f1f77bcf86cd799439011",
"workspaceId": "507f191e810c19729de860ea",
"clientId": "507f1f77bcf86cd799439012",
"clientName": "John Doe",
"serviceIds": ["507f1f77bcf86cd799439013"],
"serviceNames": ["استشارة طبية"],
"staffId": "507f1f77bcf86cd799439015",
"staffName": "Dr. Smith",
"name": "Updated Session Name",
"date": "2024-01-21T00:00:00.000Z",
"startTime": "10:00",
"endTime": "11:30",
"durationMinutes": 90,
"status": "in-progress",
"updatedAt": "2024-01-15T11:00:00.000Z"
}
}

Common Errors

  • 400 Bad Request: Invalid request body or no fields provided
  • 401 Unauthorized: Missing or invalid authentication token
  • 403 Forbidden: Insufficient permissions (requires sessions.update)
  • 404 Not Found: Session or workspace not found
  • 422 Unprocessable Entity: Validation errors
  • 500 Internal Server Error: Server error