Unified Logging — API, Function & Webhook Logs
Every request through moqapi is logged with its source type. Filter by API calls, mock requests, webhook deliveries, cron executions, or function invocations—all in a single unified log viewer.
// Source Types
Every log entry includes a source_type field that identifies where the request originated:
apiStandard API Gateway invocations via functions
mockMock API requests (resource + spec-based)
webhookWebhook test-fire deliveries
cronScheduled cron job executions
functionDirect function invocations
// Using the Log Viewer
Navigate to Logs in the dashboard sidebar. The log viewer supports:
Dropdown to filter by api, mock, webhook, cron, or function
Logs refresh automatically every few seconds
2xx green, 3xx blue, 4xx yellow, 5xx red
Shows the API or Mock API name alongside the path
Each source type has a distinct color badge in the table
// Query Logs via API
# All logs (latest 100)
curl https://moqapi.dev/api/logs
# Filter by source type
curl "https://moqapi.dev/api/logs?sourceType=mock"
curl "https://moqapi.dev/api/logs?sourceType=webhook"
curl "https://moqapi.dev/api/logs?sourceType=cron"
# Combine with search
curl "https://moqapi.dev/api/logs?sourceType=mock&search=pet"{
"logs": [
{
"id": "log-uuid",
"request_method": "GET",
"request_path": "/pet/findByStatus",
"response_status": 200,
"response_time_ms": 45,
"source_type": "mock",
"api_name": "Petstore",
"mock_api_id": "mock-uuid",
"created_at": "2025-01-15T10:30:00Z"
},
{
"id": "log-uuid-2",
"request_method": "POST",
"request_path": "https://hooks.slack.com/T1/B2/abc",
"response_status": 200,
"response_time_ms": 312,
"source_type": "webhook",
"webhook_name": "Slack Notification",
"webhook_id": "wh-uuid",
"created_at": "2025-01-15T10:28:00Z"
}
]
}// What Gets Logged
| Source | Trigger | Logged Fields |
|---|---|---|
api | API Gateway request via /api/invoke/fn/... | method, path, status, response time, API name |
mock | Mock API request via /api/invoke/mock/... | method, path, status, response time, mock API name/ID |
webhook | Webhook test-fire delivery | target URL, status, response time, webhook ID |
cron | Scheduled cron execution | cron name, function ID, status, execution time |
function | Direct function invocation | function name, status, execution time, error message |
// Log Cleanup
Admins can purge old logs from Settings → Admin Cleanup. Choose a retention period (7, 14, 30, or 90 days) and purge logs older than that threshold.
# Purge logs older than 30 days (admin only)
curl -X POST https://moqapi.dev/api/admin/cleanup \
-H "Content-Type: application/json" \
-d '{
"action": "purge_logs",
"olderThanDays": 30
}'
# Check log stats
curl -X POST https://moqapi.dev/api/admin/cleanup \
-H "Content-Type: application/json" \
-d '{ "action": "stats" }'// API Reference
/api/logs/api/admin/cleanup