MediaSFU Blog

What Is a Widget Key?

· Guide

Every MediaSFU widget — whether it's a Click-to-Call button, an AI agent, or a full meeting portal — requires a Widget Key to function. Think of it as a scoped API token specifically designed for client-side embeds.

ℹ️ Not a secret Unlike traditional API keys that you'd keep secret on your server, widget keys are meant to be visible in your HTML. They're embedded right in the page source. This is safe because of how they're designed.

Why Widget Keys Are Safe in Client-Side Code

Traditional API keys are dangerous in client code because they grant broad access. Widget keys are different:

🔒 Domain-locked

A widget key only works on the domains you authorize. Even if someone copies the key from your page source and puts it on their site — it won't work. The MediaSFU CDN checks the requesting origin before initializing.

🎯 Scoped to a single widget type

A Click-to-Call key can't be used to spin up an AI Agent session. Each key is tied to a specific widget type and configuration profile.

⚡ Rate-limited

Every key has built-in rate limiting. If someone tries to abuse a key (e.g., automated flood of call attempts), the system throttles and eventually blocks that key until you investigate.

♻️ Disposable

Keys are cheap to create and cheap to revoke. If anything looks wrong, generate a new key, update your embed, and the old key becomes useless. There's no "master key" situation.


Creating Your First Widget Key

Here's the step-by-step:

  1. Log in to your MediaSFU dashboard
  2. Navigate to Widgets in the sidebar
  3. Click Create Widget
  4. Choose your widget type (Call Button, AI Agent, Meeting Portal, Web Agent, Calls Dashboard, or Agents Dashboard)
  5. Configure the widget — appearance, behavior, connected phone numbers or AI agents
  6. Click Generate Key
  7. Copy the embed snippet

The snippet looks like this:

<script src="https://cdn.mediasfu.com/widget.js" async></script>
<mediasfu-call-button
  widget-key="wk_abc123def456"
  button-text="Talk to Sales"
  primary-color="#6366f1"
  theme="dark"
  position="bottom-right">
</mediasfu-call-button>

That's your entire integration. Paste it before </body> and you're live.


The Localhost Development Workflow

Every new widget key works on localhost by default. This is intentional — we want you to be able to develop and test without friction.

During development:

  • Keys work on localhost, 127.0.0.1, and localhost:* (any port)
  • All widget features function identically to production
  • Call routing, AI agent responses, meeting creation — everything is real
  • Usage still counts against your account (be mindful during heavy testing)
💡 Pro tip Create a dedicated "dev" widget key for testing. This way you can revoke it without affecting your production embeds, and you can track dev usage separately.

Locking Down for Production

When you're ready to go live, update the key's domain restrictions:

Dashboard → Widgets → [Your Widget] → Settings → Allowed Domains

Add your production domain(s):

yourdomain.com
www.yourdomain.com
app.yourdomain.com

You can add multiple domains. Subdomains need to be listed explicitly — yourdomain.com does not automatically cover app.yourdomain.com.

After adding domains:

  • The widget will only work on those listed domains
  • localhost access is removed unless you explicitly keep it in the list
  • Unauthorized origins get a silent failure (no console errors, no visible feedback)
⚠️ Recommendation Keep a separate key with localhost allowed for ongoing development. Use a different key — locked to production domains — for your live site.

Managing Multiple Widget Keys

Most real deployments use several keys:

Key Widget Type Domains Purpose
wk_prod_call Click-to-Call yoursite.com, www.yoursite.com Production website call button
wk_prod_agent AI Agent yoursite.com Production AI receptionist
wk_internal_dash Calls Dashboard admin.yoursite.com Internal call management
wk_internal_agents Agents Dashboard admin.yoursite.com Internal AI session monitoring
wk_dev_call Click-to-Call localhost Dev local development
wk_staging_all Meeting Portal staging.yoursite.com Staging environment

Each key has independent analytics, so you can see usage broken down by environment and purpose.


Public-Facing vs. Internal Widgets

This distinction matters for security planning:

Public-facing widgets Public

Click-to-Call, AI Agent, Meeting Portal, Web Agent

  • Embedded on pages accessible to anyone
  • Domain-locked to your public site
  • Rate-limited per visitor (IP-based)
  • Designed to handle anonymous, untrusted traffic
  • Self-healing — if an AI agent session crashes, the widget auto-recovers

Internal widgets Internal

Calls Dashboard, Agents Dashboard

  • Embedded behind your authentication layer
  • Domain-locked to internal domains (admin.*, ops.*, etc.)
  • Display sensitive operational data
  • Should never be on a publicly accessible page
  • Pair with your own RBAC (role-based access control) for who sees what
🚨 Critical rule Never put Calls Dashboard or Agents Dashboard widget keys on a public-facing page. Even with domain locking, these widgets show real-time call data that shouldn't be visible to the public.

Key Rotation and Security Hygiene

Best practices for ongoing security:

1. Rotate keys periodically

Even if nothing is wrong, rotate production keys every 90 days. Create a new key with the same configuration, update your embed, verify it works, then revoke the old key.

2. Use different keys per environment

Dev, staging, production — each should have its own key. This prevents dev testing from polluting production analytics and limits blast radius if a key leaks.

3. Monitor usage dashboards

Unusual spikes in call volume or AI sessions could indicate key abuse. Set up alerts if available.

4. Revoke immediately on breach

If you suspect a key has been exposed (e.g., committed to a public GitHub repo), revoke it immediately. Generate a new one. The transition takes seconds.

5. Keep embed codes in environment variables

If you're using React, Vue, or similar:

<mediasfu-call-button
  widget-key={process.env.REACT_APP_WIDGET_KEY}
  ...
/>

This way the key lives in .env and isn't hardcoded in your source repository. The key is still visible in the rendered HTML — that's fine because it's domain-locked — but it's not in your Git history.


What Happens When a Key Is Revoked?

When you revoke a widget key:

  1. The widget stops initializing on all domains within ~60 seconds (CDN cache TTL)
  2. No new calls, sessions, or meetings can be created with that key
  3. Active calls or sessions already in progress are not interrupted — they complete normally
  4. Usage data for the revoked key remains in your dashboard for auditing
  5. The key ID is permanently retired and cannot be reused

Pricing and Usage

Service Billing Notes
AI Agent sessions Per minute of agent time LLM provider costs included
Voice calls Per minute As low as $0.10/1K minutes
Meeting sessions Per participant-minute Includes recording if enabled
Widget keys Free No limit on quantity

There's no separate "widget fee." The widgets are a delivery mechanism; you pay for the underlying communication services they consume.


Getting Started Today

  1. Log in to mediasfu.com
  2. Navigate to Widgets
  3. Create your first widget — we recommend starting with Click-to-Call (simplest to test)
  4. Paste the embed on a local HTML file and open it
  5. Make a test call
  6. When ready, add your domain and deploy
✅ Five-minute setup The whole process takes under 5 minutes. No sales call, no contract, no minimum spend.

Have questions about widget keys or security? Reach out to our team or try the AI support agent right on our demos page.