Skip to main content
POST
POST /api/logs
The POST /api/logs endpoint receives error logs from vij-sdk or custom clients and stores them in MongoDB.

Request

string
required
The error message describing what went wrong.Example: "TypeError: Cannot read property 'map' of undefined"
string
required
The error name or type.Example: "TypeError", "ReferenceError", "CustomError"
string
required
Full stack trace of the error.Example:
string
required
Severity level of the error.Values: "error", "warning", "info"Default: "error"
string
required
ISO 8601 timestamp when the error occurred.Format: YYYY-MM-DDTHH:mm:ss.sssZExample: "2024-01-01T12:34:56.789Z"
string
required
Identifier for the application that generated the error.Example: "my-frontend-app", "backend-api", "mobile-app"
string
required
Environment where the error occurred.Example: "production", "staging", "development"
object
Custom metadata attached to the error.Example:
object
Environmental context (browser or Node.js information).Browser Context:
Node.js Context:

Response

boolean
Indicates whether the log was successfully stored.
string
MongoDB ObjectId of the created log entry.
string
Fingerprint hash used for error grouping.

Example Request

Example Response

Error Responses

Validation Rules

All of these fields must be present:
  • message
  • name
  • stack
  • severity
  • timestamp
  • appId
  • environment
Optional fields:
  • metadata (defaults to {})
  • context (defaults to {})
severity must be one of:
  • "error" - Critical errors
  • "warning" - Non-critical issues
  • "info" - Informational logs
Any other value will return a 400 error.
timestamp must be a valid ISO 8601 string:
  • Format: YYYY-MM-DDTHH:mm:ss.sssZ
  • Example: 2024-01-01T12:34:56.789Z
  • Must be in UTC (Z timezone)
Invalid formats will return a 400 error.
  • message: Max 10,000 characters
  • name: Max 500 characters
  • stack: Max 50,000 characters
  • appId: Max 100 characters
  • environment: Max 50 characters
Exceeding limits will truncate the value.

Rate Limiting

VIJ Admin does not enforce rate limiting by default. However, you should implement rate limiting in production to prevent abuse.
Recommended limits:
  • 1,000 requests per minute per IP
  • 10,000 requests per hour per appId
Implementation example:

CORS Configuration

VIJ Admin allows all origins by default for the /api/logs endpoint. Default CORS headers:
Custom CORS (if needed):

Processing Pipeline

When a log is received, VIJ processes it through these steps:
  1. Validation - Check required fields and formats
  2. Fingerprinting - Generate error group fingerprint
  3. Storage - Insert into MongoDB logs collection
  4. Indexing - Update MongoDB indexes
  5. Grouping - Update error group counters
  6. Response - Return success with log ID
Processing time: Typically < 50ms

Batch Logging

Send multiple logs in a single request:
Response:
The vij-sdk automatically batches logs to reduce network overhead.

Security Considerations

VIJ Admin does not require authentication for the /api/logs endpoint by default.Add authentication:
Never log sensitive information:
  • Passwords
  • API keys
  • Credit card numbers
  • Social security numbers
  • Personal identification
Sanitize before sending:
Prevent large payloads from overwhelming the server:

Troubleshooting

Common causes:
  • Missing required fields
  • Invalid severity value
  • Invalid timestamp format
  • Malformed JSON
Solution: Check request body matches schema exactly
Cause: Request body exceeds size limitSolution:
  • Reduce stack trace length
  • Minimize metadata
  • Use batch endpoint for multiple logs
Common causes:
  • MongoDB connection failure
  • Database write error
  • Server configuration issue
Solution: Check VIJ Admin logs and MongoDB connection
Symptom: Browser blocks requestSolution: Ensure CORS headers allow your domain or use * for all origins

GET /api/logs

Retrieve stored error logs

GET /api/stats

Get error statistics and metrics

GET /api/groups

Retrieve error groups

SDK Reference

Use vij-sdk for automatic logging