Environments: detailed guide
This page focuses on the environment-specific parts of the SDK: creation, configuration, status management, and worker registration. If you haven’t set up aControlPlaneClient yet, see the Client Quick Start at Client Overview for initialization and authentication instructions.
Create an environment example
The following example demonstrates creating an environment using the Control Plane SDK:Core Operations
List Environments
Retrieve a list of environments with optional status filtering:| Parameter | Type | Default | Description |
|---|---|---|---|
status_filter | str | None | Filter by status: active, inactive, provisioning, ready, error |
| Status | Description |
|---|---|
active | Environment is active and running |
inactive | Environment is disabled |
provisioning | Environment is being set up |
ready | Environment is ready for use |
error | Environment encountered an error |
Get Environment Details
Fetch a single environment’s details by UUID:Create Environment
Create a new environment:| Field | Type | Required | Description |
|---|---|---|---|
name | str | Yes | Environment name (typically uppercase, e.g., PRODUCTION) |
display_name | str | No | Human-readable display name |
description | str | No | Environment description |
tags | list | No | List of tags for categorization |
priority | int | No | Priority level (default: 5) |
policy_ids | list | No | List of policy IDs to apply |
execution_environment | dict | No | Execution environment configuration |
| Field | Type | Description |
|---|---|---|
env_vars | dict | Environment variables |
secrets | list | List of secret names to inject |
integration_ids | list | List of integration IDs to enable |
Update Environment
Update an existing environment’s configuration (partial update - only provided fields are updated):Delete Environment
Permanently remove an environment by UUID:Worker Registration
Get Worker Command
Get the worker registration command for an environment. This returns the kubiya worker start command with the worker token:Error Handling
The Environments Service raisesEnvironmentError for API errors:
Best Practices
- Use descriptive environment names (e.g.,
production,staging,development) - Monitor environment status, especially during provisioning
- Keep track of environment UUIDs for worker registration
- Use separate environments for different deployment stages
- Check environment status before routing tasks to workers
- Handle
provisioningstatus appropriately in automation scripts