Integrations
Copy-paste Beam examples for backend, web, and mobile systems.
Every Beam integration follows the same pattern: create a session on your backend, hand the join token to your app or browser flow, and resolve the viewer metadata through /v1/join. The examples below use typed Beam sessions so you can choose screenshare or stream explicitly.
Base variables
BEAM_API_BASE=https://beam-api.example.com
BEAM_API_KEY=YOUR_BEAM_API_KEY
Replace the base URL with your reverse-proxied API origin if you terminate TLS elsewhere.
cURL
curl -X POST "$BEAM_API_BASE/v1/sessions" \
-H "Authorization: Bearer $BEAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "stream",
"stream_profile": "gaming",
"audio_enabled": true,
"purpose": "launch-day stream"
}'
PHP
<?php
$baseUrl = 'https://beam-api.example.com';
$payload = [
'mode' => 'screenshare',
'stream_profile' => 'balanced',
'audio_enabled' => true,
'purpose' => 'support escalation',
];
$ch = curl_init("$baseUrl/v1/sessions");
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('BEAM_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
?>
Laravel
use Illuminate\Support\Facades\Http;
$session = Http::withToken(config('services.beam.key'))
-post(config('services.beam.base_url') . '/v1/sessions', [
'mode' => 'stream',
'stream_profile' => 'gaming',
'audio_enabled' => true,
'purpose' => 'customer live demo',
'metadata' => [
'account_id' => $account->id,
],
])
-throw()
-json();
WordPress
<?php
$response = wp_remote_post('https://beam-api.example.com/v1/sessions', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('BEAM_API_KEY'),
'Content-Type' => 'application/json',
],
'body' => wp_json_encode([
'mode' => 'screenshare',
'stream_profile' => 'balanced',
'purpose' => 'member support',
'customer' => get_current_user_id(),
]),
]);
$body = json_decode(wp_remote_retrieve_body($response), true);
?>
Python
import os
import requests
resp = requests.post(
"https://beam-api.example.com/v1/sessions",
headers={"Authorization": f"Bearer {os.environ['BEAM_API_KEY']}"},
json={
"mode": "stream",
"stream_profile": "gaming",
"audio_enabled": True,
"purpose": "qa capture",
},
timeout=10,
)
resp.raise_for_status()
session = resp.json()
C#
using System.Net.Http.Headers;
using System.Net.Http.Json;
var http = new HttpClient { BaseAddress = new Uri("https://beam-api.example.com") };
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("BEAM_API_KEY"));
var response = await http.PostAsJsonAsync("/v1/sessions", new
{
mode = "screenshare",
stream_profile = "balanced",
audio_enabled = true,
purpose = "enterprise support"
});
response.EnsureSuccessStatusCode();
var session = await response.Content.ReadFromJsonAsync<JsonElement>();
Java
var client = java.net.http.HttpClient.newHttpClient();
var body = """
{
"mode":"stream",
"stream_profile":"gaming",
"audio_enabled":true,
"purpose":"app showcase"
}
""";
var request = java.net.http.HttpRequest.newBuilder()
.uri(java.net.URI.create("https://beam-api.example.com/v1/sessions"))
.header("Authorization", "Bearer " + System.getenv("BEAM_API_KEY"))
.header("Content-Type", "application/json")
.POST(java.net.http.HttpRequest.BodyPublishers.ofString(body))
.build();
var response = client.send(request, java.net.http.HttpResponse.BodyHandlers.ofString());
Android (Kotlin)
val payload = JSONObject()
.put("mode", "stream")
.put("stream_profile", "gaming")
.put("audio_enabled", true)
val request = Request.Builder()
.url("https://beam-api.example.com/v1/sessions")
.addHeader("Authorization", "Bearer ${BuildConfig.BEAM_API_KEY}")
.post(payload.toString().toRequestBody("application/json".toMediaType()))
.build()
iOS (Swift)
var request = URLRequest(url: URL(string: "https://beam-api.example.com/v1/sessions")!)
request.httpMethod = "POST"
request.setValue("Bearer \\(beamApiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try JSONSerialization.data(withJSONObject: [
"mode": "screenshare",
"stream_profile": "balanced",
"audio_enabled": true
])
Flutter
final response = await http.post(
Uri.parse('https://beam-api.example.com/v1/sessions'),
headers: {
'Authorization': 'Bearer $beamApiKey',
'Content-Type': 'application/json',
},
body: jsonEncode({
'mode': 'stream',
'stream_profile': 'gaming',
'audio_enabled': true,
}),
);
React Native
const response = await fetch('https://beam-api.example.com/v1/sessions', {
method: 'POST',
headers: {
Authorization: `Bearer ${beamApiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
mode: 'screenshare',
stream_profile: 'balanced',
audio_enabled: true,
}),
});
const session = await response.json();
Resolve join metadata anywhere
POST /v1/join
Content-Type: application/json
{
"join_token": "jt_01..."
}
The response gives you the relay host, signaling URL, browser WebRTC URL, stream profile, viewer protocols, and recommended settings. That same payload can drive a WordPress portal, a Laravel dashboard, a mobile app, or a custom viewer entry screen.