API Documentation

REST API documentation for the FileMaker WebViewer application.

Base URL

Development: http://localhost:3000/api
Production: https://your-domain.com/api

Endpoints
GET /activities

Get all activities with pagination and filtering

Query Parameters:
  • page (integer): Page number (default: 1)
  • limit (integer): Items per page (default: 10, max: 100)
  • companyId (string): Filter by company ID
  • activityOwner (string): Filter by creator
  • key (string): Filter by activity type
  • status (integer): Filter by status (0=inactive, 1=active)
  • search (string): Search in value and key fields
  • sortBy (string): Sort field (createdAt, updatedAt, key, activityOwner, status)
  • sortOrder (string): Sort order (ASC, DESC)

POST /activities

Create a new activity

Request Body:
{
  "value": "Note content here",
  "companyId": "677E86E4-0BBC-4E17-91B2-008B381FE1BD",
  "key": "Note"  // optional, defaults to "Note"
}

GET /activities/company/{companyId}

Get activities for a specific company

Path Parameters:
  • companyId (string): Company UUID
Query Parameters:

Same as GET /activities


GET /activities/{id}

Get a single activity by ID

Path Parameters:
  • id (string): Activity UUID

PUT /activities/{id}

Update an activity's value

Path Parameters:
  • id (string): Activity UUID
Request Body:
{
  "value": "Updated activity value"
}

PATCH /activities/{id}

Same as PUT - Update an activity's value


GET /health

Health check endpoint


GET /test-db

Test database connection and show table information

Response Format
Paginated Response
{
  "data": [...],        // Array of activities
  "total": 416,         // Total count
  "page": 1,            // Current page
  "limit": 10,          // Items per page
  "totalPages": 42,     // Total pages
  "hasNext": true,      // Has next page
  "hasPrev": false      // Has previous page
}
Activity Object
{
  "id": "F7D949EB-6F14-264F-BDC5-D493732EC504",
  "value": "WorkOrder W574583-2 Submitted",
  "key": "Workorder",
  "activityOwner": "Quintin Driskell",
  "status": 0,
  "companyId": "677E86E4-0BBC-4E17-91B2-008B381FE1BD",
  "createdAt": "2025-06-16T15:14:00.000Z",
  "updatedAt": "2025-06-16T19:33:17.000Z",
  "createdBy": "Quintin Driskell",
  "updatedBy": null
}
Success Response (POST/PUT)
{
  "success": true,
  "data": { /* Activity object */ }
}
Error Response
{
  "error": "Internal Server Error",
  "message": "Failed to fetch activities",
  "details": "...",     // Only in development
  "timestamp": "2024-01-01T00:00:00.000Z"
}
Example Requests
Create a new note:
POST /api/activities
Content-Type: application/json

{
  "value": "Customer called about invoice #12345",
  "companyId": "677E86E4-0BBC-4E17-91B2-008B381FE1BD",
  "key": "Note"
}
Update an activity:
PUT /api/activities/F7D949EB-6F14-264F-BDC5-D493732EC504
Content-Type: application/json

{
  "value": "WorkOrder W574583-2 Completed"
}
Search for WorkOrder activities:
GET /api/activities?search=WorkOrder&limit=20
Get active activities for a company:
GET /api/activities/company/677E86E4-0BBC-4E17-91B2-008B381FE1BD?status=1
Get activities created by specific user:
GET /api/activities?activityOwner=mobileapp_api&sortBy=createdAt&sortOrder=DESC
Database Configuration

The application uses separate read and write database connections for optimal performance:

  • Read operations (GET requests) use the read-only Aurora endpoint
  • Write operations (POST, PUT, PATCH, DELETE) use the read-write Aurora endpoint

This ensures better load distribution and prevents read-only errors during write operations.