Skip to main content
Every API call your agent makes should be logged to Brain as a BackendEvent. Brain is the OTAS service that stores, indexes, and serves analytics for all observed activity. There are two ways to get events into Brain: the server-side SDK middleware (which captures in-domain requests automatically when your agent attaches a session token) and the direct agent log endpoint (which your agent calls manually after making any external API call). Both paths produce the same BackendEvent record — they differ only in the authentication mechanism and who initiates the log call.

Logging modes

This path is used by your project’s server-side middleware to automatically capture events for any request your agent makes within the project domain. Your agent does not call Brain directly — it simply attaches the session token to the in-domain request, and the middleware handles the rest.Endpoint: POST http://localhost:8002/api/v1/backend/log/sdk/Required headers:Example (server middleware):
Successful response:
The SDK log response does not include an event_id. Use the agent log endpoint if you need to track individual event IDs.

Required fields

Every event log request — regardless of which endpoint you use — must include these five fields. Requests missing any of them will be rejected with a 400 missing_required_fields error that lists which fields are absent.
string
required
UUID of the OTAS project this event belongs to. Must match the project associated with the SDK key or agent key you are using.
string
required
The API path that was called, e.g., /api/v1/some-resource. For external calls, use the path portion of the external URL.
string
required
The HTTP method used: GET, POST, PUT, PATCH, DELETE, etc.
integer
required
The HTTP status code returned by the API, e.g., 200, 201, 404, 500.
float
required
The measured round-trip time in milliseconds. This value is used directly in p50/p95/p99 latency analytics — measure it accurately.

Optional fields

These fields are not required but provide richer observability data and enable more detailed filtering in the OTAS dashboard.

Full example request body

The following example shows all fields populated — use this as a reference for out-of-domain log calls:

Error responses

Best practices

Measure latency_ms using a timer that starts immediately before you send the request and stops as soon as you receive the full response. This value drives p50, p95, and p99 latency analytics — inaccurate measurements will skew your percentile charts.
  • Set error to a non-empty string whenever the call fails or returns an error status code. This is what Brain uses to count errors in the error-rate analytics view.
  • Use custom_properties to attach agent-specific context (e.g., which LLM model was used, which tool was invoked) that is not captured by the standard fields.
  • Log out-of-domain events immediately after each call, not in a batch at the end of the task. Batching risks losing events if the process exits unexpectedly.