Header Logo

Best Practices for Securing Protoface REST API Calls in Voice and Video Agent Apps

Best Practices for Securing Protoface REST API Calls in Voice and Video Agent Apps

Secure Protoface REST API calls in voice/video agents: keep keys server-side, rotate secrets, rate-limit sessions, and use iframe embeds.

Introduction


When you add a realtime avatar to a voice or video agent, you are not just rendering a UI component. You are creating an authenticated control plane for something that can start sessions, consume billed media resources, and speak on behalf of your product. That means the security model matters as much as the rendering pipeline.


This post focuses on practical ways to secure Protoface REST API calls in agent apps: how to keep API keys off clients, how to scope and rotate credentials, how to structure server-side calls, and how to think about browser embeds and realtime session lifecycles. By the end, you should be able to design an integration that is safe by default and operationally boring in the best possible way.


Keep the REST API server-side only


The first rule is simple: never call the REST API from a browser, mobile client, or any other untrusted runtime with a long-lived Protoface API key. The API uses Bearer authentication, and those keys are effectively high-value secrets. If a key leaks, an attacker can create sessions, manage avatars, and generate usage charges until you revoke it.


For web apps, the correct pattern is:


  1. Your frontend sends a request to your backend.

  2. Your backend validates the user and checks authorization.

  3. Your backend calls the Protoface REST API with the API key stored in server-side secret management.

  4. Your backend returns only the minimal data the client needs.


That may sound obvious, but realtime products often get tempted into shortcutting this with “temporary” client-side keys or exposed test credentials. Don’t do that. If the browser can see the credential, assume it will eventually be copied.


curl https://api.protoface.com/v1/sessions \
curl https://api.protoface.com/v1/sessions \
curl https://api.protoface.com/v1/sessions \


The exact request shape will depend on the endpoint and object model in the docs, but the pattern is the same: authenticate from the server, not the client. Keep the token in an environment variable or secret manager, and inject it only into outbound requests from trusted code.


Use narrow trust boundaries and short-lived delegation


Not every action requires full API authority. If your application has multiple backend services, separate the responsibilities that create or mutate avatars from the services that only need to read status or attach metadata. Even if the platform exposes a single API key format, you can still reduce risk by limiting where the key is available internally.


A useful mental model is to treat Protoface like any other privileged service: one service owns the secret, and every other component asks that service to perform the action. That keeps the blast radius of a compromised worker or misconfigured job much smaller.


For user-driven actions, validate the application-level authorization before you call Protoface. For example, if a customer can create a session for only one avatar tier, enforce that on your side before the REST call. Do not rely on the UI to prevent abuse; the backend should enforce quota, tenant ownership, and feature flags.


Rotate keys and design for revocation


Assume an API key will eventually need to be rotated. The two common failure modes are: keys embedded in too many places to change quickly, or systems that depend on a single static key with no rollout plan.


To avoid that, make these choices early:


  • Load keys from environment or secret manager, never from code.

  • Centralize outbound API access in one service if possible.

  • Log only key identifiers or prefixes, never full secrets.

  • Keep a documented rotation procedure and test it in staging.


If a key is exposed, rotation should be an operational action, not an architecture project. You want to revoke the old key, deploy the replacement, and confirm the affected paths still work without redeploying the entire application stack.


Protect session creation and lifecycle endpoints


Realtime avatar systems often have a sharp distinction between “control plane” operations and “media plane” traffic. The control plane creates avatars, sessions, and policy decisions. The media plane carries the voice/video stream and typically uses ephemeral session-scoped credentials or negotiated transport.


Even if the transport for the live session is separate from the REST API, the creation of that session is still security-sensitive. A common mistake is to allow any authenticated user to create unlimited sessions, which becomes an easy path to bill shock. Put limits in place at your application boundary:


  • Per-user and per-tenant session quotas

  • Per-minute creation rate limits

  • Expiration windows for unused sessions

  • Ownership checks before session teardown or reuse


Also think carefully about idempotency. If a client retries a “create session” request, you do not want to accidentally mint multiple billable sessions. If your backend has to retry outbound REST calls, use request identifiers or application-level deduplication so transient network failures do not create duplicate resources.


from protoface import ProtofaceClient
from protoface import ProtofaceClient
from protoface import ProtofaceClient


The Python SDK is useful because it keeps the REST boundary in one place and makes it easier to enforce your own policy before and after the call. That said, the SDK is not a security boundary by itself. If a developer can import it into browser code, they can still misuse it. The boundary is where you run it.


Browser embeds: prefer iframe isolation over exposing APIs


If your use case is to place an interactive avatar on a website, the safest default is a customer-managed iframe embed. This model is materially different from exposing the REST API to the browser: the browser never sees your API key, and the avatar runs in an isolated frame with an explicit parent-origin allowlist.


This is the right approach when you need a no-backend integration for marketing pages, product tours, or lightweight interactive experiences. Security-wise, it gives you a few advantages:


  • No API key in client JavaScript.

  • Origin allowlisting reduces cross-site embedding abuse.

  • Per-embed limits can cap duration and voice usage.

  • Custom instructions can be scoped to the specific embed instead of reused globally.


That isolation is important because the browser is an adversarial environment. Any secret that reaches the page can be inspected, proxied, or replayed. An iframe architecture avoids that entirely by moving the privileged operations out of the parent page.


Secure the LiveKit agent integration the same way


For voice agents, the LiveKit plugin pattern is usually where teams first connect a speech pipeline to a talking face. The security rule remains the same: the component that wires the avatar into the agent should run in trusted backend code, not in a client session.


In practice, that means your LiveKit agent process should own the Protoface credentials and create or attach the avatar server-side. Keep the agent’s own transport credentials separate from the Protoface API key, and do not reuse one secret for both systems. If the agent is compromised, you want the damage to stay within a clearly defined scope.


# Illustrative only; see the plugin repo for exact wiring
# Illustrative only; see the plugin repo for exact wiring
# Illustrative only; see the plugin repo for exact wiring


If you are working in a Pipecat-based stack instead of LiveKit, the same principles apply. The plugin should live in the trusted orchestration layer, and your browser client should never receive the raw credentials needed to create or manage avatars. The implementation details differ, but the trust model does not.


Logging, monitoring, and abuse detection


Security does not end at authentication. Realtime systems can be abused in ways that look like normal usage at the HTTP layer, so your observability should focus on both request volume and business signals.


At minimum, log:


  • Who requested the action, in your app’s identity terms

  • Which avatar or session was targeted

  • Whether the request succeeded or failed

  • How many sessions or minutes were consumed


Avoid logging full request bodies if they contain user prompts, voice instructions, or other sensitive content. If you need troubleshooting detail, redact or hash the parts that do not need to be human-readable.


Alert on unusual patterns such as repeated failed session creation, sharp spikes in avatar creation, or requests from tenants that are well outside normal usage. Realtime avatars are expensive enough that abuse usually shows up in spend before it shows up as a classic security incident.


How Protoface fits into the secure pattern


The relevant Protoface surfaces support this architecture cleanly. Use the REST API and Python SDK from backend services only, keep secrets out of the browser, and use the iframe embed when you intentionally want a no-backend web integration with built-in origin restrictions. The public docs at https://docs.protoface.com and the quickstarts in the GitHub organization are the right places to verify exact request fields and supported flows before you wire them into production.


For LiveKit-based voice agents, the plugin pattern is especially straightforward: your agent process stays in control, your users never see the credentials, and the avatar lifecycle remains a server-side concern. That separation is exactly what you want for a service that can speak, animate, and accumulate usage in real time.


Conclusion


The secure default for Protoface is the same as for any privileged realtime API: keep API keys server-side, enforce authorization in your own backend, rate limit session creation, rotate secrets cleanly, and use iframe embeds when you want browser-based interaction without exposing credentials. If you follow those rules, the integration stays simple and the security model stays legible.


When you are ready to implement, start with the docs at https://docs.protoface.com, then pick the integration surface that matches your app: REST API for control-plane operations, Python SDK for backend automation, LiveKit plugin for voice agents, or iframe embeds for isolated web experiences.

Add a face to your AI.

No credit card needed.

Add a face to your AI.

No credit card needed.

Add a face to your AI.

No credit card needed.