Runbeam SDK
A Rust library for integrating with the Runbeam Cloud API.
Features
- Dual Authentication Support
- JWT Token Validation - RS256 signature verification with automatic JWKS caching
- Laravel Sanctum API Tokens - Server-side validation for simpler auth flows
- API Client - Comprehensive HTTP client for Runbeam Cloud API
- Gateway management (list, get, create, update, delete)
- Service management (list, get, create, update, delete)
- Endpoint, Backend, and Pipeline management
- Gateway authorization and token management
- Secure Token Storage - Automatic secure storage with OS keychain or encrypted filesystem
- Keyring (OS-native): macOS Keychain, Linux Secret Service, Windows Credential Manager
- Encrypted Filesystem fallback: age encryption with instance-specific keys
- No configuration required - automatically selects best option
- Machine Tokens - Autonomous gateway authentication with 30-day expiry
- Instance Isolation - Multiple instances can coexist with separate storage
- Cross-Platform - Works on macOS, Linux, and Windows
Installation
Add to your Cargo.toml:
[]
= "0.5.0"
Quick Start
Using JWT Tokens
use ;
async
Using Runbeam Tokens
use ;
async
Authentication Methods
The SDK supports two authentication methods:
JWT Token Authentication
JWT tokens are validated locally using RS256 signature verification with JWKS endpoint discovery.
Use JWT tokens when:
- You need local token validation before making API calls
- You need to extract claims (user info, team info) from the token
- You're working with existing JWT-based infrastructure
- You want to verify token authenticity without server roundtrips
Authorization Flow:
- CLI sends user JWT token to Harmony Management API
- Harmony validates JWT locally (signature verification via JWKS)
- Harmony exchanges user JWT for machine token from Runbeam Cloud
- Runbeam Cloud issues machine-scoped token (30-day expiry)
- Machine token is stored securely for autonomous API access
Laravel Sanctum API Token Authentication
Sanctum tokens (format: {id}|{token}) are passed directly to the server for validation.
Use Sanctum tokens when:
- You want simpler authentication without local validation complexity
- Your application doesn't need to inspect token claims locally
- You're integrating with Laravel-based authentication systems
- You prefer server-side token validation
Authorization Flow:
- CLI sends user Sanctum API token to Harmony Management API
- Harmony passes token directly to Runbeam Cloud (no local validation)
- Runbeam Cloud validates token and issues machine-scoped token (30-day expiry)
- Machine token is stored securely for autonomous API access
Note: All API methods accept both JWT and Sanctum tokens interchangeably.
Secure Token Storage
The SDK automatically manages secure token storage with no configuration required.
Automatic Storage Selection
When you call save_token(), load_token(), or clear_token(), the SDK automatically:
- Tries OS Keyring first (macOS Keychain, Linux Secret Service, Windows Credential Manager)
- Falls back to Encrypted Filesystem if keyring unavailable (headless/CI/CD environments)
Instance Isolation
Each instance gets its own isolated storage using an instance_id:
use ;
// Each instance_id gets separate storage at ~/.runbeam/<instance_id>/
let instance_id = "harmony-production";
// Save token
save_token.await?;
// Load token
if let Some = load_token.await?
// Clear token
clear_token.await?;
Encryption Key Management
When using encrypted filesystem storage (fallback), keys are sourced from:
-
RUNBEAM_ENCRYPTION_KEYenvironment variable (production/containers) -
Auto-generated key at
~/.runbeam/<instance_id>/encryption.key(development)- Created with restrictive permissions (0600 on Unix)
- Persists across application restarts
Security Guarantees
✅ Tokens are NEVER stored unencrypted on disk ✅ Automatic keyring use when available ✅ age X25519 encryption for filesystem storage ✅ Instance isolation - multiple instances can coexist ✅ Thread-safe for concurrent access
Development
Build
Test
Lint
Documentation
API Usage
All API methods accept JWT tokens, Sanctum tokens, or machine tokens for authentication.
List Gateways
use RunbeamClient;
async
Manage Services
use RunbeamClient;
async
Download Full Configuration
use RunbeamClient;
async
Architecture
runbeam_api/client.rs- HTTP client for Runbeam Cloud APIrunbeam_api/jwt.rs- JWT validation with JWKS cachingrunbeam_api/resources.rs- API resource types (Gateway, Service, etc.)runbeam_api/token_storage.rs- Token persistence operationsrunbeam_api/types.rs- Error types and API structuresstorage/mod.rs- Storage backend trait and implementations
License
Part of the Runbeam project.