To send traces from an application, use the Python SDK or a raw OTLP exporter instead of hand-written calls. The SDK batches, retries, and formats spans for you. The endpoints below are for reading resources and for custom integrations.
Reach the API at /api/public
Every endpoint lives under the/api/public path on your Surface Area host. On the hosted platform the base URL is https://withgateway.ai/api/public; on a self-hosted instance, swap in your own host.
The examples on these pages use the same three environment variables as the SDK.
Authenticate with HTTP Basic auth
Authenticate with your project’s API key pair using HTTP Basic auth. The public key (pk-lf-...) is the username and the secret key (sk-lf-...) is the password. Generate a pair under Project Settings, then send it on every request.
-u flag builds the Authorization: Basic <base64> header for you. To build the header by hand, base64-encode the two keys joined by a colon.
Keep the secret key in an environment variable or secrets manager. Never inline it in source files, commit it, or paste it into an agent prompt.
Page through list results
List endpoints return a fixed envelope: adata array plus a meta object with the current page and totals. Request a page with the page and limit query parameters.
totalPages, or divide totalItems by limit, to know how many pages remain. A few high-volume endpoints (such as GET /v2/observations) use an opaque cursor instead of page; their reference rows say so.
Timestamps are ISO 8601
Send and read timestamps as ISO 8601 strings with an offset, for example2024-01-15T09:00:00Z. Time-range filters on list endpoints use fromTimestamp (inclusive) and toTimestamp (exclusive).
Errors return JSON with a message
Every error responds with a JSON body carrying a human-readablemessage. Most errors add an error field naming the error type; validation errors instead list the specific field problems under error.
Ingestion is the exception. A batch ingestion call returns
207 Multi-Status with per-event successes and errors, so one bad event does not fail the whole batch.
Send traces over OTLP (preferred for ingestion)
Surface Area accepts traces over the OpenTelemetry Protocol (OTLP) atPOST /api/public/otel/v1/traces. tracing.init() points at the same endpoint.
The endpoint accepts an OTLP ExportTraceServiceRequest as either Protocol Buffers (Content-Type: application/x-protobuf) or JSON (Content-Type: application/json), and it decompresses gzipped bodies. Authenticate with the same HTTP Basic keys.
POST /api/public/otel/v1/metrics. For the full export walkthrough, including batching, flushing, and endpoint overrides, see Export to Surface Area.
Ingest events in a batch
The batch ingestion endpoint,POST /api/public/ingestion, accepts a mixed list of trace, observation, and score events in one call. It backs the SDK’s own ingestion path.
Send a JSON body with a batch array and optional metadata. Each event needs a type, an id, a timestamp, and a body. The response is 207 Multi-Status.
Use OTLP or the SDK first. Batch ingestion is the lower-level path the SDK builds on.
Query and manage from the MCP endpoint
Surface Area exposes a Model Context Protocol (MCP) endpoint atPOST /api/public/mcp so AI assistants can query and manage a project over JSON-RPC 2.0. Authenticate with either the HTTP Basic key pair (one project) or a personal access token.
With a personal access token, send Authorization: Bearer pat_... and name the project in the query string as ?project_id=<id>. Set the Accept header to application/json, text/event-stream, since the endpoint may answer with plain JSON or a server-sent-events stream.
Where to go next
- Core Resources: the route tables and a worked
curlexample for every resource. - Tracing: instrument an agent and export its spans.
- MCP Server: drive Surface Area from an AI assistant.