Skip to content

Errors API

Report errors to MiniAPM for tracking, grouping, and analysis.

POST /ingest/errors
HeaderRequiredDescription
AuthorizationYesBearer <api_key>
Content-TypeYesapplication/json
{
"error_type": "RuntimeError",
"message": "Something went wrong",
"backtrace": [
"app/models/user.rb:42:in `save`",
"app/controllers/users_controller.rb:15:in `create`"
],
"context": {
"user_id": 123,
"request_id": "abc-123-def"
},
"environment": "production",
"git_sha": "abc123def",
"happened_at": "2024-01-01T12:00:00Z"
}
FieldTypeRequiredDescription
error_typestringYesException class name
messagestringYesError message
backtracearrayNoStack trace lines
contextobjectNoAdditional context data
environmentstringNoEnvironment name
git_shastringNoGit commit SHA
happened_atstringNoISO 8601 timestamp
user_idstringNoUser identifier
request_idstringNoRequest identifier
trace_idstringNoTrace ID for linking
span_idstringNoSpan ID for linking
{
"id": "err_abc123",
"fingerprint": "a1b2c3d4e5f6"
}
Terminal window
curl -X POST http://localhost:3000/ingest/errors \
-H "Authorization: Bearer proj_abc123..." \
-H "Content-Type: application/json" \
-d '{
"error_type": "ActiveRecord::RecordNotFound",
"message": "Could not find User with id=999",
"backtrace": [
"app/controllers/users_controller.rb:10:in `show`",
"lib/middleware/auth.rb:25:in `call`"
],
"context": {
"user_id": 123,
"params": { "id": "999" }
},
"environment": "production"
}'

Report multiple errors in a single request.

POST /ingest/errors/batch
{
"errors": [
{
"error_type": "RuntimeError",
"message": "Error 1",
"backtrace": ["..."]
},
{
"error_type": "NoMethodError",
"message": "Error 2",
"backtrace": ["..."]
}
]
}
{
"accepted": 2,
"errors": []
}

MiniAPM automatically groups errors by fingerprint, which is computed from:

  1. Error type (class name)
  2. Error message (normalized)
  3. Top stack frame location

Errors with the same fingerprint are grouped together, showing:

  • First seen timestamp
  • Last seen timestamp
  • Occurrence count
  • Trend over time

If you include file paths in your backtrace, MiniAPM can display source context (lines before/after the error). Send structured backtrace entries:

{
"backtrace": [
{
"file": "app/models/user.rb",
"line": 42,
"method": "save",
"pre_context": [" def save", " validate!"],
"context_line": " raise 'Invalid' unless valid?",
"post_context": [" end", ""]
}
]
}

Errors can be managed through the web UI:

  • Open - New or active error
  • Resolved - Fixed, but can reopen if it recurs
  • Ignored - Won’t show in dashboard
begin
risky_operation
rescue => e
MiniAPM.record_error(e, context: {
user_id: current_user.id,
params: request.params.except(:password)
})
raise
end

The miniapm gem captures exceptions automatically in Rails.

import requests
def report_error(exception, context=None):
import traceback
requests.post(
'http://localhost:3000/ingest/errors',
headers={
'Authorization': 'Bearer proj_abc123...',
'Content-Type': 'application/json'
},
json={
'error_type': type(exception).__name__,
'message': str(exception),
'backtrace': traceback.format_exception(exception),
'context': context or {}
}
)
async function reportError(error, context = {}) {
await fetch('http://localhost:3000/ingest/errors', {
method: 'POST',
headers: {
'Authorization': 'Bearer proj_abc123...',
'Content-Type': 'application/json'
},
body: JSON.stringify({
error_type: error.name,
message: error.message,
backtrace: error.stack?.split('\n') || [],
context
})
});
}