# errorgap via plain HTTP (no SDK)

See [index.md](./index.md) for API details and the placeholder values (`ERRORGAP_API_KEY`, `ERRORGAP_ENDPOINT`, `ERRORGAP_PROJECT_SLUG`).

Use this guide when no SDK exists for the user's platform. Errors are reported by POSTing JSON directly to the ingestion endpoint.

## Configure

Store the credentials in the app's environment (e.g. `.env`):

```sh
ERRORGAP_API_KEY=...
ERRORGAP_ENDPOINT=...
ERRORGAP_PROJECT_SLUG=...
```

## Report an error

`POST {ERRORGAP_ENDPOINT}/api/projects/{ERRORGAP_PROJECT_SLUG}/notices` with header `x-errorgap-project-key: {ERRORGAP_API_KEY}` and a JSON body:

```json
{
  "errors": [
    {
      "type": "RuntimeError",
      "message": "something went wrong",
      "backtrace": [
        { "file": "src/handler", "line": 42, "function": "handle" }
      ]
    }
  ],
  "context": { "environment": "production", "url": "https://example.com/path" },
  "params": {},
  "session": {}
}
```

Only `errors` (with `type` and `message`) is required. `context.environment` sets the environment shown in errorgap. Wire this into the platform's global exception hook so unhandled errors are reported automatically.

## Trigger a test error

```sh
curl -sS -X POST "$ERRORGAP_ENDPOINT/api/projects/$ERRORGAP_PROJECT_SLUG/notices" \
  -H "content-type: application/json" \
  -H "x-errorgap-project-key: $ERRORGAP_API_KEY" \
  -d '{"errors":[{"type":"ErrorgapInstallTest","message":"Errorgap install verification"}],"context":{"environment":"development"}}'
```

## Verify

The curl above should return HTTP 201 with a `group_id` in the JSON response (202 means received but sampled/rate-limited; 401 means a wrong or missing key). The errorgap onboarding screen advances automatically once the first event arrives.
