| title | API |
|---|---|
| description | Programmatic Rudel APIs. |
| path | api |
| order | 170 |
| section | Reference |
| meta_title | API |
| meta_description | Programmatic Rudel APIs. |
Use Rudel\Rudel when calling Rudel from WordPress code.
use Rudel\Rudel;Returns true when the current request is inside a Rudel sandbox.
Returns the current sandbox ID or null.
Returns the current Rudel\Environment object or null.
Returns request-level Rudel context.
$context = Rudel::context();Example keys:
[
'active' => true,
'environment_id' => 'alpha-1234',
'environment' => [/* environment array */],
'host_url' => 'http://localhost:8000',
]Standalone mode is for metadata access outside a live WordPress request.
Rudel::init( [
'db' => [
'host' => '127.0.0.1',
'database' => 'wordpress',
'username' => 'root',
'password' => 'root',
'prefix' => 'wp_',
],
'context' => [
'environments_dir' => '/var/www/html/wp-content/rudel-environments',
],
] );Standalone mode can list and inspect Rudel records. Creating, destroying, bootstrapping, and cloning require WordPress runtime services.
Lists sandbox records.
$environments = Rudel::environments( [
'status' => 'active',
] );Loads one sandbox by ID.
$environment = Rudel::environment_by_id( 'alpha-1234' );Creates a sandbox.
$sandbox = Rudel::create( 'alpha', [
'theme' => 'twentytwentyfour',
'owner' => 'dennis',
'labels' => [ 'qa', 'agent' ],
'ttl_days' => 7,
] );Supported options include:
themeclone_fromownerlabelspurposeprotectedttl_daysexpires_at
Updates lifecycle metadata for a sandbox.
Destroys a sandbox and its managed runtime state.
Runs cleanup policy.
Creates a snapshot.
Restores a snapshot.
Pushes tracked worktree changes for a sandbox.