API Reference

Detailed documentation for the Watchtower API.

API Reference

The Watchtower API is the primary way to send events to our platform. It's a simple, JSON-based REST API that you can use with any HTTP client.

Authentication

All API requests must be authenticated using a bearer token in the Authorization header. Your API key can be found on the Projects page in your dashboard.

Authorization: Bearer YOUR_API_KEY

API keys are prefixed with wt_.

Endpoints

Ingest Event

This is the primary endpoint for sending event data to Watchtower.

  • Endpoint: POST /api/events
  • Content-Type: application/json

Request Body

The request body must be a JSON object with the following fields:

| Field | Type | Required | Description | | :---------- | :------- | :------- | :----------------------------------------------------------------------- | | level | string | Yes | The severity of the event. Must be one of error, warn, or info. | | message | string | Yes | A human-readable message describing the event. | | projectId | string | Yes | The ID of the project this event belongs to. | | context | object | No | An optional JSON object containing additional data about the event. |

Example Request

curl -X POST https://app.watchtower.ai/api/events \
  -H "Authorization: Bearer wt_your_api_key" \
  -H "Content-Type: application/json" \
  -d 
    {
      "level": "error",
      "message": "Failed to process payment",
      "projectId": "proj_12345",
      "context": {
        "userId": "user_abc",
        "amount": 99.99,
        "currency": "USD"
      }
    }
  

AI Summarize

This endpoint provides AI-powered summaries of your recent events.

  • Endpoint: GET /api/ai/summarize
  • Authentication: Requires user session (not API key).

Query Parameters

| Parameter | Type | Description | | :-------- | :------- | :----------------------------------------------------------------------- | | limit | number | The maximum number of events to summarize. Defaults to 50. | | since | number | A Unix timestamp to fetch events since. |

Example Response

{
  "summary": "There has been a spike in payment processing errors over the last hour, primarily affecting users in the EU. The root cause appears to be a timeout when communicating with the payment gateway."
}