Skip to main content

Playgrounds API

Manage Playgrounds — live, running instances of your environment blueprints.

Endpoints

MethodPathScopeDescription
GET/api/playgroundsplaygrounds:readList all Playgrounds
GET/api/playgrounds/:idplaygrounds:readGet a single Playground (detailed)
GET/api/playgrounds/:id/statusplaygrounds:readGet real-time status and service health
POST/api/playgroundsplaygrounds:writeCreate a new Playground
DELETE/api/playgrounds/:idplaygrounds:deleteDestroy a Playground
POST/api/playgrounds/:id/rolloutplaygrounds:writeRollout a Playground (incremental update)
POST/api/playgrounds/:id/hard_restartplaygrounds:writeHard restart a Playground (full teardown)
POST/api/playgrounds/:id/extend_expirationplaygrounds:writeExtend the TTL
GET/api/playgrounds/:id/composeplaygrounds:readGet the generated Compose YAML
GET/api/playgrounds/:id/logs/:serviceplaygrounds:readGet service logs
GET/api/playgrounds/:id/env_metadataplaygrounds:readGet merged environment variables with source metadata
GET/api/playgrounds/:id/debugplaygrounds:readGet detailed diagnostic info for troubleshooting

List Playgrounds

GET /api/playgrounds

Response:

[
{
"id": 1,
"name": "feature-auth",
"status": "running",
"job_mode": false,
"playspec_id": 1,
"playspec_name": "My Web Stack",
"service_branches": {
"web": { "branch_name": "feature/auth" }
},
"expires_at": "2025-01-15T18:30:00Z",
"created_at": "2025-01-15T10:30:00Z"
}
]

Get Playground (Detailed)

GET /api/playgrounds/:id

Response:

{
"id": 1,
"name": "feature-auth",
"status": "running",
"job_mode": false,
"playspec_id": 1,
"playspec_name": "My Web Stack",
"compose_project": "pg-1-feature-auth",
"service_branches": {
"web": { "branch_name": "feature/auth" }
},
"env_overrides": {
"DATABASE_URL": "postgres://db/myapp"
},
"expires_at": "2025-01-15T18:30:00Z",
"time_remaining": 28800.0,
"expiration_percentage": 0,
"last_applied_at": "2025-01-15T10:31:00Z",
"needs_recreation": false,
"services": [
{ "name": "web", "status": "running", "health": "healthy", "running": true },
{ "name": "db", "status": "running", "health": null, "running": true }
],
"created_at": "2025-01-15T10:30:00Z"
}

Get Status

GET /api/playgrounds/:id/status

Lightweight status endpoint — useful for polling during creation:

{
"id": 1,
"status": "in_progress",
"job_mode": false,
"creation_step": "image_build",
"creation_step_label": "Building Images",
"error_message": null,
"error_step": null,
"error_step_label": null,
"needs_recreation": false,
"services": [
{ "name": "web", "status": "stopped", "health": null, "running": false },
{ "name": "db", "status": "running", "health": null, "running": true }
]
}

Create Playground

POST /api/playgrounds

Request body:

{
"playground": {
"name": "feature-auth",
"playspec_id": 1,
"playroom_id": 1,
"job_mode": false,
"env_overrides": {
"DATABASE_URL": "postgres://db/myapp"
},
"service_subdomains": {
"web": "feature-auth-web"
},
"services": {
"web": {
"git_config": {
"branch_name": "feature/auth",
"create_branch": false
},
"production": false
}
}
}
}

Key fields:

FieldDescription
env_overridesGlobal environment variable overrides (applied to all services)
service_subdomainsPer-service subdomain overrides
services.{name}.git_config.branch_nameBranch to use for a dynamic service
services.{name}.git_config.create_branchCreate a new branch from base_branch_name
services.{name}.git_config.base_branch_nameBase branch when creating a new branch
services.{name}.productionRun this service in production mode
services.{name}.env_varsPer-service environment variable overrides

Destroy Playground

DELETE /api/playgrounds/:id

Destroys all containers and resources. Returns 202 Accepted.


Rollout

POST /api/playgrounds/:id/rollout

Performs an incremental update of the Playground. Unchanged containers stay running. For services with zero-downtime enabled (playgrounds.zerodowntime: true), a rolling update is performed via docker rollout. Returns 200 OK.


Hard Restart

POST /api/playgrounds/:id/hard_restart

Performs a full teardown (docker compose down) followed by a fresh provisioning cycle (docker compose up). All containers restart. All images are re-pulled. Preserves volumes if the Playspec has persist_volumes enabled. Returns 200 OK.

Rollout vs Hard Restart:

RolloutHard Restart
DowntimeNear-zero (unchanged services stay)Full reprovision cycle
VolumesAlways preservedPreserved only if persist_volumes enabled
Image refreshSkipped (no prepull)All images re-pulled
Config changesApplied incrementallyApplied from scratch
Use caseDeploy code updates, apply small config changesRecover stuck services, major infrastructure changes

Extend Expiration

POST /api/playgrounds/:id/extend_expiration

Parameters:

ParameterTypeDescription
duration_hoursintegerHours to extend by (default: 8)

Response:

{
"id": 1,
"expires_at": "2025-01-16T02:30:00Z",
"time_remaining": 57600.0
}

Get Generated Compose

GET /api/playgrounds/:id/compose

Returns the final Docker Compose YAML generated by the platform:

{
"compose_yaml": "services:\n web:\n ...",
"compose_project": "pg-1-feature-auth"
}

Get Service Logs

GET /api/playgrounds/:id/logs/:service?tail=100

Parameters:

ParameterTypeDefaultDescription
tailinteger100Number of lines to return (max: 1000)

Response:

{
"service": "web",
"lines": [
"=> Booting Puma",
"=> Rails 8.0.0 application starting in development",
"* Listening on http://0.0.0.0:3000"
],
"source": "live"
}

For completed job-mode Playgrounds, logs are returned from cache ("source": "cached").


Get Environment Metadata

GET /api/playgrounds/:id/env_metadata

Returns the fully merged environment variables with source tracking:

{
"merged": {
"DATABASE_URL": "postgres://db/myapp",
"RAILS_ENV": "development",
"PLAYGROUND_ID": "1"
},
"metadata": {
"DATABASE_URL": { "value": "postgres://db/myapp", "source": "override" },
"RAILS_ENV": { "value": "development", "source": "default" },
"PLAYGROUND_ID": { "value": "1", "source": "system" }
},
"system_keys": ["PLAYGROUND_ID"],
"generated_keys": ["SECRET_KEY_BASE"]
}

Get Debug Info

GET /api/playgrounds/:id/debug

Returns comprehensive diagnostic information including the generated Compose YAML, augmented template, service configuration, build records, and branch clone details — useful for troubleshooting deployment issues.

{
"id": 1,
"compose_project": "pg-1-feature-auth",
"generated_compose_yaml": "services:\n web:\n ...",
"augmented_compose_template": "...",
"services_configuration": [...],
"build_overrides": {},
"build_records": [...],
"branch_clones": [...]
}