Atlas Knowledge Base
Dashboard
API Proxy

API Proxy


The API Proxy is the single web entry point into SBN Media. SBN Anywhere and SBN Video clients, the SBN Media dashboard, and other applications all connect through it. It receives web requests, forwards them to the right service, and returns the response.

Overview

The API Proxy turns incoming web requests into messages for the services that do the work, then relays the result back. It is the only SBN Media service that normally needs to be reachable from outside the host - everything else sits behind it.

It also serves the SBN Media dashboard and the API documentation, and it is the connection point a browser uses to start a live video session.

  • Runs: When configured; at most one per host. A host that serves video or web clients needs one.
  • Required: Yes, for any host that serves clients. Without it, SBN Anywhere and SBN Video clients cannot reach SBN Media.
  • Depends on: NATS, which it uses to reach the other services.

Configuration

The API Proxy is configured under the apiproxy namespace. View the defaults with ./sbn-media config eject and set host-specific overrides in sbn-media.local.yaml.

SettingDefaultDescription
apiproxy.port8081The port the API Proxy listens on.
apiproxy.addressemptyThe address to bind to. Empty listens on all addresses.
apiproxy.protocolhttphttp or https. Use https in production.
apiproxy.publishedUrlemptyThe URL clients use to reach the API Proxy. Defaults to protocol://address:port.
apiproxy.allowOrigins*Which web origins may call the API Proxy. In production, set this to the origins of the applications that use it - for example your SBN Anywhere or SBN Video front end - rather than *.
apiproxy.requireTokentrueRequire a valid token on requests. Tokens are checked against the API Engine.
apiproxy.adminTokenemptyProtects the administrative routes. If it is not set, those routes are unavailable.
apiproxy.prometheusTokenemptyToken required to read Prometheus metrics.
apiproxy.maxBodySize10485760Largest request body accepted, in bytes (10 MB).
apiproxy.routessee belowTurns individual feature routes on or off.

Routes

Each feature of the API Proxy is a route that can be turned on or off under apiproxy.routes. A route that is off is not available. Routes marked "admin" require apiproxy.adminToken to be set and supplied by the caller.

RouteDefaultEnables
staticonThe SBN Media dashboard and sample client pages.
swaggeronThe API documentation at /api/docs.
webrtconLive video connections for SBN Video clients.
recordingonAccess to recorded video, and the download of routing call recordings and transcripts (see Downloading captures and recordings).
classifyonObject-detection endpoints.
sceneChangeonScene-change detection endpoints.
reidonRe-identification queries.
deviceonThe device registry.
apslonAction-plan script endpoints.
textToSpeechonListing the available text-to-speech voices.
foresightonForesight invite links.
watchdogonService control - start, stop, restart, health (admin).
logonLive and historical logs (admin).
pprofoffPerformance profiling, for diagnostics (admin).
signalTraceoffDownload raw call captures, for diagnostics (admin).
mediaCaptureoffList and download raw camera captures, for diagnostics (admin). A client can also fetch its own capture.
partnerLogoffThe partner log search API, including the packet capture download for a call. Requires a partner credential.
partnerLogUIoffThe partner log search web application. Requires partnerLog.
fileserveroffA local file server, for testing only.

Example:

apiproxy:
  port: 8081
  protocol: http

  # Only allow the applications that use the API Proxy (for example SBN Anywhere or SBN Video).
  allowOrigins: "https://your-sbn-anywhere"

  # Require a valid token, checked against the API Engine.
  requireToken: true

  # Set a strong token to enable the administrative routes.
  adminToken: "change-me"

  # Turn diagnostic routes on only when needed.
  routes:
    pprof: false
    signalTrace: false
    mediaCapture: false

After changing these settings in sbn-media.local.yaml, reload the configuration for them to take effect. Changing the listen address or port requires restarting the service.

Downloading captures and recordings

The API Proxy streams captures and recordings to the caller as downloads. It does not hold them itself: the service that owns the data prepares the file and the API Proxy relays it, so large downloads do not depend on the size of a single message.

Routing call recordings and transcripts

A call handled by the routing service can leave a recording and a transcript. Both are fetched through the recording route, using a bearer token in the Authorization header:

  • GET /api/routing-captures/{dealer}/{recordingId} returns the call recording as an MP4 file, named <recordingId>.mp4, as an attachment.
  • GET /api/routing-captures/{dealer}/{recordingId}/transcript returns the transcript of the same call.

The caller must be allowed to download recordings (the recording-download action) for the dealer. The recording is served only when a catalogue record for it is stored; a recording that has no stored record is answered as not found, including a recording that was split into several parts. The transcript is read without the catalogue record.

ResponseMeaning
200The file follows.
400The dealer or the recording id is not valid.
401No valid bearer token was supplied. The credential is checked before the id, so a request without one is refused whatever the id.
404The recording or transcript does not exist, the caller has no grant for it, the request was refused, or the backend could not answer. The body is empty in every case.

The 404 is deliberately the same for a missing grant and for a missing recording, so a caller cannot probe which recordings exist for another dealer. A caller who receives a 404 for a recording that should exist should check that the caller holds the recording-download action for that dealer, and that the call was recorded.

Raw call and camera captures

These are diagnostic downloads for support work. They are off by default and need the admin token.

  • signalTrace serves the captured legs of a call under /signal-trace. /signal-trace/{traceId} downloads a capture as a .tar file, /signal-trace/{traceId}/legs lists the captured legs of one call, and /signal-trace/{traceId}/all downloads every leg of the call as a single .tar file. An unknown call answers 404.
  • mediaCapture serves camera captures. /media-capture lists them, and /media-capture/{captureId} downloads one. A client that holds its own capture identifier can fetch it at /media-capture/self/{captureId} without the admin token. These routes are answered by the camera loader.

Partner packet capture

When partnerLog is on, a partner credential can download the packet capture of one of its own calls at GET /api/v1/partner/log/pcap/{tranId}. It is authenticated and scoped to the partner's tenant in the same way as the partner log search. A call that has no capture, or that the partner may not see, is answered as not found.

FAQ

SBN Video clients cannot connect. What should I check?

First confirm the API Proxy is running and reachable - check it in the dashboard, or open its address in a browser. Then confirm the port (8081 by default) is open on the network, and that apiproxy.allowOrigins includes the origin of the client application (for example SBN Anywhere or SBN Video). If the service will not start, run it in the foreground with sbn-media service exec apiproxy -ld to see the startup error.

How do I secure the API Proxy?

Use https for apiproxy.protocol, set apiproxy.allowOrigins to the origins of the applications that use it (such as SBN Anywhere or SBN Video) instead of *, keep apiproxy.requireToken set to true, and set a strong apiproxy.adminToken. Leave the diagnostic routes (pprof, signalTrace, mediaCapture, fileserver) off unless you are actively using them.

Why am I getting an unauthorized (401) response?

apiproxy.requireToken is on, so every request must carry a valid token, which the API Proxy checks against the API Engine. The administrative routes (service control, logs, profiling, signal trace, media capture) need the admin token as well - confirm apiproxy.adminToken is set and that the caller is supplying it. The routing call recording and transcript downloads need a bearer token in the Authorization header, and the partner routes need a partner credential; a request without one is refused before the recording id is looked at.

Why does a recording download answer 404 when the recording exists?

The download answers 404 for every case where it will not serve the file, so that a caller cannot tell a missing recording from one it may not see. Check that the caller holds the recording-download action for that dealer, that the recording has a stored catalogue record, and that the dealer in the URL is the dealer that owns the recording.

Do I need an API Proxy on every host?

You can run at most one per host, and you need at least one that clients can reach. In a multi-host setup it is common for each host to run its own so that a client can connect through any of them. A common production configuration places the API Proxy in a DMZ on several servers that load-balance incoming requests; the requests are then carried out by the other services behind them.

  • SBN Media Overview (SBN-Media/overview)
  • Deploying SBN Media (SBN-Media/deployment)
  • Watchdog (SBN-Media/Platform/watchdog)
  • Firewall (SBN-Media/Configuration/firewall)


Was this helpful?