Organization Branches
Function-calling namespace: organizationBranches
- Base URL:
https://api.aivida.in - Engine endpoint:
POST /api - Auth: Stack token middleware enabled in
optionalmode. - Send token in header:
x-stack-access-token: <access_token>(orAuthorization: Bearer <access_token>). - In
optionalmode: no token is allowed; invalid token is rejected with401.
create
Source: backend/endpoints/organization-branches/create
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
organizationId | string | Yes | - |
branchName | string | Yes | - |
branchCode | string | Yes | unique per organization among non-deleted branches |
branchType | string | Yes | - |
description | string | No | - |
managerName | string | No | - |
managerContact | string | No | international phone format |
streetAddress | string | No | - |
area | string | No | - |
city | string | No | - |
state | string | No | - |
postalCode | string | No | - |
country | string | No | - |
coordinates | object | No | object with numeric latitude and longitude |
contactPhone | string | No | international phone format |
telephoneNumber | string | No | - |
contactEmail | string | No | - |
website | string | No | - |
emergencyContact | string | No | international phone format |
openingHours | object | No | object with schedule, timezone, and is24Hours |
coverImageUrl | string | No | - |
status | string | Yes | oneof: active |
isActive | boolean | No | - |
createdAt | integer | No | unix-ms timestamp; nullable |
updatedAt | integer | No | unix-ms timestamp; nullable |
Business Rules
organizationId,branchName,branchCode,branchType, andstatusare required.- The organization must exist, be active, and not be deleted.
branchCodemust be unique among non-deleted branches for the same organization.- Supported
statusvalues areactive,inactive,coming_soon, andtemporarily_closed.
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "organizationBranches",
"apiName": "create",
"data": {
"organizationId": "org_123",
"branchName": "Anna Nagar Branch",
"branchCode": "ANNA",
"branchType": "clinic",
"description": "Primary dental branch for Anna Nagar.",
"managerName": "Priya Raman",
"managerContact": "+919876543210",
"streetAddress": "12, 2nd Avenue",
"area": "Anna Nagar",
"city": "Chennai",
"state": "Tamil Nadu",
"postalCode": "600040",
"country": "India",
"coordinates": {
"latitude": 13.0405271553947,
"longitude": 80.21238,
"accuracy": 316,
"capturedAt": 1779971037247
},
"contactPhone": "+914412345678",
"contactEmail": "annanagar@example.com",
"website": "https://example.com/anna-nagar",
"emergencyContact": "+919123456789",
"openingHours": {
"schedule": {
"monday": [
{
"start": "09:00",
"end": "18:00"
}
]
},
"timezone": "Asia/Kolkata",
"is24Hours": false
},
"coverImageUrl": "https://example.com/images/anna-nagar.jpg",
"status": "active",
"isActive": true
}
}'Example Response
{
"status": "ok",
"data": "branch_123"
}delete
Source: backend/endpoints/organization-branches/delete
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
id | string | Yes | - |
organizationId | string | Yes | - |
Business Rules
- This API performs a soft delete only.
- The branch is marked
isDeleted: true,isActive: false, anddeletedAtis set. - Deleted branches are hidden from get and list APIs.
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "organizationBranches",
"apiName": "delete",
"data": {
"id": "branch_123",
"organizationId": "org_123"
}
}'Example Response
{
"status": "ok",
"data": {
"message": "Organization branch deleted successfully"
}
}getById
Source: backend/endpoints/organization-branches/get-by-id
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
id | string | Yes | - |
organizationId | string | Yes | - |
Response Data Format
| Field | Type | Notes |
|---|---|---|
_id | string | Branch ID. |
organizationId | string | Parent organization ID. |
branchName | string | Display name of the branch. |
branchCode | string | Unique active branch code within the organization. |
branchType | string | Branch category/type. |
description | string | Optional branch description. |
managerName | string | Optional branch manager name. |
managerContact | string | Optional manager phone number. |
streetAddress | string | Street address. |
area | string | Area/locality. |
city | string | City. |
state | string | State. |
postalCode | string | Postal code. |
country | string | Country. |
coordinates | object | Location object with latitude, longitude, optional accuracy, and optional capturedAt. |
contactPhone | string | Branch contact phone. |
contactEmail | string | Branch contact email. |
website | string | Branch website. |
emergencyContact | string | Emergency contact phone. |
openingHours | object | Schedule object with schedule, timezone, and is24Hours. |
coverImageUrl | string | Cover image URL. |
status | string | active, inactive, coming_soon, or temporarily_closed. |
isActive | boolean | Active flag. |
isDeleted | boolean | Soft delete flag. |
deletedAt | integer | Unix-ms timestamp when soft deleted; omitted when not deleted. |
createdAt | integer | Unix-ms creation timestamp. |
updatedAt | integer | Unix-ms update timestamp. |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "organizationBranches",
"apiName": "getById",
"data": {
"id": "branch_123",
"organizationId": "org_123"
}
}'Example Response
{
"status": "ok",
"data": {
"_id": "branch_123",
"organizationId": "org_123",
"branchName": "Anna Nagar Branch",
"branchCode": "ANNA",
"branchType": "clinic",
"description": "Primary dental branch for Anna Nagar.",
"managerName": "Priya Raman",
"managerContact": "+919876543210",
"streetAddress": "12, 2nd Avenue",
"area": "Anna Nagar",
"city": "Chennai",
"state": "Tamil Nadu",
"postalCode": "600040",
"country": "India",
"coordinates": {
"latitude": 13.0405271553947,
"longitude": 80.21238,
"accuracy": 316,
"capturedAt": 1779971037247
},
"contactPhone": "+914412345678",
"contactEmail": "annanagar@example.com",
"website": "https://example.com/anna-nagar",
"emergencyContact": "+919123456789",
"openingHours": {
"schedule": {
"monday": [
{
"start": "09:00",
"end": "18:00"
}
]
},
"timezone": "Asia/Kolkata",
"is24Hours": false
},
"coverImageUrl": "https://example.com/images/anna-nagar.jpg",
"status": "active",
"isActive": true,
"isDeleted": false,
"createdAt": 1779971037247,
"updatedAt": 1779971037247
}
}listByOrganization
Source: backend/endpoints/organization-branches/list-by-organization
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
organizationId | string | Yes | - |
search | string | No | - |
page | integer | No | default: 1 |
pageSize | integer | No | default: 20 |
List Rules
- Lists non-deleted branches for one organization.
- Supports
pageandpageSize; defaults are handled by the backend.
Response Data Format
| Field | Type | Notes |
|---|---|---|
items | array<OrganizationBranch> | Non-deleted branches for the requested organization. Each item has the same shape as getById. |
total | integer | Total matching branch count before pagination. |
page | integer | Current page number. |
pageSize | integer | Number of records requested per page. |
totalPages | integer | Total pages calculated from total and pageSize. |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "organizationBranches",
"apiName": "listByOrganization",
"data": {
"organizationId": "org_123",
"page": 1,
"pageSize": 20
}
}'Example Response
{
"status": "ok",
"data": {
"items": [
{
"_id": "branch_123",
"organizationId": "org_123",
"branchName": "Anna Nagar Branch",
"branchCode": "ANNA",
"branchType": "clinic",
"description": "Primary dental branch for Anna Nagar.",
"managerName": "Priya Raman",
"managerContact": "+919876543210",
"streetAddress": "12, 2nd Avenue",
"area": "Anna Nagar",
"city": "Chennai",
"state": "Tamil Nadu",
"postalCode": "600040",
"country": "India",
"coordinates": {
"latitude": 13.0405271553947,
"longitude": 80.21238,
"accuracy": 316,
"capturedAt": 1779971037247
},
"contactPhone": "+914412345678",
"contactEmail": "annanagar@example.com",
"website": "https://example.com/anna-nagar",
"emergencyContact": "+919123456789",
"openingHours": {
"schedule": {
"monday": [
{
"start": "09:00",
"end": "18:00"
}
]
},
"timezone": "Asia/Kolkata",
"is24Hours": false
},
"coverImageUrl": "https://example.com/images/anna-nagar.jpg",
"status": "active",
"isActive": true,
"isDeleted": false,
"createdAt": 1779971037247,
"updatedAt": 1779971037247
}
],
"total": 1,
"page": 1,
"pageSize": 20,
"totalPages": 1
}
}update
Source: backend/endpoints/organization-branches/update
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
id | string | Yes | - |
organizationId | string | Yes | - |
branchName | string | No | nullable |
branchCode | string | No | unique per organization among non-deleted branches; nullable |
branchType | string | No | nullable |
description | string | No | nullable |
managerName | string | No | nullable |
managerContact | string | No | international phone format; nullable |
streetAddress | string | No | nullable |
area | string | No | nullable |
city | string | No | nullable |
state | string | No | nullable |
postalCode | string | No | nullable |
country | string | No | nullable |
coordinates | object | No | object with numeric latitude and longitude; nullable |
contactPhone | string | No | international phone format; nullable |
telephoneNumber | string | No | nullable |
contactEmail | string | No | nullable |
website | string | No | nullable |
emergencyContact | string | No | international phone format; nullable |
openingHours | object | No | object with schedule, timezone, and is24Hours; nullable |
coverImageUrl | string | No | nullable |
status | string | No | oneof: active |
isActive | boolean | No | nullable |
createdAt | integer | No | unix-ms timestamp; nullable |
updatedAt | integer | No | unix-ms timestamp; nullable |
Business Rules
idandorganizationIdare required.- The branch must exist under the organization and must not be deleted.
- If
branchCodeis changed, it must remain unique among non-deleted branches for the same organization.
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "organizationBranches",
"apiName": "update",
"data": {
"id": "branch_123",
"organizationId": "org_123",
"branchName": "Anna Nagar Branch",
"branchCode": "ANNA",
"status": "active",
"contactPhone": "+914412345678",
"coordinates": {
"latitude": 13.0405271553947,
"longitude": 80.21238,
"accuracy": 316,
"capturedAt": 1779971037247
},
"openingHours": {
"schedule": {
"monday": [
{
"start": "09:00",
"end": "18:00"
}
]
},
"timezone": "Asia/Kolkata",
"is24Hours": false
}
}
}'Example Response
{
"status": "ok",
"data": "branch_123"
}