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
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer token: Bearer <token> |
Content-Type | string | Yes | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workspaceId | string | Yes | Workspace identifier |
sessionId | string | Yes | Session 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
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | No | Session name (minimum 1 character if provided) |
clientId | string | No | Client ID for the session |
serviceIds | array[string] | No | Array of service IDs (minimum 1 service required if provided). All services must have scope: "sessions" |
staffId | string|null | No | Responsible staff member ID (use null to remove assignment) |
date | string | No | Session date in ISO 8601 datetime format |
startTime | string | No | Session start time in HH:mm format (24-hour) |
durationMinutes | number | No | Session duration in minutes. If serviceIds are updated and durationMinutes is not provided, duration will be recalculated from services |
status | string | No | Session status. Valid values: scheduled, in-progress, completed, cancelled |
reminder.isReminded | boolean | No | Whether the session reminder has been sent |
reminder.remindedAt | string|null | No | Reminder timestamp (ISO 8601) |
reminder.channels | array[string] | No | Reminder channels: sms, whatsapp, manual, bulk-sms |
Note: At least one field must be provided for update.
Duration Recalculation:
- When
serviceIdsare updated without providingdurationMinutes, the duration is automatically recalculated from the new services - If
durationMinutesis 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