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:

api

Standard API Gateway invocations via functions

mock

Mock API requests (resource + spec-based)

webhook

Webhook test-fire deliveries

cron

Scheduled cron job executions

function

Direct function invocations

// Using the Log Viewer

Navigate to Logs in the dashboard sidebar. The log viewer supports:

Source Type Filter

Dropdown to filter by api, mock, webhook, cron, or function

Real-Time Polling

Logs refresh automatically every few seconds

Status Code Colors

2xx green, 3xx blue, 4xx yellow, 5xx red

API Name Resolution

Shows the API or Mock API name alongside the path

Color-Coded Badges

Each source type has a distinct color badge in the table

// Query Logs via API

terminalbash
# 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"
response.jsonjson
{
  "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

SourceTriggerLogged Fields
apiAPI Gateway request via /api/invoke/fn/...method, path, status, response time, API name
mockMock API request via /api/invoke/mock/...method, path, status, response time, mock API name/ID
webhookWebhook test-fire deliverytarget URL, status, response time, webhook ID
cronScheduled cron executioncron name, function ID, status, execution time
functionDirect function invocationfunction 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.

terminalbash
# 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

GET/api/logs
POST/api/admin/cleanup