EMP-BUSINESS — API Configuration Document

Base URL

https://us-central1-emp-business-playstore.cloudfunctions.net

Authentication

All API requests require an API key sent via header:

x-api-key: <your-api-key>

or

Authorization: Bearer <your-api-key>

Generate an API key from the app: Profile → API Integration → Generate API Key

Keys expire after 1 year and can be revoked from the app.

API Endpoints

1. Get Employees

GET /getEmployees

Response

{
  "success": true,
  "count": 2,
  "data": [
    {
      "id": "uid123",
      "name": "John Doe",
      "email": "john@example.com",
      "phone": "+911234567890",
      "role": "employee",
      "status": "active",
      "createdAt": "2025-01-15T10:00:00.000Z",
      "lastLogin": "2026-02-27T08:30:00.000Z",
      "profileImage": "https://storage.googleapis.com/...",
      "balances": {
        "overtimeMinutes": 120,
        "casualLeaveUsed": 2,
        "sickLeaveUsed": 1,
        "compOffEarned": 3,
        "compOffUsed": 1,
        "permissionUsedHrs": 4,
        "permissionUsedMins": 30
      }
    }
  ],
  "timestamp": "2026-02-27T17:12:44.000Z"
}

2. Get Tasks

GET /getTasks
Query ParamTypeDefaultDescription
statusstringpending / in_progress / completed
employeeIdstringFilter by employee UID
startDateISO dateTasks created after this date
endDateISO dateTasks created before this date
limitinteger100Max results

Response

{
  "success": true,
  "count": 1,
  "data": [
    {
      "id": "taskId123",
      "title": "Repair AC Unit",
      "description": "Fix the AC at customer site",
      "status": "pending",
      "priority": "high",
      "assignedTo": "empUid123",
      "assignedToName": "John Doe",
      "createdAt": "2026-02-27T10:00:00.000Z",
      "dueDate": "2026-02-28T18:00:00.000Z",
      "completedAt": null,
      "location": { "address": "123 Main St" },
      "customerInfo": { "name": "Jane Smith", "phone": "+919876543210" }
    }
  ],
  "timestamp": "2026-02-27T17:12:44.000Z"
}

3. Get Attendance

GET /getAttendance
Query ParamTypeDefaultDescription
employeeIdstringFilter by employee UID
startDateISO dateRecords after this date
endDateISO dateRecords before this date
limitinteger100Max results

Response

{
  "success": true,
  "count": 1,
  "data": [
    {
      "id": "attId123",
      "employeeId": "empUid123",
      "employeeName": "John Doe",
      "date": "2026-02-27T00:00:00.000Z",
      "clockIn": "2026-02-27T09:00:00.000Z",
      "clockOut": "2026-02-27T18:00:00.000Z",
      "status": "present",
      "location": { "lat": 12.9716, "lng": 77.5946 },
      "totalHours": 9
    }
  ],
  "timestamp": "2026-02-27T17:12:44.000Z"
}

4. Get Services

GET /getServices
Query ParamTypeDefaultDescription
employeeIdstringFilter by employee UID
startDateISO dateCompleted after this date
endDateISO dateCompleted before this date
limitinteger100Max results

Response

{
  "success": true,
  "count": 1,
  "data": [
    {
      "id": "svcId123",
      "taskId": "taskId123",
      "employeeId": "empUid123",
      "employeeName": "John Doe",
      "customerName": "Jane Smith",
      "serviceType": "AC Repair",
      "status": "completed",
      "completedAt": "2026-02-27T15:30:00.000Z",
      "amount": 2500,
      "paymentMethod": "cash",
      "rating": 5,
      "notes": "Replaced compressor"
    }
  ],
  "timestamp": "2026-02-27T17:12:44.000Z"
}

5. Get Requests (Leave & Permissions)

GET /getRequests
Query ParamTypeDefaultDescription
typestringpermission or leave (omit for both)
statusstringpending / approved / rejected
employeeIdstringFilter by employee UID
limitinteger100Max results

Response

{
  "success": true,
  "count": 1,
  "data": [
    {
      "id": "reqId123",
      "type": "permission",
      "employeeId": "empUid123",
      "employeeName": "John Doe",
      "reason": "Doctor appointment",
      "status": "approved",
      "date": "2026-02-27",
      "fromTime": "14:00",
      "toTime": "16:00",
      "hours": 2,
      "createdAt": "2026-02-26T10:00:00.000Z",
      "updatedAt": "2026-02-26T12:00:00.000Z"
    }
  ],
  "timestamp": "2026-02-27T17:12:44.000Z"
}

6. Get API Analytics

GET /getApiAnalytics

Response

{
  "success": true,
  "data": {
    "apiCallsToday": 42,
    "webhookDeliveries": 15,
    "totalApiCalls": 1250,
    "endpoints": { "getEmployees": 10, "getTasks": 20, "getAttendance": 8, "getServices": 4 },
    "webhookEvents": { "task_created": 8, "task_completed": 5 },
    "date": "2026-02-27"
  },
  "timestamp": "2026-02-27T17:12:44.000Z"
}

Webhook Configuration

POST /webhook
x-api-key: <your-api-key>
Content-Type: application/json

Body

{
  "webhookUrl": "https://your-crm.com/webhook",
  "events": ["task_created", "task_completed", "service_completed", "request_created", "request_updated"]
}

Webhook Payload Format

{
  "event": "task_created",
  "timestamp": "2026-02-27T17:12:44.000Z",
  "data": {
    "taskId": "abc123",
    "title": "Repair AC",
    "status": "pending",
    "assignedTo": "empUid",
    "assignedToName": "John Doe",
    "adminId": "adminUid"
  }
}

Error Codes

HTTP StatusMeaning
401Missing, invalid, inactive, or expired API key
405HTTP method not allowed (use GET for data endpoints, POST for webhook)
500Internal server error

Error response format

{ "error": "Description of the error" }