> ErrorCapture _

API Reference

Build your own integration in any language. All you need is an HTTP client that can POST JSON.

Base URL: https://errorcapture.com/api.php

POST /api.php

Submit an error. This is the main endpoint your application calls when an error occurs.

Headers

Content-Type required application/json

Request body

hash required Your project key
level required Error severity, e.g. Fatal Error, Warning, Notice
message required The error message
file optional Source file path
line optional Line number (integer)
hostname optional Server or machine name
request optional Object with method, url, get, post fields

Example

curl -X POST https://errorcapture.com/api.php \
  -H "Content-Type: application/json" \
  -d '{
    "hash": "your-project-key",
    "level": "Warning",
    "message": "Undefined variable $foo",
    "file": "/var/www/app/index.php",
    "line": 42,
    "hostname": "dev-machine",
    "request": {
      "method": "GET",
      "url": "http://localhost/page?id=5",
      "get": {"id": "5"},
      "post": null
    }
  }'

Response

{"ok": true, "id": 1}

If the project key doesn't exist yet, it will be auto-created. The request object is entirely optional — you can send just hash, level, and message for a minimal integration.

GET /api.php?action=generate

Generate a new project key.

Parameters

name optional A label for the project

Example

curl "https://errorcapture.com/api.php?action=generate&name=my-app"

Response

{"hash": "62e12151cb074f9a676a48a521ae0cdb"}
GET /api.php?action=errors

Fetch errors for a project. Supports pagination via the since parameter.

Parameters

hash required Your project key
since optional Return only errors with id greater than this value (for polling)

Example

curl "https://errorcapture.com/api.php?action=errors&hash=your-key&since=0"

Response

{
  "errors": [
    {
      "id": 1,
      "level": "Warning",
      "message": "Undefined variable $foo",
      "file": "/var/www/app/index.php",
      "line": 42,
      "url": "http://localhost/page?id=5",
      "method": "GET",
      "get_params": {"id": "5"},
      "post_params": null,
      "hostname": "dev-machine",
      "received_at": "2026-04-14 12:00:00"
    }
  ]
}
GET /api.php?action=clear

Delete all errors for a project.

Parameters

hash required Your project key

Example

curl "https://errorcapture.com/api.php?action=clear&hash=your-key"

Response

{"ok": true, "deleted": 4}

Integration examples

The API accepts standard JSON over HTTP, so you can report errors from any language or framework.

Python

import requests, traceback, sys

ERRORCAPTURE_ENDPOINT = "https://errorcapture.com/api.php"
ERRORCAPTURE_HASH = "your-key"

def report_error(exc_type, exc_value, exc_tb):
    tb = traceback.extract_tb(exc_tb)[-1] if exc_tb else None
    requests.post(ERRORCAPTURE_ENDPOINT, json={
        "hash": ERRORCAPTURE_HASH,
        "level": exc_type.__name__,
        "message": str(exc_value),
        "file": tb.filename if tb else "",
        "line": tb.lineno if tb else 0,
    })
    sys.__excepthook__(exc_type, exc_value, exc_tb)

sys.excepthook = report_error

Node.js

const ERRORCAPTURE_ENDPOINT = "https://errorcapture.com/api.php";
const ERRORCAPTURE_HASH = "your-key";

process.on("uncaughtException", (err) => {
  const match = err.stack?.match(/at .+? \((.+?):(\d+):\d+\)/);
  fetch(ERRORCAPTURE_ENDPOINT, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      hash: ERRORCAPTURE_HASH,
      level: err.name,
      message: err.message,
      file: match?.[1] ?? "",
      line: parseInt(match?.[2] ?? "0"),
    }),
  }).catch(() => {});
  process.exit(1);
});

Bash / cURL

Useful for reporting errors from shell scripts or CI pipelines:

report_error() {
  curl -s -X POST "https://errorcapture.com/api.php" \
    -H "Content-Type: application/json" \
    -d "{
      \"hash\": \"your-key\",
      \"level\": \"$1\",
      \"message\": \"$2\",
      \"file\": \"${BASH_SOURCE[1]:-unknown}\",
      \"line\": ${BASH_LINENO[0]:-0}
    }"
}

# Usage:
report_error "Error" "Deploy failed: migration returned non-zero"

Minimal POST (any language)

At its simplest, the API just needs three fields. Send this JSON as a POST:

{
  "hash": "your-project-key",
  "level": "Error",
  "message": "Something went wrong"
}

Everything else (file, line, hostname, request) is optional context that makes the dashboard more useful but isn't required.