The Branches API allows you to create, retrieve, update, and delete branch locations for your dental practice.
Authentication
All endpoints require authentication. The following permissions apply:
All authenticated users can view branches (GET)
MANAGE_BRANCHES permission required for create, update, and delete operations
Endpoints
List Branches
curl -X GET "https://your-domain.com/api/branches" \
-H "Cookie: session=your-session-token"
Retrieve a list of all branches.
Indicates if the request was successful
Array of branch objects Physical address of the branch
Emoji or icon representing the branch
Branch status (active, inactive)
{
"success" : true ,
"branches" : [
{
"id" : 1 ,
"name" : "Main Office" ,
"address" : "123 Main Street, Downtown" ,
"icon" : "🏢" ,
"status" : "active" ,
"created_at" : "2024-01-01T00:00:00Z"
},
{
"id" : 2 ,
"name" : "West Side Clinic" ,
"address" : "456 West Avenue" ,
"icon" : "🏥" ,
"status" : "active" ,
"created_at" : "2024-02-01T00:00:00Z"
},
{
"id" : 3 ,
"name" : "East Branch" ,
"address" : "789 East Boulevard" ,
"icon" : "🦷" ,
"status" : "inactive" ,
"created_at" : "2024-03-01T00:00:00Z"
}
]
}
Create Branch
curl -X POST "https://your-domain.com/api/branches" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{
"name": "North Side Clinic",
"address": "321 North Road",
"icon": "🏥"
}'
Create a new branch location.
Permission Required: MANAGE_BRANCHES
Physical address of the branch
Emoji or icon for the branch (default: ”🏢“)
{
"success" : true ,
"id" : 4
}
Update Branch
curl -X PATCH "https://your-domain.com/api/branches" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{
"id": 1,
"name": "Main Office - Downtown",
"address": "123 Main Street, Suite 100, Downtown",
"icon": "🏢",
"status": "active"
}'
Update an existing branch’s information.
Permission Required: MANAGE_BRANCHES
ID of the branch to update
Emoji or icon for the branch
Branch status: “active” or “inactive” (default: “active”)
Delete Branch
curl -X DELETE "https://your-domain.com/api/branches?id=3" \
-H "Cookie: session=your-session-token"
Delete a branch from the system.
Permission Required: MANAGE_BRANCHES
ID of the branch to delete
Deleting a branch may affect associated records such as patients, appointments, and doctor assignments. Ensure no critical data is linked before deletion.
Branch Icons
Branches can be visually distinguished using emoji icons. Common icons include:
🏢 Office building
🏥 Hospital/Clinic
🦷 Tooth (dental themed)
🏪 Store
📍 Location pin
🏛️ Building with columns
The icon field accepts any single emoji character.
Common Use Cases
Get All Active Branches
curl -X GET "https://your-domain.com/api/branches" \
-H "Cookie: session=your-session-token"
Filter active branches client-side by checking status === "active".
Create a New Branch
curl -X POST "https://your-domain.com/api/branches" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{
"name": "South Branch",
"address": "555 South Street",
"icon": "🦷"
}'
Update Branch Address
curl -X PATCH "https://your-domain.com/api/branches" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{
"id": 2,
"name": "West Side Clinic",
"address": "456 West Avenue, Unit 12",
"icon": "🏥",
"status": "active"
}'
Deactivate a Branch
To soft-delete or deactivate a branch without removing it:
curl -X PATCH "https://your-domain.com/api/branches" \
-H "Content-Type: application/json" \
-H "Cookie: session=your-session-token" \
-d '{
"id": 3,
"name": "East Branch",
"address": "789 East Boulevard",
"icon": "🦷",
"status": "inactive"
}'
Permanently Delete a Branch
curl -X DELETE "https://your-domain.com/api/branches?id=3" \
-H "Cookie: session=your-session-token"
Branch Assignment
Branches are referenced in several other resources:
Patients - Each patient can be assigned to a primary branch
Doctors - Doctors can be assigned to one or more branches
Appointments - Each appointment occurs at a specific branch
Users - Staff members can be assigned to specific branches
Error Responses
401 Unauthorized
403 Forbidden
400 Bad Request
400 Bad Request
500 Internal Server Error
{
"message" : "No autorizado"
}
Source Reference
API implementation can be found in:
src/routes/api/branches/+server.js - All branch management endpoints